fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. typedef struct Mark
  4. {
  5. unsigned short int Toan ;
  6. unsigned short int Ly ;
  7. unsigned short int Hoa ;
  8. unsigned short int Anh ;
  9. }Mark;
  10. typedef struct SinhVien
  11. {
  12. unsigned short int age;
  13. char name[21];
  14. char msv[21];
  15. Mark diem;
  16. }SinhVien_Type;
  17.  
  18. void Nhap(SinhVien_Type* sv)
  19. {
  20. scanf("%hu",&(sv->age));
  21. fflush(stdin);
  22. fgets(sv->name,21,stdin);
  23. fgets(sv->msv,21,stdin);
  24. scanf("%hu",&(sv->diem.Toan));
  25. scanf("%hu",&(sv->diem.Ly));
  26. scanf("%hu",&(sv->diem.Hoa));
  27. scanf("%hu",&(sv->diem.Anh));
  28. }
  29. void Xuat(SinhVien_Type sv)
  30. {
  31. printf("\n======OUT PUT=======\n");
  32. printf("age = %hu\n",sv.age);
  33. printf("name = ");
  34. puts(sv.name);
  35. printf("msv = ");
  36. puts(sv.msv);
  37. printf("Diem: \n");
  38. printf("%hu\n",sv.diem.Toan);
  39. printf("%hu\n",sv.diem.Ly);
  40. printf("%hu\n",sv.diem.Hoa);
  41. printf("%hu\n",sv.diem.Anh);
  42.  
  43.  
  44.  
  45. }
  46. int main()
  47. {
  48. SinhVien_Type sv1,sv2,sv3;
  49. Nhap(&sv1);
  50. Xuat(sv1);
  51. }
Success #stdin #stdout 0s 4300KB
stdin
20
Nguyen Trong Dung
DTC16HD
10
9
8
7
stdout
======OUT PUT=======
age = 20
name = 

msv = Nguyen Trong Dung

Diem: 
21921
0
37360
4618