string comparison multiple instances

Source: Internet
Author: User

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&GT;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" &LT;&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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.