Advertisement
Guest User

Untitled

a guest
Oct 5th, 2019
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.95 KB | None | 0 0
  1. #include <iostream>
  2. #include <sstream>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. main(){
  8.  
  9.     string sentance;
  10.     getline(cin,sentance);
  11.     istringstream istr(sentance);
  12.     string word;
  13.     int maxSig=INT_MIN;
  14.     string longest;
  15.     bool check=false;
  16.  
  17.     while(istr>>word)
  18.     {
  19.         size_t sizeW= word.size();
  20.         string noise;
  21.  
  22.         for(int a =0;a<sizeW; ++a)
  23.         {
  24.             if(word[a]>='0' && word[a]<='9')
  25.             {
  26.                     continue;
  27.             }
  28.  
  29.             else{
  30.                 noise+=word.at(a);
  31.                 check=true;
  32.             }
  33.         }
  34.  
  35.         int scheck=noise.size();
  36.  
  37.         if(maxSig<=scheck)
  38.         {
  39.             maxSig=noise.length();
  40.  
  41.             if(longest>noise || longest.empty()){
  42.                 longest=noise;
  43.             }
  44.         }
  45.     }
  46.     if(check==true){
  47.     cout << longest;
  48.     }else
  49.     {
  50.         cout<<"no noise";
  51.     }
  52.  
  53. return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement