[ create a new paste ] login | about

Link: http://codepad.org/NcGDkM4x    [ raw code | output | fork ]

C++, pasted on Oct 17:
//#pragma argsused
#include <iostream.h>
#include <ctime>
#include <cstdlib>
 
using namespace std;
int main()
{
srand(time(NULL));
const int n = 5;
int a[n][n];
cout<<"Enter matrix 5x5:\n";
for(int i=0; i<n; i++)
for(int j=0; j<n; j++)
    a[i][j]=rand()%50;
int max_i = 0, max_j = 0;
int max = a[0][0];
for(int i=0; i<n; i++)
for(int j=0; j<n; j++)
if(a[i][j] > max)
{
max = a[i][j];
max_i = i;
max_j = j;
}
int res = 1;
for(int i=0; i<n; i++)
for(int j = n-1; j>i; j--)
res *= a[i][j]; //перемножуєм всі елементи масиву;
cout << "Max element: i = " << max_i << ", j = " << max_j << endl; //максимального елементу;
cout<< "Resultat: " << res<<endl;
system("pause");
return 0;
} 


Output:
1
2
3
4
5
Enter matrix 5x5:
Max element: i = 3, j = 4
Resultat: -614792704

Disallowed system call: SYS_fork


Create a new paste based on this one


Comments: