Advertisement
Emanuele_Bruno

Cercare le vocali in una matrice di stringhe di un alfabeto

Nov 23rd, 2015
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.41 KB | None | 0 0
  1. #include <iostream>
  2. #include <ctime> // srand
  3. #include <cstdlib> // srand
  4. #include <iomanip> // setw
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10.     int righe,colonne,i=0,j=0,k=0,lunghezza_stringa,l,m;
  11.     string confronto="aeiou";
  12.     l=confronto.length();
  13.     cout << "Indicare la grandezza della matrice di stringhe.\n";
  14.     cout << "Righe :";
  15.     cin >> righe;
  16.     cout << "Colonne :";
  17.     cin >> colonne;
  18.     cout << "Lunghezza stringa :";
  19.     cin >> lunghezza_stringa;
  20.     string matrice[righe][colonne];
  21.     srand(time(0));
  22.  
  23.     // inizializzo matrice
  24.  
  25.     while (i<righe)
  26.     {
  27.         j=0;
  28.         while (j<colonne)
  29.         {
  30.             k=0;
  31.             while (k<lunghezza_stringa)
  32.             {
  33.                 matrice[i][j]+=char(rand()%26+97);
  34.                 k++;
  35.             }
  36.             cout << matrice[i][j] << " ";
  37.             j++;
  38.         }
  39.         cout << "\n";
  40.         i++;
  41.     }
  42.  
  43.     // ricerca delle vocali nelle stringhe
  44.  
  45.     i=0;
  46.     while (i<righe)
  47.     {
  48.         j=0;
  49.         while (j<colonne)
  50.         {
  51.             k=0;
  52.             while (k<lunghezza_stringa)
  53.             {
  54.                 m=0;
  55.                 while (m<l)
  56.                 {
  57.                     if (matrice[i][j][k]==confronto[m]) cout << confronto[m];
  58.                     m++;
  59.                 }
  60.                 k++;
  61.             }
  62.             j++;
  63.         }
  64.         i++;
  65.     }
  66.     return 0;
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement