UVA 105 - The Skyline Problem

代码如下:


#include <bits/stdc++.h>

using namespace std;
int x[10005];
int main()
{
    int a,b,c,d=0,i;
    memset(x,0,sizeof(x));
    while(cin>>a>>b>>c)
    {
        if(c>d)
            d=c;
        for(i=a; i<c; ++i)
            if(b>x[i])
                x[i]=b;
    }
    for(i=1; i<=d; ++i)
        if(x[i]-x[i-1])
        {
            cout<<i<<" "<<x[i];
            if(i-d)
                cout<<" ";
        }
    cout<<endl;
    return 0;
}

猜你喜欢

转载自blog.csdn.net/liuxinyu666/article/details/80008701