Course(简单的字符串处理问题)
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
一道很无脑的题,简单来说就是算出成绩突破次数。我还花了半个多小时,真是打脸啊。。。。
普通结构体写法:
#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(简单的字符串处理问题)的更多相关文章
- Redis的简单动态字符串实现
Redis 没有直接使用 C 语言传统的字符串表示(以空字符结尾的字符数组,以下简称 C 字符串), 而是自己构建了一种名为简单动态字符串(simple dynamic string,sds)的抽象类 ...
- SQL点滴3—一个简单的字符串分割函数
原文:SQL点滴3-一个简单的字符串分割函数 偶然在电脑里看到以前保存的这个函数,是将一个单独字符串切分成一组字符串,这里分隔符是英文逗号“,” 遇到其他情况只要稍加修改就好了 CREATE FUN ...
- Redis数据结构之简单动态字符串SDS
Redis的底层数据结构非常多,其中包括SDS.ZipList.SkipList.LinkedList.HashTable.Intset等.如果你对Redis的理解还只停留在get.set的水平的话, ...
- 小白的Redis学习(一)-SDS简单动态字符串
本文为读<Redis设计与实现>的记录.该书以Redis2.9讲解Redis相关内容.请注意版本差异. Redis使用C语言实现,他对C语言中的char类型数据进行封装,构建了一种简单动态 ...
- redis_简单动态字符串
在redis中,C字符串(以'\0'结尾的字符数组)只用在一些无需对字符串值进行修改的地方,比如打印日志.其他情况,redis使用SDS - SimpleDynamicString 简单动态字符串,来 ...
- redis 系列3 数据结构之简单动态字符串 SDS
一. SDS概述 Redis 没有直接使用C语言传统的字符串表示,而是自己构建了一种名为简单动态字符串(simple dynamic string, SDS)的抽象类型,并将SDS用作Redis的默 ...
- 图解Redis之数据结构篇——简单动态字符串SDS
图解Redis之数据结构篇--简单动态字符串SDS 前言 相信用过Redis的人都知道,Redis提供了一个逻辑上的对象系统构建了一个键值对数据库以供客户端用户使用.这个对象系统包括字符串对象 ...
- Redis中的简单动态字符串
Redis没有直接使用C语言传统的字符串表示(以空字符结尾的字符数组,以下简称C字符串),而是自己构建了一种名为简单动态字符串(simple dynamic string,SDS)的抽象类型,并将SD ...
- Redis---SDS(简单动态字符串)
Redis 没有直接使用 C 语言传统的字符串表示(以空字符结尾的字符数组,以下简称 C 字符串), 而是自己构建了一种名为简单动态字符串(simple dynamic string,SDS)的抽象类 ...
- Redis数据类型之SDS简单动态字符串
一,简单的动态字符串 1,Redis自己构建了一种名为简单动态字符串的抽象类型,并将SDS用作Redis的默认字符串表示, 2,在redis的数据库里面,包含字符串值的键值对在底层都是由SDS实现的 ...
随机推荐
- hadoop笔记之Hive入门(Hive的体系结构)
Hive入门(二) Hive入门(二) Hive的体系结构 ○ Hive的元数据 Hive将元数据存储在数据库中(metastore),支持mysql.derby.oracle等数据库,Hive默认是 ...
- HTTP协议中keep-alive
一 . http协议是有连接的协议,这样每一个连接过来都要重新打开一个tcp的http socket,短期内同一个host 对服务器的请求就会很慢,若是能够保持住连接,就可以节省socket open ...
- The number of positions
Description The number of positions time limit per test: 0.5 second memory limit per test: 256 megab ...
- 【翻译】MVC Music Store 教程-概述(三)
Controller 与传统的Web框架,将传入的URL通常映射到磁盘上的文件.例如:一个URL请求“/Products.aspx" 或"/Products.php”是处理一个Pr ...
- SQL Server 的三种用户自定义函数
create function fun_A() #标题函数.create function fun_name() returns output_type as begin return value ...
- SelectDirectory使用方法以及EnableTaskWindows
SelectDirectory使用方法 格式 Delphi syntax: On Windows: function SelectDirectory(const Caption: string; co ...
- Android切换页面效果的实现二:WebView+ViewPager
前言: 由于第一种切换页面的效果不能满足项目的要求,于是又找到另外一种更简单好用的方法来实现,顿时感觉,做项目开发,找到一种合适的方法能够减少很多时间,(刚开始自己弄的时候还想着自己写手势识别的方法呢 ...
- ceph伦理概念
Preface: CEPH: THE FUTURE OF STORAGE(未来存储) Ceph was made possible by a global community of passionat ...
- 调用父类Controller错误
在写一个控制器的时候,要特别注意本类继承的父类.不要继承错了.如图: ,这样就会一直是显示父类的控制器,而不是显示本类的控制器视图. 应该改为: 这些都是平时遇到的一些小问题,留着提醒自己.
- Lua学习2 Lua小框架的搭建
看了上一篇Lua环境搭建具体http://blog.csdn.net/liuwumiyuhuiping/article/details/9196435 为了方便学习. 具体新开始搭建一下学习的小框架. ...