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(简单的字符串处理问题)的更多相关文章

  1. Redis的简单动态字符串实现

    Redis 没有直接使用 C 语言传统的字符串表示(以空字符结尾的字符数组,以下简称 C 字符串), 而是自己构建了一种名为简单动态字符串(simple dynamic string,sds)的抽象类 ...

  2. SQL点滴3—一个简单的字符串分割函数

    原文:SQL点滴3-一个简单的字符串分割函数 偶然在电脑里看到以前保存的这个函数,是将一个单独字符串切分成一组字符串,这里分隔符是英文逗号“,”  遇到其他情况只要稍加修改就好了 CREATE FUN ...

  3. Redis数据结构之简单动态字符串SDS

    Redis的底层数据结构非常多,其中包括SDS.ZipList.SkipList.LinkedList.HashTable.Intset等.如果你对Redis的理解还只停留在get.set的水平的话, ...

  4. 小白的Redis学习(一)-SDS简单动态字符串

    本文为读<Redis设计与实现>的记录.该书以Redis2.9讲解Redis相关内容.请注意版本差异. Redis使用C语言实现,他对C语言中的char类型数据进行封装,构建了一种简单动态 ...

  5. redis_简单动态字符串

    在redis中,C字符串(以'\0'结尾的字符数组)只用在一些无需对字符串值进行修改的地方,比如打印日志.其他情况,redis使用SDS - SimpleDynamicString 简单动态字符串,来 ...

  6. redis 系列3 数据结构之简单动态字符串 SDS

    一.  SDS概述 Redis 没有直接使用C语言传统的字符串表示,而是自己构建了一种名为简单动态字符串(simple dynamic string, SDS)的抽象类型,并将SDS用作Redis的默 ...

  7. 图解Redis之数据结构篇——简单动态字符串SDS

    图解Redis之数据结构篇--简单动态字符串SDS 前言     相信用过Redis的人都知道,Redis提供了一个逻辑上的对象系统构建了一个键值对数据库以供客户端用户使用.这个对象系统包括字符串对象 ...

  8. Redis中的简单动态字符串

    Redis没有直接使用C语言传统的字符串表示(以空字符结尾的字符数组,以下简称C字符串),而是自己构建了一种名为简单动态字符串(simple dynamic string,SDS)的抽象类型,并将SD ...

  9. Redis---SDS(简单动态字符串)

    Redis 没有直接使用 C 语言传统的字符串表示(以空字符结尾的字符数组,以下简称 C 字符串), 而是自己构建了一种名为简单动态字符串(simple dynamic string,SDS)的抽象类 ...

  10. Redis数据类型之SDS简单动态字符串

    一,简单的动态字符串 1,Redis自己构建了一种名为简单动态字符串的抽象类型,并将SDS用作Redis的默认字符串表示, 2,在redis的数据库里面,包含字符串值的键值对在底层都是由SDS实现的 ...

随机推荐

  1. C#正则提取HTML中img的url值

    /// <summary> /// 取得HTML中所有图片的 URL. /// </summary> /// <param name="sHtmlText&qu ...

  2. WGS84、GCJ-02(火星坐标)、百度坐标,Web墨卡托坐标

    GCJ-02坐标系统(火星坐标)简介:http://blog.csdn.net/giswens/article/details/8775121(存档:http://mapbd.com/cms/2012 ...

  3. Android 更好的Activity生命周期回调

    /** * This class allows you to listen to when the user is entering the background (i.e. after a home ...

  4. 如何让多个不同版本的jquery库共存

    问题描述:公司的登录接口使用的是jquery1.4.2,因为我要使用一个jquery.pagination的分页控件(jquery1.7.2).如果我使用了1.7.2,登录接口会有问题. <sc ...

  5. window.open打开新页面,并将本页数据用过url传递到打开的页面;需要两个页面;

    页面1 <!doctype html> <html lang="en"> <head> <meta charset="UTF-8 ...

  6. JSP、JSTL、EL

    Jsp Jsp内置对象: Response.Request.Page.pageContext.session.out.application.exception.config Out->jspW ...

  7. hive集群安装配置

    hive 是JAVA写的的一个数据仓库,依赖hadoop.没有安装hadoop的,请参考http://blog.csdn.net/lovemelovemycode/article/details/91 ...

  8. 【菜鸟学习Linux】-第一章-Linux环境搭建-安装VMware虚拟机

    本人菜鸟一个,刚毕业才上班2个月,现在用到Linux部署项目,这才开始学习Linux,以下是我在安装Linxu系统是遇到的一些问题,希望能给广大菜鸟们在学习的道路上提供帮助和指导,废话不多说!开工! ...

  9. C++/C# 最基本的Marshal和Ptr

    Vidyo32.VidyoClientInEventLogin Login = new Vidyo32.VidyoClientInEventLogin(); Login.portalUri = thi ...

  10. js简单实现链式调用

    链式调用实现原理:对象中的方法执行后返回对象自身即可以实现链式操作.说白了就是每一次调用方法返回的是同一个对象才可以链式调用. js简单实现链式调用demo Object.prototype.show ...