tungggg

check xem xau "python" co xuat hien dung thu tu trong xau s hay khong, bat chap do dai xau s la bao

Mar 16th, 2022
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.83 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. void lowlize(string & s){
  5.     for (int i=0;i<s.size();i++){
  6.         if ( isalpha(s[i])){
  7.             s[i]=tolower(s[i]);
  8.         }
  9.     }
  10. }
  11.  
  12. int main(){
  13.     string s;
  14.     cin>> s;
  15.  
  16.     string destination = "python";
  17.     int start = 0 ;
  18.     int countReplace = 0 ;
  19.  
  20.         for (int i=0;i<destination.size();i++){
  21.             for (int j=start ;j<s.size();j++){
  22.                 if ( destination[i] == s[j]){
  23.                     start= j+1;
  24.                     destination[i]=' ';
  25.                     s[j]=' ';
  26.                     countReplace ++ ;
  27.                     break;
  28.                 }
  29.             }
  30.         }
  31.        
  32.         if (countReplace == destination.size() ){
  33.             cout<<"YES";
  34.         }
  35.         else cout<<"NO";
  36.        
  37.  
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment