Advertisement
Guest User

47/108

a guest
Nov 23rd, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.76 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <cstring>
  4.  
  5. using namespace std;
  6.  
  7. void citire(char* str, size_t size)
  8. {
  9.     ifstream infile("date.in");
  10.  
  11.     infile.get(str, size);
  12. }
  13.  
  14. int CountValidWords(char* str)
  15. {
  16.     int wordCount = 0;
  17.     for(int i = 0; i < strlen(str); i++)
  18.     {
  19.         int start = 0, end = 0;
  20.  
  21.         if(str[i] != ' ' && str[i] != '_')
  22.         {
  23.             start = i;
  24.             while(str[i] != ' ' && str[i] != '_' && i < strlen(str))
  25.             {
  26.                 end = i++;
  27.             }
  28.  
  29.             if(end - start + 1 >= 7)
  30.             {
  31.                 char* aux;
  32.                 strncpy(aux, str + start, end - start + 1);
  33.                 if(strchr(aux, 'u') != NULL)
  34.                 {
  35.                     wordCount++;
  36.                 }
  37.             }
  38.         }
  39.  
  40.     }
  41.     return wordCount;
  42. }
  43.  
  44. int main()
  45. {
  46.     char str[500];
  47.  
  48.     citire(str, 500);
  49.  
  50.     cout << CountValidWords(str);
  51.  
  52.     return 0;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement