Untitled
unknown
plain_text
a year ago
894 B
12
Indexable
#include <iostream> #include <cstdio> #include <cmath> using namespace std; //4) void initialize_matrix(double A[6][6],double min, double ave, int npos); void initialize_matrix(double A[6][6],double min, double ave, int npos) { // a) intialization int i,j; A[i][j] = sin(i) + cos(j); //b) minimum value min = 1.0e10; for(i=1;i<6;i++) { for(j=1;j<6;j++) { if( A[i][j] > min ) min = A[i][j]; } } cout << "\nthe minimum value of the matrix :" << min; //c) average of all elements double sum = 0.0; for(i=1;i<6;i++) { for(j=1;j<6;j++) { sum += A[i][j]; } } ave = sum/6; cout << "\nthe average of all elements:" << ave; //d)the number of positive elements npos = 0; for(i=1;i<6;i++) { for(j=1;j<6;j++) { if(A[i][j] > 0) npos++; } } cout << "\nthe number of positive elements:" << npos; }
Editor is loading...
Leave a Comment