11. Array Declare the actual size MXN (m, n are respectively the number of rows and columns are entered from the keyboard). Enter values into the array and display the screen in matrix form. total value of non-negative elements in the array.
# include
using namespace std;
void main ()
{
int a [100] [100], i, j, m, n, tong;
cout << "Enter number of rows m =";
cin >> m;
cout << "Enter number of columns n =";
cin >> n;
cout << "Enter the value to bring" << endl;
for (i = 0; i <m; i + +)
for (j = 0; j <n; j + +)
{
cout << "a [" << i << "] [" << j << "] =";
cin >> a [i] [j];
}
cout << "show brings entered as matrix" << endl;
for (i = 0; i <m; i + +)
{
for (j = 0; j <n; j + +)
cout << a [i] [j] << "\ t";
cout << endl;
}
tong = 0;
for (i = 0; i <m; i + +)
for (j = 0; j <n; j + +)
if (a [i] [j]> 0)
= tong tong + a [i] [j];
cout << "zero tong am in the network is:" << Total << endl;
}
# include
using namespace std;
void main ()
{
int a [100] [100], i, j, m, n, tong;
cout << "Enter number of rows m =";
cin >> m;
cout << "Enter number of columns n =";
cin >> n;
cout << "Enter the value to bring" << endl;
for (i = 0; i <m; i + +)
for (j = 0; j <n; j + +)
{
cout << "a [" << i << "] [" << j << "] =";
cin >> a [i] [j];
}
cout << "show brings entered as matrix" << endl;
for (i = 0; i <m; i + +)
{
for (j = 0; j <n; j + +)
cout << a [i] [j] << "\ t";
cout << endl;
}
tong = 0;
for (i = 0; i <m; i + +)
for (j = 0; j <n; j + +)
if (a [i] [j]> 0)
= tong tong + a [i] [j];
cout << "zero tong am in the network is:" << Total << endl;
}

No comments:
Post a Comment
Thanks