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[];
int flag1;
int cro,wro,sum;
}a[]; int main()
{
int t;
scanf("%d",&t);
int ans1 = ;
while(t--)
{
int n;
scanf("%d",&n);
getchar();
int max1 = ;
for(int i = ;i < n;i++)
{
gets(a[i].m);
int len = strlen(a[i].m);
int flag = -;
int j = ;
a[i].cro = ;
a[i].wro = ;
a[i].sum = ;
for( ;j < len;j++)
{
if(a[i].m[j] == ' ')
break;
}
j++;
for( ;j < len;j++)
{
if(a[i].m[j] == 'y')
{
flag = ;
a[i].cro++;
if(a[i].m[j+] == 'e')
j = j+;
else
j++;
break;
}
else if(a[i].m[j] == 'n')
{
flag = ;
a[i].wro++;
if(a[i].m[j+] == 'o')
j = j+;
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+] == 'e')
j = j+;
else
j++;
}
else if(a[i].m[j] == 'n')
{
a[i].wro++;
if(a[i].m[j+] == 'o')
j = j+;
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 = ,ans3 = ,ans4 = ,ans5 = ;
for(int i = ;i < n;i++)
{
if(a[i].wro == && a[i].cro > )
ans2++;
if(a[i].flag1 == && a[i].cro > )
ans3++;
if(a[i].wro >= )
ans4++;
if(a[i].sum == )
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 ;
}

HDU 4178 模拟的更多相关文章

  1. hdu 4891 模拟水题

    http://acm.hdu.edu.cn/showproblem.php?pid=4891 给出一个文本,问说有多少种理解方式. 1. $$中间的,(s1+1) * (s2+1) * ...*(sn ...

  2. hdu 5012 模拟+bfs

    http://acm.hdu.edu.cn/showproblem.php?pid=5012 模拟出骰子四种反转方式,bfs,最多不会走超过6步 #include <cstdio> #in ...

  3. hdu 4669 模拟

    思路: 主要就是模拟这些操作,用链表果断超时.改用堆栈模拟就过了 #include<map> #include<set> #include<stack> #incl ...

  4. 2013杭州网络赛C题HDU 4640(模拟)

    The Donkey of Gui Zhou Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/O ...

  5. HDU/5499/模拟

    题目链接 模拟题,直接看代码. £:分数的计算方法,要用double; #include <set> #include <map> #include <cmath> ...

  6. hdu 5003 模拟水题

    http://acm.hdu.edu.cn/showproblem.php?pid=5003 记得排序后输出 #include <cstdio> #include <cstring& ...

  7. hdu 5033 模拟+单调优化

    http://acm.hdu.edu.cn/showproblem.php?pid=5033 平面上有n个建筑,每个建筑由(xi,hi)表示,m组询问在某一个点能看到天空的视角范围大小. 维护一个凸包 ...

  8. HDU 2860 (模拟+并查集)

    Regroup Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Sub ...

  9. hdu 5083(模拟)

    Instruction Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

随机推荐

  1. pat乙级1060

    将数组排序后从大到小遍历,设置一个递增的变量t,当v[i] > t的时候,说明有t个数大于t,最后一个满足v[i] > t的t即为所求结果. #include <iostream&g ...

  2. echarts 相关属性介绍

    title: {//图表标题     x: 'left', //组件离容器左侧的距离,left的值可以是像20,这样的具体像素值, 可以是像 '20%' 这样相对于容器高宽的百分比,也可以是 'lef ...

  3. oc语言特性

    It’s a superset of the C programming language and provides object-oriented capabilities and a dynami ...

  4. 简单ssh

    #!/usr/bin/env python #-*- coding:utf-8 -*- # datetime:2019/5/22 14:20 # software: PyCharm #服务端 impo ...

  5. C# 运用StreamReader类和StreamWriter类实现文件的读写操作

    对文件的读写操作应该是最重要的文件操作,System.IO命名空间为我们提供了诸多文件读写操作类,在这里我要向大家介绍最常用也是最基本的StreamReader类和StreamWriter类.从这两个 ...

  6. 一次线上CPU高的问题排查实践

    一次线上CPU高的问题排查实践 前言 近期某一天上班一开电脑,就收到了运维警报,有两台服务CPU负载很高,同时收到一线同事反馈 系统访问速度非常慢,几乎无响应. 一个美好的早晨,最怕什么就来什么.只好 ...

  7. 人品计算器 JFrame 窗体软件版 JPanel JTextField JTextArea JButtton JLabel setContentPane Swing包(用户界面工具包)

    import java.awt.BorderLayout; import java.awt.Color; import java.awt.GridLayout; import java.awt.eve ...

  8. 防止内存泄露 Linux下用Valgrind做检查

    用C/C++开发其中最令人头疼的一个问题就是内存管理,有时候为了查找一个内存泄漏或者一个内存访问越界,需要要花上好几天时间,如果有一款工具能够帮助我们做这件事情就好了,valgrind正好就是这样的一 ...

  9. 从指定的view中截图 返回UIImage

    -(UIImage *)getImageFromView:(UIView *)view{ UIGraphicsBeginImageContext(view.bounds.size); [view.la ...

  10. SummerVocation_Learning--java的多线程实现

    java的线程是通过java.lang.Thread类来实现的. 可以通过创建Thread的实例来创建新的线程. 每个线程都是通过某个特定Thread对象所对应的方法run()来完成操作,方法run( ...