fork download
  1. #include <cctype>
  2. #include <cstdio>
  3. #include <vector>
  4. #include <string>
  5. #include <iostream>
  6. using namespace std ;
  7.  
  8. int main()
  9. {
  10. int t , len ;
  11. int i ;
  12. string str ;
  13. string res ;
  14.  
  15. cin >> t ;
  16.  
  17. while( t-- ){
  18. getline ( cin , str );
  19. res = "" ;
  20. len = str.size() ;
  21. for ( i = 0 ; i < len ; i++ ){
  22. if ( isalpha(str[i]) && ( i == 0 || str[i-1] == ' ' ) ){
  23. res.append(1,str[i]);
  24. }
  25. }
  26. res.append(1,'\0');
  27. cout << res << endl ;
  28. }
  29.  
  30. return 0;
  31. }
Success #stdin #stdout 0.01s 2860KB
stdin
5
 Goku    part
      y      TTTTTT
MY NAM EI A ADFADJKN  
        M
M  
stdout

Gp
yT
MNEAA
M