RicoHeartless

Laba 1.1 (2K)

Sep 18th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. #include <iostream>
  2. #include <cctype>
  3.  
  4. using namespace std;
  5.  
  6. char* InputSent();
  7. char* myFunc(char* text);
  8.  
  9. //char* InputSent()
  10. //{
  11. //  const int n = 100;
  12. //  char input[n];
  13. //  cin.getline(input, n);
  14. //  return input;
  15. //}
  16.  
  17. void myFunc(){
  18.     const char n = 100;
  19.     char text[n];
  20.     cout << "Enter string: ";
  21.     cin.getline(text, 100);
  22.     int wordSum = 1;
  23.     int a = 0;
  24.     for (int i(0); text[i] != '\0'; i++)
  25.     {
  26.         if (isalpha(text[i])){
  27.             a++;
  28.         }
  29.         if (text[i] == ' '){ wordSum++; };
  30.     }
  31.     int result = a / wordSum;
  32.     cout << "Result: " << result << endl;
  33. }
  34.  
  35.  
  36.  
  37. void main()
  38. {
  39.     myFunc();
  40. }
Add Comment
Please, Sign In to add comment