Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int main()
- {
- int num[3][5] = {{2,4,6,8,10},{5,10,15,20,25},{3,6,9,12,15}};
- int sum1, sum2;
- int ave1, ave2;
- int temp, ctr=0;
- int a,b,d,e;
- //Asc array
- for(int a = 0; a < 3; a++){
- for(int b = 0; b < 5; b++){
- for(int e = 0; e < 3; e++){
- for(int d = 0 ; d < 5; d++){
- if(num[a][b] < num[e][d]){
- temp = num[a][b];
- num[a][b] = num[e][d]; //
- num[e][d] = temp;
- }
- }
- }
- }
- }
- cout<<"\nAscend Multi Array:\n";
- for (int e = 0; e < 3 ; e++){
- for(int d = 0 ; d < 5; d++){
- cout <<num[e][d] << " , ";
- }
- }
- //Des array
- for(int a = 0; a < 3; a++){
- for(int b = 0; b < 5; a++){
- for(int c = 0; c < 3; e++){
- for(int d = 0 ; d < 5; d++){
- if(num[a][b] > num[e][d]){
- temp = num[a][b];
- num[a][b] = num[e][d];
- num[e][d] = temp;
- }
- }
- }
- }
- }
- cout <<"\nDescend Multi Array: ";
- for(int e = 0; e < 3 ; e++){
- for(int d = 0 ; d < 5; d++){
- cout <<num[e][d] << " , ";
- }
- }
- //rows
- for(int e = 0 ; e < 3 ; e++){
- ctr++;
- cout << "\nRows : "<< ctr;
- for(int d = 0 ; d <5 ; d++){
- sum2 += num[e][d];
- }
- ave2 = sum2/5;
- cout << "\nSum: "<< sum1;
- cout << "\nAverage: "<< ave1;
- sum2 = 0;
- ave2 = 0;
- }
- ctr = 0;
- //col
- for(int e = 0 ; e < 5 ; e++){
- ctr++;
- cout << "\nColumns : "<< ctr;
- for(int d = 0 ; d <3 ; d++){
- sum1 += num[d][e];
- sum2 += num[d][e];
- }
- ave2 = sum2/5;
- cout << "\nSum: "<< sum1;
- cout << "\nAverage: "<< ave1;
- sum2 = 0;
- ave2 = 0;
- }
- ave1 = sum1/15;
- ctr = 0;
- //Min and Max
- cout << "\nThe Table :";
- cout << "\nMin : " << num[2][4];
- cout << "\nMax : " << num[0][0];
- cout << "\nAverage of the table: " << ave1;
- cout << "\nSum of the table: " << sum1;
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement