Advertisement
AlexandruFilipescu

C++ Read from the keyboard util the word "gata" and show the longest word that contains only vocals

Jul 18th, 2019
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.74 KB | None | 0 0
  1. #include <iostream>
  2. #include <string.h>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.     char cuvant[100], copie[100];
  8.     bool esteVocala;
  9.     bool verificare;
  10.     char vocale[] = "aeiou";
  11.     char max[100] = "\0";
  12.     int i, j;
  13.  
  14.     verificare = false;
  15.     esteVocala = false;
  16.     while (strcmp("gata" ,cuvant)) {
  17.         cin >> cuvant;
  18.  
  19.         for (i = 0; i < strlen(cuvant);i++) {
  20.             esteVocala = false;
  21.             for (j = 0; j < strlen(vocale);j++) {
  22.                 if (cuvant[i] == vocale[j]) {
  23.                     esteVocala = true;
  24.                 }
  25.             }
  26.             if (!esteVocala) {
  27.                 verificare = false;
  28.                 break;
  29.             } else {
  30.                 verificare = true;
  31.             }
  32.         }
  33.         if (verificare) {
  34.             if (strlen(cuvant) > strlen(max)) {
  35.                 strcpy_s(max, cuvant);
  36.             }
  37.         }
  38.        
  39.     }
  40.  
  41.     cout << "Cel mai lung cuvant si doar cu vocale: " << max << endl;
  42.  
  43.     system("pause");
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement