Introduction

This is my blog of programming, I take notes and leave codes of computer science problems I solved here. Be my guest to comment :)

Monday, December 3, 2012

uva 11942 - Lumberjack Sequencing


/*
Problem link
*/
#include <iostream>
#include <cstdio>
using namespace std;
const int n = 10;

int a[n];

int main() {
 int ntest;
 cin >> ntest;
 cout << "Lumberjacks:" << endl;
 for (int test=1; test<=ntest; test++)
 {
  for (int i=1; i<=n; i++) cin >> a[i];
  int tmp = a[2]-a[1];
  int i;
  for (i=3; i<=n; i++)
   if ((a[i]-a[i-1])*tmp<=0)
   {
    cout << "Unordered" << endl;
    break;
   }
  if (i==n+1) cout << "Ordered" << endl;
 }
 return 0;
}

No comments:

Post a Comment