[text] bien doi xau

Viewer

copydownloadembedprintName: bien doi xau
  1. #include<iostream>
  2. using namespace std;
  3. int main(){
  4.     int Q;
  5.     cin>>Q;
  6.     while (Q){
  7.     string a;
  8.     string b;
  9.     cin>>a;
  10.     cin>>b;
  11.     int tmpIndex=-1;
  12.     int cnt=0;
  13.     for (int i=0;i<b.length();i++){
  14.         for (int j=0;j<a.length();j++){
  15.             if (b[i]==a[j]||b[i]==a[j]-32){
  16.                 if (j>tmpIndex){
  17.                 cout<<a[j]<<" ";
  18.                 a[j]='0';
  19.                 cnt++;
  20.                 tmpIndex=j;
  21.                 break;
  22.                 }
  23.                 
  24.             }
  25.         }
  26.     }
  27.     int cnt1=0;
  28.     if (cnt==b.length()){
  29.         for (int i=0;i<a.length();i++){
  30.             if (a[i]!='0'&&a[i]>='a'&&a[i]<='z'){
  31.                 cnt1++;
  32.             }
  33.         }
  34.         if (cnt1==a.length()-b.length()){
  35.             cout<<"YES"<<endl;
  36.         }
  37.         else cout<<"NO"<<endl;
  38.     }
  39.     else cout<<"NO"<<endl;
  40.     Q--;
  41.     }
  42.     return 0;
  43. }

Editor

You can edit this paste and save as new:


File Description
  • bien doi xau
  • Paste Code
  • 23 Nov-2021
  • 928 Bytes
You can Share it: