Course
Time limit: Ms | Memory Limit: 65535 KB
"Problem description"
there is such a policy in sichuan university that of the song body" if you are not satisfied with the score of your course , you can study this course again to get a better score . if you do this and get a higher score (than the Highest score he got before), it can cover the original one. And we can say this time you update the score of This course successfully.
Here is one schoolmate's all the courses he had studied and scores he got (sorted by chronological order). So could your tell me what many time he successfully update his scores of courses?
Input
The first of input is a integer T which stands for the number of test cases. For each test case the first line was an integer n (1 <= N <=) which stands for the number of courses he had stud IED. Then following N lines, each line contains a string (only contains letters and the length are no more than 30,which STA NDS for the course name) and an integer (0<=integer<=100, which stands for the score of the course), separated by a s Pace.
Remember:the best by getting the best score in one time.
Study One course many times is not a recommended choice!
Output
The For each test case output the number of times he update successfully.
"Sample Input"
2
6
Cprogramming 70
Datastructrue 80
Cprogramming 80
Cprogramming 60
Cprogramming 90
Datastructrue 70
2
Compilertheory 95
Network 90
"Sample Output"
2
0
A very brain-free problem, in short, is to calculate the score breakthrough times. I spent more than half an hour, really hit the face ah ....
General structure of the wording:
#include <cstdio> #include <cstring>struct course{char name[35];int score;} P[105];int Main () {int I,j,m,n,count,num,sum;char str[35];scanf ("%d", &n), while (n--) {count=sum=0;scanf ("%d", &M), for (i=0;i<m;i++) {int sign=1;scanf ("%s%d", Str,&num), and for (j=0;j<count;j++) if (!strcmp (P[j].name, STR) {&&num>p[j].score) {p[j].score=num;sign=0;sum++;break;} if (sign) {strcpy (P[J].NAME,STR);p [j].score=num;count++;}} printf ("%d\n", sum);} return 0;}
Take this as a mirror, no precedent.
Course (Simple string handling problem)