C - Roll-call in Woop Woop High

來源:互聯網
上載者:User

標籤:des   style   blog   http   color   os   io   for   

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 ( 1K100) indicating the number of classes. Each class starts with an integer N ( 1N50) 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

25Doc n ysneezy n n no yesprincecharming no n no no ngoofy yesgrumpy n y5evilemperor n yprincessliar2d2 no no yobeyonecanopy n no ydarthvedar y

Sample Output

Roll-call: 1Present: 1 out of 5Needs to study at home: 3 out of 5Needs remedial work after school: 1 out of 5Absent: 0 out of 5Roll-call: 2Present: 1 out of 5Needs to study at home: 3 out of 5Needs remedial work after school: 0 out of 5Absent: 1 out of 5
/*題意:每個人做五道題  答對(yes/y) 答錯(n,/n)      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   一道題也沒有回答 各種寫法都有   不過就還是最熟悉的寫法來的好 讀空格 gets()  也可以是讀整行的getline--cin.getline(str,100); getcahr()  一直不能掌握其要領  不過輸入字串的時候就要注意一下 */ #include <iostream> #include <string.h> #include <stdio.h> using namespace std; int s1,s2,s3,s4; bool OK; int cnt; int main() {     int t,n;     int num;     char str[150];     scanf("%d",&t);     for(num=1;num<=t;num++)     {         s1=0;s2=0;s3=0;s4=0;         scanf("%d",&n);         int s=n;         getchar();         while(n--)         {              OK=false;              cnt=0;              gets(str);              int len=strlen(str);              for(int i=0;i<len;i++)              {                  if(str[i-1]==‘ ‘&&str[i]==‘y‘)                  {                      if(cnt==0)  ///yi ci jiu dui                      s1++;                      else  ///hui da hao ji ci dui                      s2++;                      cnt++;   ///lai guo                      OK=true;                  }                  else if(str[i-1]==‘ ‘&&str[i]==‘n‘)                  {                      cnt++;  ///lai guo                  }              }              if(cnt==0)              s4++;   ///mei lai              else if(!OK)              s3++;  ///mei dui guo         }        // cout<<s1<<‘ ‘<<s2<<‘ ‘<<s3<<‘ ‘<<s4<<endl;        printf("Roll-call: %d\n",num);        printf("Present: %d out of %d\n",s1,s);        printf("Needs to study at home: %d out of %d\n",s2,s);        printf("Needs remedial work after school: %d out of %d\n",s3,s);        printf("Absent: %d out of %d\n",s4,s);     } }

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.