Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdlib.h>
  3. #include <time.h>
  4. #include <iomanip>
  5. #define n 8
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10.     setlocale(LC_ALL,"");
  11.     int i,j,A[n][n],summa=0,max=0;
  12.     srand(time(NULL));
  13.     for(i=0;i<n;i++){
  14.         for(j=0;j<n;j++){
  15.             A[i][j]=rand()%100-20;}}
  16.            
  17.     for(i=0;i<n;i++){
  18.         for(j=0;j<n;j++){
  19.             if( A[i][j]<0){summa+=A[i][i];if(A[i][i]>max){max=A[i][i];}}
  20.         }  
  21.     }
  22.    
  23.     for(i=0;i<n;i++){
  24.         for(j=0;j<n;j++){
  25.             cout << setw(6) << A[i][j];
  26.         }  
  27.         cout << endl;
  28.     }
  29.    
  30.     cout << "Максимальное число = " << max << endl;
  31.     cout << "Сумма = " << summa << endl;
  32.     cout << endl;
  33.     cout<<"Автотр:Димид Олександр"<<endl;
  34.     system("pause");
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement