D-Gj

Oddelni zborovi vo tekst

Mar 3rd, 2013
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.82 KB | None | 0 0
  1. // Da se najdat site zborovi vo nekoj tekst.
  2.  
  3. #include <iostream>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     char text[500], word[50][500];
  10.     int m = 0, n = 0;
  11.  
  12.     cout << "Vnesi tekst: ";
  13.     cin.getline(text, 500);
  14.     cout << endl;
  15.  
  16.     for (int i = 0;;++i)
  17.     {
  18.         if (text[i] == '\0')
  19.         {
  20.             word[m][n] = '\0';
  21.             break;
  22.         }
  23.         else if (!(text[i] == ',' || text[i] == '.' || text[i] == ';' || text[i] == ':' || text[i] == '!' || text[i] == '?'))
  24.         {
  25.             if (text[i] == ' ')
  26.             {
  27.                 word[m++][n] = '\0';
  28.                 n = 0;
  29.             }
  30.             else
  31.             {
  32.                 word[m][n++] = text[i];
  33.             }
  34.         }
  35.     }
  36.  
  37.     for (int i = 0; i <= m; ++i) cout << word[i] << endl;
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment