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;

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

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

    if (a < b) {
    else if (a > b) {
    else {

No comments:

Post a Comment