灿烂的神


私信TA

用户名:Frank3821

访问量:18007

签 名:

十月一日那天,祝你幸福!

等  级
排  名 535
经  验 4306
参赛次数 2
文章发表 42
年  龄 23
在职情况 学生
学  校 临沂大学
专  业 计算机科学与技术

  自我简介:

每走一次捷径,就会丧失一点人性!

解题思路:

1)要一次输入多个值,利用结构体比较方便

2)对于奖学金的评定,有一些关于分数的要求,比较时可以自己为他们排一下序,比如如果不大于80,就不用可虑大于90了,所以把大于90的奖学金放在大于80的语句里面,可以减少一些不必要的资源浪费

注意事项:

1)利用数组,别忘了加[i]

参考代码:

#include<stdio.h>

#include<string.h>

struct Stu{                      //定义结构体 

         char name[20];

         int ave_grade;

         int class_grade;

         char ganbu;

         char west;

         int article;

         int all;

};


int main(){

         struct Stu student[100];

         int N;

         scanf("%d",&N);                        

         int max=0,count=0;                //最多奖学金得主,全部的奖学金总和

         char maxname[20];                //最多奖学金得主名字

         for(int i=0;i<N;i++){

         //printf("name avegrade classgrade ganbu west article\n");            //输入提示

         scanf("%s %d %d %c %c %d",&student[i].name,&student[i].ave_grade,&student[i].class_grade,&student[i].ganbu,&student[i].west,&student[i].article);

         student[i].all=0;                    //赋初值

         if(student[i].ave_grade>80){                                            //平均分>80

                         if(student[i].article>=1){                                                  //院士奖学金发表文章>1

                                 student[i].all+=8000;

                         }

                         if(student[i].ave_grade>85){                            //平均分>85

                                         if(student[i].class_grade>80){                         //五四奖学金评议成绩>80

                                                  student[i].all+=4000;

                                         }

                                        if(student[i].west=='Y'){                                 //西部奖学金

                                                  student[i].all+=1000;

                                         }

                                         if(student[i].ave_grade>90){            //平均分>90

                                                  student[i].all+=2000;                            //成绩优秀奖

                                         }

                         }

         }

         if(student[i].class_grade>80 && student[i].ganbu=='Y'){        //干部奖学金

              student[i].all+=850;

         }

         if(i==0){

         max=student[i].all;

         }else{

         if(student[i].all>max){

         max=student[i].all;

         strcpy(maxname,student[i].name);

         }

         }

         count+=student[i].all;

         } 

         printf("%s\n%d\n%d\n",maxname,max,count);

         return 0;

}


 

0.0分

0 人评分

  评论区