fork download
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <iomanip>
  4. using namespace std;
  5. void wypelnij(float tab[5][4])
  6. {
  7. for(int i=0; i<5; i++)
  8. {
  9. for(int j=0; j<4; j++)
  10. {
  11. cout<<"Podaj wartosc elementu: ";
  12. cin>>tab[i][j];
  13. }
  14. }
  15. }
  16. //------------------------------------------------
  17. void wyswietl(float tab[5][4])
  18. {
  19. for(int i=0; i<5; i++)
  20. {
  21. for(int j=0; j<4; j++)
  22.  
  23. {
  24. cout<<setw(4)<<tab[i][j];
  25. }
  26. cout<<endl;
  27. }
  28. }
  29. //-------------------------------------------------
  30. void suma(float tab[5][4])
  31. {
  32. int suma=0;
  33. for(int i=0;i<5;i++)
  34. {
  35. for(int j=0; j<4; j++){
  36.  
  37. suma+=tab[i][j];
  38. }
  39.  
  40. cout<<"Suma wiersza " << i+1;
  41. cout<<": " <<suma;
  42. cout<<endl;
  43. suma =0;
  44. }
  45. }
  46. //-------------------------------------------------
  47. int main()
  48. {
  49. float tab1[5][4];
  50. wypelnij (tab1);
  51. cout<<endl;
  52. wyswietl (tab1);
  53. suma (tab1);
  54.  
  55. cin.ignore();
  56. getchar();
  57. return 0;
  58.  
  59.  
  60. }
Success #stdin #stdout 0s 3432KB
stdin
1 2 3 4
2 3 4 5
3 4 5 6
4 5 6 7
5 6 7 8
stdout
Podaj wartosc elementu: Podaj wartosc elementu: Podaj wartosc elementu: Podaj wartosc elementu: Podaj wartosc elementu: Podaj wartosc elementu: Podaj wartosc elementu: Podaj wartosc elementu: Podaj wartosc elementu: Podaj wartosc elementu: Podaj wartosc elementu: Podaj wartosc elementu: Podaj wartosc elementu: Podaj wartosc elementu: Podaj wartosc elementu: Podaj wartosc elementu: Podaj wartosc elementu: Podaj wartosc elementu: Podaj wartosc elementu: Podaj wartosc elementu: 
   1   2   3   4
   2   3   4   5
   3   4   5   6
   4   5   6   7
   5   6   7   8
Suma wiersza 1:  10
Suma wiersza 2:  14
Suma wiersza 3:  18
Suma wiersza 4:  22
Suma wiersza 5:  26