Advertisement
RicoHeartless

Laba 1.1 (2K) (NEW)

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