第2章练习题--7--谁拿了最多奖学金--2715

#include <stdio.h>
#include <stdlib.h>
#include<string.h>
struct Student
{
       char sName[20];
       int avgScore;
       int evaScore;
       char leader;
       char west;
       int paperNum;
       int totalScholar;
};
int isYuanShi(struct Student s)
{
    if(s.avgScore>80&&s.paperNum>=1)
      return 8000;
    else return 0;
}
int isWuSi(struct Student s)
{
    if(s.avgScore>85&&s.evaScore>80)
      return 4000;
    else return 0;
}
int isYouXiu(struct Student s)
{
    if(s.avgScore>90)
      return 2000;
    else return 0;
}
int isWest(struct Student s)
{
    if(s.avgScore>85&&s.west=='Y')
      return 1000;
    else return 0;
}
int isGongXian(struct Student s)
{
    if(s.evaScore>80&&s.leader=='Y')
      return 850;
    else return 0;
}

int main(int argc, char *argv[])
{
    struct Student s[101];
    int n,maxS,maxMoney,total;
    int i;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
      scanf("%s %d %d %c %c %d",&s[i].sName,&s[i].avgScore,&s[i].evaScore,&s[i].leader,&s[i].west,&s[i].paperNum);
      s[i].totalScholar=isYuanShi(s[i])+isWuSi(s[i])+isYouXiu(s[i])+isWest(s[i])+isGongXian(s[i]);
    }
    maxS=maxMoney=total=0;
    for(i=0;i<n;i++)
    {
      total += s[i].totalScholar;
      if(s[i].totalScholar>maxMoney)
      {
        maxMoney = s[i].totalScholar;
        maxS = i;
      }
    }
    printf("%s\n",s[maxS].sName);
    printf("%d\n",s[maxS].totalScholar);
    printf("%d\n",total);
  
  system("PAUSE");	
  return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值