Advertisement
Emanuele_Bruno

Esercizio 2 del 03/02/2015

Dec 14th, 2015
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.97 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. const int N=4;
  6.  
  7. string matrice[][N]={{"casa","trota","palo","lago"},
  8.                     {"amo","limo","ino","lino"},
  9.                     {"l","augurio","di","un"},
  10.                     {"buono","anno","a","tutti"}};
  11.  
  12. void puntatore (string matrice[][N],int N);
  13. string concatena (string stringhe);
  14.  
  15. int main()
  16. {
  17.     puntatore(matrice,N);
  18.     return 0;
  19. }
  20.  
  21. void puntatore (string matrice[][N],int N)
  22. {
  23.     int i=0,k=N-1;
  24.     string stringa;
  25.     while (i<N)
  26.     {
  27.         stringa+=concatena(matrice[i][k]);
  28.         k--;
  29.         i++;
  30.     }
  31.     cout << "Ed ecco a voi l'indirizzo della stringa "<<stringa<<":"<<&stringa;
  32. }
  33.  
  34. string concatena (string stringhe)
  35. {
  36.     int lunghezza=stringhe.length();
  37.     string carattere; // la stringa inizializzata e' un carattere vuoto
  38.     if (lunghezza%2) carattere+=stringhe[(lunghezza/2)];
  39.     return carattere; // restituisco il carattere vuoto oppure il carattere di mezzo
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement