Advertisement
Guest User

Untitled

a guest
Dec 11th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. #include <fstream>
  2. #include <cstring>
  3.  
  4.  using namespace std;
  5.  
  6.  ifstream fin("cuvmax.in");
  7. ofstream fout("cuvmax.out");
  8.  
  9. int nrcuv(char * s){
  10. int c = 0; if(s[0]!=' ')
  11. c++;
  12. for(int i=1 ; s[i] ; ++i)
  13. if(s[i]!=' ' && s[i-1]==' ')
  14. c++;
  15.  return c;
  16.  }
  17. int main(){
  18.  int n;
  19.  char s[251], m[251];
  20.  fin >> n;
  21. fin.get();
  22. fin.getline(m,251);
  23. for( ; n ; --n){
  24. fin.getline(s,251);
  25. if(nrcuv(s) > nrcuv(m))
  26. strcpy(m,s);
  27. }
  28. fout << m << endl;
  29.  return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement