Course

Course

时间限制:1000 ms  |  内存限制:65535 KB
难度:2
描述
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

#include

typedef struct Course{

 char name[35];

 int grade;

 int flag;

}Course;//定义存储结构

int main(){

 int m,n,i,j,count;

 Course s[100];

 scanf("%d",&m);

  while(m--){

   count=0;

   scanf("%d",&n);

   for(i=0;i

    scanf("%s%d",s[i].name,&s[i].grade);

    s[i].flag=0;//标志变量初始化

   }

   for(i=0;i

    for(j=i+1;j

     if(s[i].flag==1)//如果是已统计过的课程退出

      break;

     if(strcmp(s[i].name,s[j].name)==0){

      s[j].flag=1;

      if(s[i].grade

      s[i].grade=s[j].grade;

      count++;

      }

     }

    }

     printf("%d\n",count);

  }

  return 0;

}
//一次就过了,第一次啊

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值