1155: string comparison multi-instance time limit: 1 Sec Memory Limit: MB
Submit: 361 Solved: 155
Submitstatusweb Board Description
compares the string size, but compares the rules with different dictionary order rules. The new rules for character comparisons are as follows:A < a < b < b < ... < Z < Z.
Input
The input data contains multiple test instances, each of which takes two lines, and each row has a string (only uppercase and lowercase letters with a length of less than 10000).
Output
If the first string is less than the second one, the output is yes, otherwise, the output is no.
Note: A < a < b < b < .... < Z < Z.
Sample InputABCBBCABAABCEFABCESample OutputYesyesnoHINT
SourceSome details should be noted. For example A and A,a and a, Lena and LenB length, of course, for me this program ...
#include <iostream> #include <string.h> #include <stdio.h>using namespace Std;char a[10000],b[10000] ; int main () {memset (a,0,sizeof (a)); Memset (b,0,sizeof (b)); while (scanf ("%s%s", &a,&b)!=eof) {int lena,lenb,i,temp; Lena=strlen (a); Lenb=strlen (b); if (strcmp (A, b) ==0) {cout<< "NO" <<endl; } else {if (LENA>LENB) Temp=lena; else Temp=lenb; for (i=0;i<temp;i++) {if (a[i]==b[i]) continue; else {if (a[i]>= ' a ' &&a[i]<= ' z ' &&b[i]>= ' a ' &&b[i]<= ' Z ' | | A[i]>= ' a ' &&a[i]<= ' z ' &&b[i]>= ' a ' &&b[i]<= ' Z ') {if (A[i] <b[i]) {cout<< "YES" <<endl; Break } else {cout<< "NO" <<endl; Break }} else if (a[i]>= ' a ' &&a[i]<= ' z ' &&b[i]>= ' a ' &&b[i]<= ' Z ') {if (A[i]-32<b[i]) {cout<< "YES" << Endl Break } else {cout<< "NO" <<endl; Break }} else if (a[i]>= ' a ' &&a[i]<= ' z ' &&b[i]>= ' a ' &&b[i]<= ' Z ') {if (A[i]+32<=b[i]) {cout<< "YES" <&L T;endl; Break } else {cout<< "NO" <<endl; Break }} else { if (A[i]<b[i]) {cout<< "YES" <<endl; Break } else {cout<< "NO" <<endl; Break }}}}}} return 0;}
String comparison multiple instances