Advertisement
Five_NT

problema2

Dec 22nd, 2015
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.93 KB | None | 0 0
  1.  
  2. void problema2(const char *input_file_name, const char *output_file_name)
  3. {
  4.     int sem = 0;
  5.     int cuv = 0;
  6.     ifstream fin(input_file_name);
  7.     ofstream fout(output_file_name);
  8.     char s[2001];
  9.     char chr[] = ".,-;:'\"()...?!";
  10.     while ( fin.getline(s, 2000) )
  11.     {
  12.         for (unsigned int i = 0 ; i<strlen(s) ; i++)
  13.         {
  14.             if ((s[i] >= '1' && s[i] <= '9') || (s[i] >= 'a' &&  s[i] <= 'z') || (s[i] >= 'A' && s[i] <= 'Z'))
  15.             {
  16.                 cuv++;
  17.                 while ((s[i] >= '1' && s[i] <= '9') || (s[i] >= 'a' &&  s[i] <= 'z') || (s[i] >= 'A' && s[i] <= 'Z'))
  18.                     i++;
  19.             }
  20.             if ( strchr(chr, s[i]) &&  (i+2 < strlen(s)))//s[i+1] != NULL && s[i+2] != NULL)
  21.             {
  22.                 if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.')
  23.                     i = i + 2;
  24.                 sem++;
  25.             }
  26.         }
  27.     }
  28.     fout << cuv << '\n';
  29.     fout << sem << '\n';
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement