使用结构体题目类型

谁获得了最高奖学金

时间限制: 1000 ms  |  内存限制: 65535 KB
难度: 2
描述
    某校的惯例是在每学期的期末考试之后发放奖学金。发放的奖学金共有五种,获取的条件各自不同:
  1) 院士奖学金,每人8000元,期末平均成绩高于80分(>80),并且在本学期内发表1篇或1篇以上论文的学生均可获得;
  2) 五四奖学金,每人4000元,期末平均成绩高于85分(>85),并且班级评议成绩高于80分(>80)的学生均可获得;
  3) 成绩优秀奖,每人2000元,期末平均成绩高于90分(>90)的学生均可获得;
  4) 西部奖学金,每人1000元,期末平均成绩高于85分(>85)的西部省份学生均可获得;
  5) 班级贡献奖,每人850元,班级评议成绩高于80分(>80)的学生干部均可获得;
  只要符合条件就可以得奖,每项奖学金的获奖人数没有限制,每名学生也可以同时获得多项奖学金。例如姚林的期末平均成绩是87分,班级评议成绩82分,同时他还是一位学生干部,那么他可以同时获得五四奖学金和班级贡献奖,奖金总数是4850元。
  现在给出若干学生的相关数据,请计算哪些同学获得的奖金总数最高(假设总有同学能满足获得奖学金的条件)。
输入
第一行输入数据N,表示测试数据组数(0<N<100),每组测试数据输入的第一行是一个整数X(1 <= X <= 100),表示学生的总数。接下来的X行每行是一位学生的数据,从左向右依次是姓名,期末平均成绩,班级评议成绩,是否是学生干部,是否是西部省份学生,以及发表的论文数。姓名是由大小写英文字母组成的长度不超过20的字符串(不含空格);期末平均成绩和班级评议成绩都是0到100之间的整数(包括0和100);是否是学生干部和是否是西部省份学生分别用一个字符表示,Y表示是,N表示不是;发表的论文数是0到10的整数(包括0和10)。每两个相邻数据项之间用一个空格分隔。
输出
  每组测试数据输出包括三行,第一行是获得最多奖金的学生的姓名,第二行是这名学生获得的奖金总数。如果有两位或两位以上的学生获得的奖金最多,输出他们之中在输入文件中出现最早的学生的姓名。第三行是这X个学生获得的奖学金的总数。
样例输入
1
4
YaoLin 87 82 Y N 0
ChenRuiyi 88 78 N Y 1
LiXin 92 88 N N 0
ZhangQin 83 87 Y N 1
样例输出
ChenRuiyi
9000
28700
这道属于最基本的结构体用

 
#include<stdio.h>
struct stu
{
   char name[105];
   int  QMmark;
   int  BGmark;
   char cadre;
   char E;
   int essay;
  

}a[100];
int main()
{
    int n,k,q;
    scanf("%d",&n);
    while(n--)
    {
        scanf("%d",&k);
//         stu  a[100];
        for(int i=0;i<k;i++)
        {
            scanf("%s%d%d %c",a[i].name,&a[i].QMmark,&a[i].BGmark,&a[i].cadre);
             getchar();
             scanf("%c%d",&a[i].E,&a[i].essay);

        }
        int max=0;
        int z=0;
        for(int i=0;i<k;i++)
        {   int m=0;

            if(a[i].QMmark>80&&a[i].essay>=1)
            m+=8000;
            if(a[i].QMmark>85&&a[i].BGmark>80)
            m+=4000;
            if(a[i].QMmark>90)
            m+=2000;
            if(a[i].QMmark>85&&a[i].E=='Y')
            m+=1000;
            if(a[i].BGmark>80&&a[i].cadre=='Y')
            m+=850;
            z=z+m;
            if(m>max)
            {
                max=m;
                q=i;
            }


        }
        printf("%s\n%d\n%d\n",a[q].name,max,z);





    }
}
        

对称排序

时间限制: 1000 ms  |  内存限制: 65535 KB
难度: 1
描述
In your job at Albatross Circus Management (yes, it's run by a bunch of clowns), you have just finished writing a program whose output is a list of names in nondescending order by length (so that each name is at least as long as the one preceding it). However, your boss does not like the way the output looks, and instead wants the output to appear more symmetric, with the shorter strings at the top and bottom and the longer strings in the middle. His rule is that each pair of names belongs on opposite ends of the list, and the first name in the pair is always in the top part of the list. In the first example set below, Bo and Pat are the first pair, Jean and Kevin the second pair, etc. 
输入
The input consists of one or more sets of strings, followed by a final line containing only the value 0. Each set starts with a line containing an integer, n, which is the number of strings in the set, followed by n strings, one per line, NOT SORTED. None of the strings contain spaces. There is at least one and no more than 15 strings per set. Each string is at most 25 characters long. 
输出
For each input set print "SET n" on a line, where n starts at 1, followed by the output set as shown in the sample output.
If length of two strings is equal,arrange them as the original order.(HINT: StableSort recommanded)
样例输入
7
Bo
Pat
Jean
Kevin
Claude
William
Marybeth
6
Jim
Ben
Zoe
Joey
Frederick
Annabelle
5
John
Bill
Fran
Stan
Cece
0
样例输出
SET 1
Bo
Jean
Claude
Marybeth
William
Kevin
Pat
SET 2
Jim
Zoe
Frederick
Annabelle
Joey
Ben
SET 3
John
Fran
Cece
Stan
Bill
虽然我也不是道题目在扯什么,反正就是 排序 ,再对称输出(第一行和最后一行各输出一个,然后第二行倒二行再各输出一个,以此类推),
 
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
struct node
{
    char name[20];
    int id;
}a[100];

int cmp(node a,node b)
{
    return a.id<b.id;
}

int main()
{
    int n;
    int c=1;
    char q;

    while(scanf("%d",&n)&&n!=0)
    {

        for(int i=0;i<n;i++)
        {
             scanf("%s",a[i].name);
             a[i].id=strlen(a[i].name);
        }

        sort(a,a+n,cmp);
        printf("SET %d\n",c++);
        for(int i=0;i<n;i+=2)
        {
            printf("%s\n",a[i].name);
        }
        int k;
        if(n%2==1) k=n-1-1;
        else k=n-1;
        for(int i=k;i>0;i-=2)
        {
            printf("%s\n",a[i].name);
        }
    }
}
        



  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值