Monday, October 13, 2014

11172 - Relational Operator

This is probably the easiest problem I ever solved in UVA.

I thought that there must be some kind of trick here. Some technicality that would make the problem extra tricky and deceiving. But it looks like there's no trick or deception here. It looks like just a really easy problem.

I also discovered that gets() can be used for these types of problems, instead of my usual fgets() style.

Here's the code:

#include "stdio.h"

int main() {
  char line[100];
  int n, i, a, b;

  gets(line);
  sscanf(line, "%d", &n);

  for (i = 0; i < n; i += 1) {
    gets(line);
    sscanf(line, "%d %d", &a, &b);
//   printf("A=%d, B=%d\n", a, b);

    if (a < b) {
      printf("<\n");
    }
    else if (a > b) {
      printf(">\n");
    }
    else {
      printf("=\n");
    }
  }
}

No comments:

Post a Comment