Pages

Thursday 13 September 2012

UVA -11942 - Lumberjack Sequencing

#include <stdio.h>
#include <stdbool.h>

int main()
{   int t=0,x,xlast,i,j;
    scanf("%d",&t);
    printf("Lumberjacks:\n");
    bool asc=true,dsc=true;
    for(i=0;i<t;i++){
        asc=true;
        dsc=true;
        scanf("%d",&xlast);
        for(j=1;j<10;j++){
            scanf("%d",&x);
            if(x>xlast){
               dsc=false;
            }else if(x<xlast){
               asc=false;
            }
            xlast=x;
        }
        if(asc || dsc)
            printf("Ordered\n");
        else
            printf("Unordered\n");
  }
    return 0;
}

No comments:

Post a Comment