Once read two-line string

Here Insert Picture Description

//we have defined the necessary header files here for this problem.
//If additional header files are needed in your program, please import here.
#include<iostream>
#include<string>
string compress(string a){
    string b;
    for(int i=0;i<a.size();i++){
        if(a[i]!=' ')
            b.push_back(a[i]);
    }
    return b;
}

bool compare(string a,string b){
    if(a.size()!=b.size()){
        return false;
    }    
    for(int i=0;i<a.size();i++){
        if(a[i]!=b[i]){
            if(abs(a[i]-b[i])!=32)
                return false;
        }
    }
    return true;
}

int main(){
  
    string a,b;
    while(getline(cin,a)&&getline(cin,b)){
        a=compress(a);
        b=compress(b);
        bool f=compare(a,b);
        if(f==true)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
 
  return 0;
}

Published 13 original articles · won praise 7 · views 4292

Guess you like

Origin blog.csdn.net/qq_29230349/article/details/104449504