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. OC语法8——@class关键字

    @class关键字: 在当前类中若要引用其他类的对象作成员变量(Book  *book),我们以前采用的方式是 #import "Book.h" 但 #import "B ...

  2. getElementByID、getElementsByName、getElementsByTagName实例详解

    getElementByID.getElementsByName.getElementsByTagName实例详解 本文通过实例,详细介绍了getElementByID.getElementsByNa ...

  3. 织梦list文章列表按权重排序

    织梦的文章列表按权重排序 DEDECMS(织梦)5.6系统支持文档权重weight排序,可以在模板中使用: {dede:arclist row='10' titlelen='50' orderby=' ...

  4. Scala的类中定义内部类实战

    scala独特之处在于可以在类中定义内部类,起到对外屏蔽作用. 类中默认都是public权限.后面将讲解如何引入接口,scala中的接口与java点区别.特质/接口(Trait)

  5. hl7 java 解析

    原文链接 http://blog.csdn.net/ycyangcai/article/details/6643784 Hl7引擎的目标主要是解决将数据按HL7协议的要求标准化,和标准业务的集成和不同 ...

  6. Traveling

    Problem J: Traveling Time Limit: 1 Sec  Memory Limit: 32 MB Description SH likes traveling around th ...

  7. 新手笔记-tftp与yum

    lspci 查看pci插槽设备 lsusb  查看USB设备 tftp 配置文件 /etc/xinetd.d/tftp tftp 根目录 /var/lib/tftpboot service xinet ...

  8. BT Smart vs ANT+ 技术孰优孰劣?

    自从Bluetooth SIG提出Bluetooth 4.0,其BLE(Bluetooth Low Energy)开始用于穿戴式电子,而后也用于iBeacon室内定位,更之后Bluetooth 4.1 ...

  9. 快速傅里叶变换FFT

    多项式乘法 #include <cstdio> #include <cmath> #include <algorithm> #include <cstdlib ...

  10. ldap理论属于概念缩略词

    Standalone LDAP Daemon, slapd(standalone lightweight access protocol) ldap 389 default listener port ...