fork download
  1. #include <iostream>
  2. #include <locale>
  3. #include <cstring>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. setlocale(LC_ALL, "rus");
  9. char S[100];
  10. int n, i, k, kol, max = 0, y,g,j=0;
  11. cin.getline(S, 100);
  12. i = 0;
  13. for (int l=0;l<strlen(S);l++)//проходимся по длине строки, и ищем пробелы, и после каждого меряем слово.
  14. {
  15. while (S[l] != ' ')
  16. {
  17. if (S[l] == ' ')
  18. {
  19. int p=l;
  20. l++;
  21. }
  22. else
  23. {
  24.  
  25. do
  26. {
  27. l++;
  28. } while (S[l] != ' '); //длина слова
  29. kol = strlen(S)-l-p; //длина слова //p последний пробел
  30. if (kol > max)
  31. {
  32. l++;
  33. ///max word
  34. max = kol;
  35. }
  36.  
  37. }
  38.  
  39. }
  40. }
  41. for (n; n<k; n++)
  42. {
  43. cout << S[n];
  44. }
  45. cout << " - самое длинное слово" << endl;
  46.  
  47. system("pause");
  48. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:29:32: error: ‘p’ was not declared in this scope
              kol = strlen(S)-l-p; //длина слова  //p последний пробел
                                ^
stdout
Standard output is empty