-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlab11b3.c
More file actions
58 lines (50 loc) · 1.34 KB
/
lab11b3.c
File metadata and controls
58 lines (50 loc) · 1.34 KB
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
56
57
58
#include<stdio.h>
#include<string.h>
struct Diemhk1
{
int stt;
char monhoc[80];
float diem;
float diemtbmax;
};
typedef struct Diemhk1 hk1;
int main()
{
int n;
printf("Nhap diem hk1, so luong mon hoc: ");
scanf("%d",&n);
hk1 a[n];
for(int i =0;i<n;i++)
{
getchar();
printf("nhap stt: "); scanf("%d",&a[i].stt);
getchar();
printf("Nhap ten mon hoc: ");
gets(a[i].monhoc);
printf("Diem mon hoc: ");
scanf("%f",&a[i].diem);
getchar();
}
float diemtbmax =a[0].diem;
for(int i =0; i<n;i++)
{
if(a[i].diem > a[0].diem)
{
diemtbmax=a[i].diem;
}else{
diemtbmax;
}
}
printf("Danh ach vua nhap: \n");
printf("+-------+------------------------------------------+------+\n");
printf("| %-5s | %-40s | %-4s |\n","stt","mon hoc","diem");
printf("+-------+------------------------------------------+------+\n");
for(int i=0; i<n;i++)
{
printf("| %-5d | %-40s | %.2f |\n",a[i].stt,a[i].monhoc,a[i].diem);
}
printf("+---------------------------------------------------------+\n");
printf("| %.2f |\n",diemtbmax);
printf("+---------------------------------------------------------+\n");
return 0;
}