Advertisement
Guest User

Untitled

a guest
Apr 25th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. const int DIM1 = 20, DIM2 = 20;
  6.  
  7. int Summa(int *ar, int size){
  8.  
  9. int sum = 0;
  10.  
  11. for(int i = 0; i < size; i++)
  12.  
  13. sum = sum + ar[i];
  14.  
  15. return sum;
  16.  
  17. }
  18.  
  19. int main(){
  20.  
  21. int matr[DIM1][DIM2], s[DIM1];
  22.  
  23. int n, m, i, j;
  24.  
  25. cout<<"Vvedi n, m: "; cin>>n>>m;
  26.  
  27. srand(n+m);
  28.  
  29. for(i = 0; i < n; i++)
  30.  
  31. for(j = 0; j < m; j++)
  32.  
  33. matr[i][j] = rand() % 25 - 10;
  34.  
  35. for(i = 0; i < n; i++){
  36.  
  37. for(j = 0; j < m; j++){
  38.  
  39. cout.width(4); cout<<matr[i][j];
  40.  
  41. }
  42.  
  43. cout<<endl;
  44.  
  45. }
  46.  
  47. cout<<"\t\tSum elementov strok== "<<endl;
  48.  
  49. for(i = 0; i < n; i++)
  50.  
  51. s[i] = Summa(matr[i], m); // вызов функции Summa()
  52.  
  53. for(i = 0; i < n; i++)
  54.  
  55. cout<<'\t'<<s[i];
  56.  
  57. cout<<endl;
  58.  
  59. system("pause");
  60.  
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement