您的位置:首页 > 其它

joj1059

2011-08-29 09:11 211 查看





1059: Mary

ResultTIME LimitMEMORY LimitRun TimesAC TimesJUDGE

3s8192K22891035Standard
Mary is a mathematics teacher of Jilin University. This term she teaches mathematics for students of classes of grade 2002. Now the final examination is over and every student has his mathematics score. Mary would like to know what the highest score of each
class is and what the highest score of all classes is. But there are too many students take the examination and Mary is too lazy indeed. So she asks you, an expert on programming, to help her solve the problem.

Input Specification

The input consists of several blocks one by one. Each block represents a class, consisting of several lines. Each line of a block consists of a positive integer s, where s<=100, designating a certain student's score of the class. A 0 marks the end of the
block. A -1 marks the end of the input. For example,

60 <-- a student's score of class 1

99 <-- another student's score of class 1

85 <-- the last student's score of class 1

0 <-- end of class 1

59 <-- a student's score of class 2

94 <-- another student's score of class 2

0 <-- end of class 2

-1 <-- end of input

Output Specification

You should output the maximum score of each class in the order of classes given in the input. And then, you should also output the maximum score of all classes and the class where the maximum score appears for the first time. For the example above, you should
make the output like this:

99 <-- maximum score of class 1

94 <-- maximum score of class 2

99 At Class 1 <-- maximum score of class 1 and class 2

Sample Input

60
99
85
0
59
94
0
-1

Sample Output

99
94
99 At Class 1


Problem Source: 1st JOJ Cup Online VContest Warmup Problem

This problem is used for contest:
75

Submit /
Problem List / Status /
Discuss

Problem Set with Online Judge System Version 3.12

Jilin University

Developed by skywind,
SIYEE

#include<cstdio>

int main()

{

//freopen("in.txt","r",stdin);

//freopen("out.txt","w",stdout);

int allmax=-1;

int singlemax=-1;

int score;

int singleclass=1 ;

int maxclass;

while(1)

{

scanf("%d",&score);

if(score>singlemax)

{

singlemax=score;

if(score>allmax)

{

allmax=score;

maxclass=singleclass;

}

}

if(score==0)

{

++singleclass;

printf("%d\n",singlemax);

singlemax=-1;

}

if(score==-1)

{

printf("%d At Class %d\n",allmax,maxclass);

break;

}

}

return 0;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: