This article is a mirror article of machine translation, please click here to jump to the original article.

View: 21836|Reply: 5

[C] Structure Enter the student number, name, and grade of the two students. Output student number, name, and grades of the highest graded student.

[Copy link]
Posted on 12/17/2015 3:59:45 PM | | |
//输入两个学生的学号,姓名,成绩。输出成绩最高的学生的学号,姓名和成绩。

  1. #include "stdafx.h"
  2. #include "stdio.h"
  3. int main()
  4. {struct Student  //声明结构体类型
  5. {int num;
  6. char name[20];
  7. float score;
  8. }student1,student2;//定义两个结构体变量student1,student2
  9. scanf("%d%s%f",&student1.num,student1.name,&student1.score);
  10. scanf("%d%s%f",&student2.num,student2.name,&student2.score);
  11. printf("the higher score is:\n");
  12. if(student1.score>student2.score)
  13. printf("%d %s %6.2f\n",student1.num,student1.name,student1.score);
  14. else if(student1.score<student2.score)
  15. printf("%d %s %6.2f\n",student2.num,student2.name,student2.score);

  16. else
  17. {printf("%d %s %6.2f\n",student1.num,student1.name,student1.score);
  18. printf("%d %s %6.2f\n",student2.num,student2.name,student2.score);}
  19. return 0;
  20. }
Copy code







Previous:VS2013, quickly reach a certain line of code, what is the shortcut?
Next:Struct array has 3 candidates, and each voter can only vote for one person. Write a statistical vote and output everyone's votes
Posted on 12/17/2015 4:15:57 PM |
What is a struct I see this thing a lot
 Landlord| Posted on 12/17/2015 4:30:01 PM |
Small slag Posted on 2015-12-17 16:15
What is a struct I see this thing a lot

It's similar to enums in C#, but C always has something of its own. It is impossible to have the same as other languages.
Posted on 12/17/2015 5:18:50 PM |
xiaoweier posted on 2015-12-17 16:30
It's similar to enums in C#, but C always has something of its own. It is impossible to have the same as other languages.

Oh, now understand what structs mean
 Landlord| Posted on 12/17/2015 5:53:37 PM |
Xiao Zhazha Posted on 2015-12-17 17:18
Oh, now understand what structs mean

It seems that a top student is a top student, and you can tell at a glance. Studying well is really not blown.
Posted on 12/17/2015 6:19:27 PM |
xiaoweier posted on 2015-12-17 17:53
It seems that a top student is a top student, and you can tell at a glance. Studying well is really not blown.

How can a top student be a joke
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com