Time limit over size: theMs | Memory Limit:65535KB Difficulty:2
-
-
Describe
-
Give you two big numbers, can you tell the size of their two numbers?
For example, 123456789123456789 to greater than-123456
-
-
Input
-
-
One row for each set of test data, enter two 1000-bit 10 binary integers, a, b
The data guarantees that the input a, B, has no prefix of 0.
If input 0 0 indicates the end of the input. No more than 10 groups of test data groups
-
-
Output
-
If
-
a>b outputs "a>b", if a<b outputs "a<b", then output "a==b" if equal.
-
-
Sample input
-
-
111111111111111111111111111 88888888888888888888-1111111111111111111111111 222222220 0
-
-
Sample output
-
-
A>ba<b
-
Uploaded by
Zhang Yunzun
At the beginning of the submission of the time to forget a==b ~ The result is wrong. Don't forget to think about it!
#include <iostream> #include <stdio.h> #include <string.h>using namespace Std;int main () {char a[1001] , B[1001];int Lena,lenb,i,count;while (scanf ("%s%s", &a,&b)) {Count=0;lena=strlen (a); Lenb=strlen (b); if (Lena ==1 && lenb==1&&strcmp (A, "0") ==0 &&strcmp (b, "0") ==0) break;if (a[0]== '-' &&b[0]!= '-' ) cout<< "A<b" <<endl; else if (a[0]!= '-' &&b[0]== '-') cout<< "A>b" <<endl;else if (a[0]!= '-' &&b[0]!= '-') {if ( LENA>LENB) cout<< "A>b" <<endl;else if (lena<lenb) cout<< "A<b" <<endl;else{ for (i=0;i<lena;i++)//aabc aace {if (A[i]>b[i]) {cout<< ' a>b ' <<endl; break;} else if (A[i]==b[i]) {count++; Continue } else {cout<< "a<b" <<endl; break;}} if (Count==lena) cout<< "A==b" <<endl;}} else if (a[0]== '-' &&b[0]== '-') {if (LENA>LENB) {cout<< "a<b" <<endl;} else if (LENA<LENB) {cout<< "a>b" <<endl;} else {for (i=0;i<le na;i++)//aabc Aace {if (A[i]>b[i]) {cout<< "a<b" <<endl; break;} else if (A[i]==b[i]) {count++; continue; } else {cout<< "a>b" <<endl; break;}} if (Count==lena) cout<< "A==b" <<endl; }}}return 0;}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
than the size