Time limit than size: 3000 MS | Memory limit: 65535 KB Difficulty: 2 description
Give you two very large numbers, can you tell the size of their two numbers?
For example 123456789123456789 to be greater than 123456 enter one row for each set of test data, and enter two 1000-bit 10 integer a,b
The data guarantees that the input a,b does not have a prefix of 0.
If input 0 0 indicates the end of input. The number of test data sets is not more than 10 sets of output if the a>b output "a>b", if a<b output "a<b", if equal output "a==b". Sample input
111111111111111111111111111 88888888888888888888
-1111111111111111111111111 22222222
0 0
Sample output
A>b
A<b
For this problem deep feeling, in Nanyang OJ submitted 8 times just congratulations, to the last found error let me no words, the following is I write the AC code.
#include <stdio.h> #include <string.h> char a[1005],b[1005]; int main () {int t=0; while (scanf ("%s%s", &a,&b) && (a[0]!= ' 0 ' | | b[0]!= ' 0 ') { if (a[0]== '-' &&b[0]== '-') { if (
Strlen (a) >strlen (b)) printf ("a<b\n", a,b);
else if (strlen (a) <strlen (b)) printf ("a>b\n", a,b); else { if (strcmp (a,b) >0)
printf ("a<b\n", a,b);
else if (strcmp (a,b) <0) printf ("a>b\n", a,b);
else printf ("a==b\n", a,b);
&NBSP;&NBSP;&NBSP;&NBSP}  } else if (a[0]!= '-' &&b[0]!= '-') { if (strlen (a) >strlen (b)) &NBSP;&NBSP;&NBSP;&NBsp;printf ("a>b\n", a,b);
else if (strlen (a) <strlen (b)) printf ("a<b\n", a,b); else { if (strcmp (a,b) >0)
printf ("a>b\n", a,b);
else if (strcmp (a,b) <0) printf ("a<b\n");
else printf ("a==b\n"); &NBSP;&NBSP;&NBSP;&NBSP}  } else { if (a[0]== '-' &&b[0]!= '-'
) printf ("a<b\n", a,b);
else printf ("a>b\n", a,b);
} t++;
if (t==10) break;
  return 0; }
The idea of this problem is not difficult, with a character array simulation on the line, enumerate all the situations violently; for two negative numbers, compare the length of the string, who is the smaller, and if the length is equal, call the strcmp () function to compare; if one is negative, it is directly judged size; two integers, as opposed to two negative numbers;
For me Nanyang OJ did not pass, the title requires the output character a<b,a>b,a==b. And I have the output of two, this error for a morning, and the test data is up to 10 groups, so not more than 10 groups, this should be taken into account.