HDU 4178 模拟

Roll-call in Woop Woop High

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 188    Accepted Submission(s): 133


Problem Description
The new principal of Woop Woop High is not satisfied with her pupils performance.She introduced a new roll-call process to get a daily measure of the pupils' learning, which proceeds as follows:At the beginning of the daily roll-call period each pupil is handed a question, which they must attempt to answer, before proceeding to their classes. A pupil stops after the question is answered correctly. Each pupil is allowed up to five attempts to answer the question correctly. Pupils who answer correctly on the first attempt are marked present. Pupils who answer correctly after more than one attempt are encouraged to work at home. Pupils who fail to develop a correct answer within five attempts are given remedial classes after school. Pupils who do not give any answer are marked as abscent. Your task is to write a program that reads the pupils' assessments and generates performance reports for the principal to proceed with appropriate actions.
 

 

Input
The input starts with an integer K (1 <= K <= 100) indicating the number of classes. Each class starts with an integer N (1 <= N <= 50) indicating the number of pupils in the class. Each of the following N lines starts with a pupil's name followed by up-to five assessments of his/her answers. An assessment of 'yes' or 'y' indicates a correct answer and an assessment of 'n' or 'no' indicates a wrong answer. A pupil's name consists of a single string with no white spaces.
 

 

Output
The attendance report for each class consists of five lines.
The first line consists of the sentence: "Roll-call: X", where X indicates the class number starting with the value of one.
The second line consists of the sentence: ''Present: Y1 out of N'', where Y1 is the number of pupils who did not submit a wrong answer.
The third line consists of the sentence: ''Needs to study at home: Y2 out of N'', where Y2 is the number of pupils who submitted a number of wrong answers before submitting the correct answer.
The fourth line consists of the sentence: ''Needs remedial work after school: Y3 out of N'', where Y3 indicates the number of pupils whose submitted five wrong answers.
The fifth line consists of the sentence: ''Absent: Y4 out of N'', where Y4 indicates the number of absent pupils.
 

 

Sample Input
2 5 Doc n y sneezy n n no yes princecharming no n no no n goofy yes grumpy n y 5 evilemperor n y princesslia r2d2 no no y obeyonecanopy n no y darthvedar y
 

 

Sample Output
Roll-call: 1 Present: 1 out of 5 Needs to study at home: 3 out of 5 Needs remedial work after school: 1 out of 5 Absent: 0 out of 5 Roll-call: 2 Present: 1 out of 5 Needs to study at home: 3 out of 5 Needs remedial work after school: 0 out of 5 Absent: 1 out of 5
 

 

Source
 

//输出的一共5行,第一行略微有点坑,第一行其实就是指的第几组数据,大概就是case的意思

Recommend
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;

struct pp{
    char m[100];
    int flag1;
    int cro,wro,sum;
}a[110];

int main()
{
    int t;
    scanf("%d",&t);
    int ans1 = 0;
    while(t--)
    {
        int n;
        scanf("%d",&n);
        getchar();
        int max1 = 0;
        for(int i = 0;i < n;i++)
        {
            gets(a[i].m);
            int len = strlen(a[i].m);
            int flag = -1;
            int j = 0;
            a[i].cro = 0;
            a[i].wro = 0;
            a[i].sum = 0;
            for( ;j < len;j++)
            {
                if(a[i].m[j] == ' ')
                    break;
            }
            j++;
            for( ;j < len;j++)
            {
                if(a[i].m[j] == 'y')
                {
                    flag = 1;
                    a[i].cro++;
                    if(a[i].m[j+1] == 'e')
                        j = j+3;
                    else
                        j++;
                    break;
                }
                else if(a[i].m[j] == 'n')
                {
                    flag = 0;
                    a[i].wro++;
                    if(a[i].m[j+1] == 'o')
                        j = j+2;
                    else
                        j++;
                    break;
                }
            }

            a[i].flag1 = flag;
            j++;
            for( ;j < len;j++)
            {
                if(a[i].m[j] == 'y')
                {
                    a[i].cro++;
                    if(a[i].m[j+1] == 'e')
                        j = j+3;
                    else
                        j++;
                }
                else if(a[i].m[j] == 'n')
                {
                    a[i].wro++;
                    if(a[i].m[j+1] == 'o')
                        j = j+2;
                    else
                        j++;
                }
            }
            a[i].sum = a[i].cro + a[i].wro;
            if(max1 < a[i].sum)
                max1 = a[i].sum;
        }


       // for(int i = 0;i < n;i++)
       //     printf("---%s %d %d %d\n",a[i].m,a[i].cro,a[i].wro,a[i].sum);


        int ans2 = 0,ans3 = 0,ans4 = 0,ans5 = 0;
        for(int i = 0;i < n;i++)
        {
            if(a[i].wro == 0 && a[i].cro > 0)
                ans2++;
            if(a[i].flag1 == 0 && a[i].cro > 0)
                ans3++;
            if(a[i].wro >= 5)
                ans4++;
            if(a[i].sum == 0)
                ans5++;
        }
        printf("Roll-call: %d\n",++ans1);
        printf("Present: %d out of %d\n",ans2,n);
        printf("Needs to study at home: %d out of %d\n",ans3,n);
        printf("Needs remedial work after school: %d out of %d\n",ans4,n);
        printf("Absent: %d out of %d\n",ans5,n);
    }
    return 0;
}

 

转载于:https://www.cnblogs.com/13224ACMer/p/4728997.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值