/*编写一个程序,要求从键盘上输入某个学生的四科成绩,求出该学生的最高分和最低分 */ #include <stdio.h> int main(){ //定义四个变量 int yuWen, shuXue,shengWu,huaXue,score; //提示用户输入四课成绩 printf("请输入学的四科成绩,并用逗号隔开:\n"); //接受用户输入的成绩 scanf("%d,%d,%d,%d",&yuWen,&shuXue,&shengWu,&huaXue); //判断最高分 score = yuWen>shengWu?yuWen:shengWu; score = score>shuXue?score:shuXue; score = score>huaXue?score:huaXue; printf("最高分是=%d\n",score); //判断最低分 score = yuWen<shengWu?yuWen:shengWu; score = score<shuXue?score:shuXue; score = score<huaXue?score:huaXue; printf("最低分是=%d\n",score); return 0; } 这个是我用老师教的屌丝写法,求大神指导!!
|