#12530: C++ 簡易參考解答


shawn2000100 (東華財金)

學校 : 國立東華大學
編號 : 57300
來源 : [27.53.168.5]
最後登入時間 :
2021-09-19 19:53:19
d424. 00105 - The Skyline Problem -- UVa105 | From: [124.9.163.172] | 發表日期 : 2017-08-07 22:04

#include <iostream>
using namespace std;

int main() {
int left, height, right, coordinate[10001] = {0};

while ( cin >> left >> height >> right ) {
for ( int i = left; i < right; ++i )
if ( height > coordinate[i] )
coordinate[i] = height;
}

for ( int i = 0; i < 10001; ++i ) {
if ( coordinate[0] && 0 == i )
cout << "0 " << coordinate[0] << " ";

if ( coordinate[i + 1] != coordinate[i] )
cout << (i + 1) << " " << coordinate[i + 1] << " ";
}

cout << endl;
return 0;
}

 
ZeroJudge Forum