0% found this document useful (0 votes)
9 views4 pages

Tema - Informatică

The document contains multiple C++ programs that perform various operations on 2D arrays. These operations include calculating averages of positive numbers, filling arrays in a specific pattern, finding the minimum value, transposing arrays, and modifying values based on a condition. Each program reads input dimensions and values, processes the data, and outputs the results.

Uploaded by

dorobatmircea
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views4 pages

Tema - Informatică

The document contains multiple C++ programs that perform various operations on 2D arrays. These operations include calculating averages of positive numbers, filling arrays in a specific pattern, finding the minimum value, transposing arrays, and modifying values based on a condition. Each program reads input dimensions and values, processes the data, and outputs the results.

Uploaded by

dorobatmircea
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Tema

50.
#include <iostream>
using namespace std;

int main() {
int a[21][21], i, j, n, m, s, v, d, nr;
cin >> n >> m;
s = 0;
nr = 0;

for (i = 1; i <= n; i++)


for (j = 1; j <= m; j++)
cin >> a[i][j];

for (i = 1; i <= n; i++)


for (j = 1; j <= m; j++)
if (i < j)
if (a[i][j] > 0)
nr++;

v = nr;
cout << (float) s / v;

return 0;
}

51.
#include <iostream>
using namespace std;

int main() {
int a[51][51], n, i, j, b, c, e, f;
cin >> n;

c = 1;
b = 1;

for (i = 1; i <= n; i++)


if (i % 2 == 1)
for (j = 1; j <= n; j++) {
e = a[i][j] = c;
c++;
b = c;
}
else
for (j = n; j >= 1; j--) {
e = a[i][j] = c;
c++;
b = c;
}

for (i = 1; i <= n; i++) {


for (j = 1; j <= n; j++)
cout << a[i][j] << " ";
cout << endl;
}

return 0;
}

52.
#include <iostream>
using namespace std;

int main() {
int o[100][100], m, n, i, j, s1, s2, nr1, nr2;
cin >> n >> m;

s1 = 0;
s2 = 0;
nr1 = 0;
nr2 = 0;

for (i = 1; i <= n; i++)


for (j = 1; j <= m; j++)
cin >> o[i][j];

for (i = 1; i <= n; i++)


for (j = 1; j <= m; j++)
if (i < j) {
if (o[i][j] > 0) {
s1 = s1 + o[i][j];
nr1++;
}
} else if (i > j) {
if (o[i][j] > 0) {
s2 = s2 + o[i][j];
nr2++;
}
}

cout << float(s1) / nr1 << " = " << float(s2) / nr2;

return 0;
}

53.
#include <iostream>
using namespace std;

int main() {
int c[100][100], i, j, m, n, x, y;
cin >> m >> n;

for (i = 1; i <= m; i++)


for (j = 1; j <= n; j++)
cin >> c[i][j];

x = c[1][1];
y = 1;

for (i = 1; i <= m; i++)


for (j = 1; j <= n; j++)
if (c[i][j] < x) {
x = c[i][j];
y = j;
}

for (i = 1; i <= m; i++) {


for (j = 1; j <= n; j++)
cout << c[i][j] << " ";
cout << endl;
}

return 0;
}

54.
#include <iostream>
using namespace std;
int main() {
int c[100][100], i, j, m, n;
cin >> m >> n;

for (i = 1; i <= m; i++)


for (j = 1; j <= n; j++)
cin >> c[i][j];

for (j = 1; j <= n; j++)


for (i = 1; i <= m; i++)
cout << c[i][j] << " ";

cout << endl;

return 0;
}

55.
#include <iostream>
using namespace std;

int main() {
int a[100][100], i, j, m, n, k;
cin >> m >> n >> k;

for (i = 1; i <= m; i++)


for (j = 1; j <= n; j++)
cin >> a[i][j];

for (i = 1; i <= m; i++)


for (j = 1; j <= n; j++)
if (a[i][j] == k)
k = k * 2;

for (i = 1; i <= m; i++) {


for (j = 1; j <= n; j++)
cout << a[i][j] << " ";
cout << endl;
}

return 0;
}

You might also like