Uva 11942 Solution

#include<bits/stdc++.h>
using namespace std;
bool anik(int a, int b)
{
    return (a>b);
}
int main()
{
    int n, m, i, j, k;
    while(cin >> n && n > 0 && n <20)
    {
        cout << "Lumberjacks:" << endl;
        for(k=1; k<=n; k++)
        {
            int a[10], b[10], c[10];
            for(i=0; i<10; i++)
            {
                cin >> a[i];
                b[i] = a[i];
                c[i] = a[i];
            }

            sort(b, b+10);
            sort(c, c+10, anik);
            int f = 0, t = 0;
            for(i=0; i<10; i++)
            {
                if(a[i] != b[i])
                {
                    f = 1;
                    break;
                }
            }
            if(f == 0)
            {
                cout << "Ordered" << endl;
                continue;
            }
            else
            {
                for(i=0; i<10; i++)
                {
                    if(a[i] != c[i])
                    {
                        t = 1;
                        break;
                    }
                }
            }
            if(t == 0)
            {
                cout << "Ordered" << endl;
                continue;
            }
            if(t==1 && f == 1)
                cout << "Unordered" << endl;
        }
    }
    return 0;
}

Comments