fork download
  1. #include <iostream>
  2. using namespace std;
  3. const int righe = 4;
  4. const int colonne = 3;
  5. int miaMat[righe][colonne];
  6. void riempiManuale()
  7. {
  8. int x, y, valore;
  9. for(x = 0; x < righe; x++)
  10. for(y = 0; y < colonne; y++)
  11. {
  12. cin >> valore;
  13. miaMat[x][y] = valore;
  14. }
  15. }
  16. void mostraMatrice()
  17. {
  18. int x, y;
  19. for(x = 0; x < righe; x++)
  20. {
  21. cout <<"/n" <<endl;
  22. for(y = 0; y < colonne; y++)
  23. cout <<miaMat[x][y] <<" ";
  24. }
  25. cout <<"/n" <<endl;
  26. }
  27. void sommaNumdisp()
  28. {
  29. int x, y, somma;
  30. for(x = 0; x < righe; x++)
  31. {
  32. for(y = 0; y < colonne; y++)
  33. {
  34. if(miaMat[x][y] % 2 == 1)
  35. somma = somma + miaMat[x][y];
  36. }
  37. }
  38. cout <<"La somma è " <<somma <<endl;
  39. }
  40. int main()
  41. {
  42. riempiManuale();
  43. mostraMatrice();
  44. sommaNumdisp();
  45. return 0;
  46. }
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
Success #stdin #stdout 0.01s 5556KB
stdin
1 2 3 4 5 6 7 8 9 10 11 12
stdout
/n
1 2 3 /n
4 5 6 /n
7 8 9 /n
10 11 12 /n
La somma è 36