forked from hanascodes/Programiranje-1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGrupa A - Zadatak 02.cpp
53 lines (44 loc) · 972 Bytes
/
Grupa A - Zadatak 02.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <iostream>
using namespace std;
void unos(int matrica[][5])
{
for (int i = 0; i < 5; i++)
for (int j = 0; j < 5; j++)
while (cin >> matrica[i][j], matrica[i][j] < 1);
}
bool pozicija(int matrica[][5], int &indeks)
{
for (int i = 0; i < 5; i++)
{
for (int j = 0; j < 5; j++)
{
if (matrica[i][j] == 5)
{
indeks = i;
return true;
}
}
}
return false;
}
float prosjecna(int matrica[][5], int indeks)
{
float suma = 0;
for (int j = 0; j < 5; j++)
suma += matrica[indeks][j];
return suma / 5;
}
int main()
{
int matrica[5][5];
int indeks;
unos(matrica);
if (pozicija(matrica, indeks))
{
for (int i = 0; i < 5; i++)
cout << matrica[indeks][i] << " ";
cout << endl << "Prosjek: " << prosjecna(matrica, indeks) << endl;
}
system("pause>0");
return 0;
}