- /*
- 编写一个程序,要求从键盘上输入某个学生的四科成绩,求出该学生的最高分和最低分
- */
- #include <stdio.h>
- int main () {
-
- int score1,score2,score3,score4;
-
- printf ("请输入四科分数,用逗号进行分隔:\n");
-
- scanf ("%d,%d,%d,%d",&score1,&score2,&score3,&score4);
-
- if (score1 > score2) {
-
- if (score3 > score4) {
-
- if (score1 > score3 && score2 >score4){
-
- printf ("最大值为:%d\n",score1);
-
- printf ("最小值为:%d\n",score4);
-
- } else {
-
- printf ("最大值为:%d\n",score3);
-
- printf ("最小值为:%d\n",score2);
-
- }
-
- } else {
-
- if (score1 > score4 && score2 >score3) {
-
- printf ("最大值为:%d\n",score1);
-
- printf ("最小值为:%d\n",score3);
-
- } else {
-
- printf ("最大值为:%d\n",score4);
-
- printf ("最小值为:%d\n",score2);
-
- }
-
- }
-
- } else {
-
- if (score3 > score4) {
-
- if (score2 > score3 && score1 > score4) {
-
- printf ("最大值为:%d\n",score2);
-
- printf ("最小值为:%d\n",score4);
-
- } else {
-
- printf ("最大值为:%d\n",score3);
-
- printf ("最小值为:%d\n",score1);
-
- }
-
- } else {
-
- if (score2 > score4 && score1 > score3) {
-
- printf ("最大值为:%d\n",score2);
-
- printf ("最小值为:%d\n",score3);
-
- } else {
-
- printf ("最大值为:%d\n",score4);
-
- printf ("最小值为:%d\n",score1);
-
- }
-
- }
-
- }
-
- return 0;
-
- }
复制代码 |
|