Course(简单的字符串处理问题)
2014-11-29 21:34
316 查看
Course
时间限制:1000 ms | 内存限制:65535 KB
【问题描述】
There is such a policy in Sichuan University that 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 has studied and scores he got (sorted by chronological order). So could you tell me how many time he successfully update his scores of courses?
【输入】
The first of input is an integer T which stands for the number of test cases. For each test case the first line is an integer N (1 <= N <= 100) which stands for the number of courses he has studied. Then following N lines, each line contains a string (only contains letters and the length is no more than 30,which stands for the course name) and an integer (0<=integer<=100, which stands for the score of the course),separated by a space.
Remember: the best way is getting the best score in one time.
Study one course many times is not a recommended choice!
【输出】
For each test case output the number of times he update successfully.
【样例输入】
2
6
CProgramming 70
DataStructrue 80
CProgramming 80
CProgramming 60
CProgramming 90
DataStructrue 70
2
CompilerTheory 95
Network 90
【样例输出】
2
0
一道很无脑的题,简单来说就是算出成绩突破次数。我还花了半个多小时,真是打脸啊。。。。
普通结构体写法:
以此为鉴,下不为例。
时间限制:1000 ms | 内存限制:65535 KB
【问题描述】
There is such a policy in Sichuan University that 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 has studied and scores he got (sorted by chronological order). So could you tell me how many time he successfully update his scores of courses?
【输入】
The first of input is an integer T which stands for the number of test cases. For each test case the first line is an integer N (1 <= N <= 100) which stands for the number of courses he has studied. Then following N lines, each line contains a string (only contains letters and the length is no more than 30,which stands for the course name) and an integer (0<=integer<=100, which stands for the score of the course),separated by a space.
Remember: the best way is getting the best score in one time.
Study one course many times is not a recommended choice!
【输出】
For each test case output the number of times he update successfully.
【样例输入】
2
6
CProgramming 70
DataStructrue 80
CProgramming 80
CProgramming 60
CProgramming 90
DataStructrue 70
2
CompilerTheory 95
Network 90
【样例输出】
2
0
一道很无脑的题,简单来说就是算出成绩突破次数。我还花了半个多小时,真是打脸啊。。。。
普通结构体写法:
#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); 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; }
以此为鉴,下不为例。
相关文章推荐
- Course(简单的字符串处理问题)
- wertyu(简单的字符串处理问题)
- 用正则表达式处理含中文字符串的问题
- 字符串处理路径问题
- 有关字符串处理问题的原则
- 字段里字符串的处理问题
- 字段里字符串的处理问题
- 字段里字符串的处理问题
- 俺写的一个简单的字符串处理函数(可能会有用)
- 字段里字符串的处理问题
- 字段里字符串的处理问题
- java字符串类型的日期处理问题
- 字符串处理:中英文混排固定长度截取问题
- javasript处理字符串问题集
- 字段里字符串的处理问题
- 切记在JAVA中处理字符串的时候的问题 == equals
- 急急急!!!有关asp字符串处理的问题,请大虾指点???
- CString的几个字符串处理函数的index问题
- 字段里字符串的处理问题
- 字段里字符串的处理问题