fork download
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <ctime>
  4. #include <cstdlib>
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. srand(time(0));
  10. int tab[10][5];
  11. for(int y=0;y<10;++y) for(int x=0;x<5;++x) tab[y][x]=rand()%20;
  12. for(int y=0;y<10;++y)
  13. {
  14. int sum=0;
  15. for(int x=0;x<5;sum+=tab[y][x++]) cout<<setw(3)<<tab[y][x];
  16. cout<<" :"<<setw(4)<<sum<<endl;
  17. }
  18. return 0;
  19. }
Success #stdin #stdout 0s 2896KB
stdin
Standard input is empty
stdout
  0  6  3 19  7 :  35
  9  3 17 19 16 :  64
  2 11  6  8  1 :  28
  8 12 11  6 15 :  52
 14 12  4 14  6 :  50
 15  4 17 19 11 :  66
  9 11 17  5 10 :  52
  4 14 13 14  5 :  50
  9 16 16  7  4 :  52
 17 15  9  1  1 :  43