-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdz11(8).c
55 lines (44 loc) · 998 Bytes
/
dz11(8).c
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
54
55
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
struct avto
{
char nomer[20];
char marka[20];
float vartist;
float vik;
};
int main(void){
int n=3;
// struct avto a1={"cv1710aa","ford",1700,17};
// printf("%s %s %g %g ", a1.nomer ,a1.marka,a1.vartist,a1.vik);
struct avto baza[n];
for (int i = 0; i<n; i++){
printf("nomer %d mashina : ", i + 1);
scanf("%s",baza[i].nomer);
printf("marka %d mashina : ", i + 1);
scanf("%s",baza[i].marka);
printf("cost %d mashina : ", i + 1);
scanf("%f", &baza[i].vartist);
printf("years %d mashina : ", i + 1);
scanf("%f", &baza[i].vik);
getchar();
}
for (int i = 0; i<n; i++)
{
printf("\n %d. %s ", i + 1, baza[i].nomer);
printf("%s %g %g", baza[i].marka, baza[i].vartist,baza[i].vik);
}
getchar();
float p=0;
float sum=0;
for (int i = 0; i<n; i++)
{
if(baza[i].vik>5){
p++;
sum+=baza[i].vartist;
}
}
printf("%g" , sum/p);
return 0;
}