| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 562 人关注过本帖
标题:杭电1718题,样例能过,但是没法AC,求大神看看我的代码。
只看楼主 加入收藏
redfire
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2012-10-30
结帖率:0
收藏
已结贴  问题点数:20 回复次数:4 
杭电1718题,样例能过,但是没法AC,求大神看看我的代码。
Problem Description
Jackson wants to know his rank in the class. The professor has posted a list of student numbers and marks. Compute Jackson’s rank in class; that is, if he has the top mark(or is tied for the top mark) his rank is 1; if he has the second best mark(or is tied) his rank is 2, and so on.
 

Input
The input consist of several test cases. Each case begins with the student number of Jackson, an integer between 10000000 and 99999999. Following the student number are several lines, each containing a student number between 10000000 and 99999999 and a mark between 0 and 100. A line with a student number and mark of 0 terminates each test case. There are no more than 1000 students in the class, and each has a unique student number.
 

Output
For each test case, output a line giving Jackson’s rank in the class.
 

Sample Input
20070101
20070102 100
20070101 33
20070103 22
20070106 33
0 0
 

Sample Output
2
 
程序代码:
#include <stdio.h>
#include <string.h>
int sign[1110],score[1110];
int main ()
{
     int a,b,c,i,k,j,y;
     memset(sign,0,sizeof(sign));
     memset(score,0,sizeof(score));
     scanf("%d",&a);
     i=0;
     k=1;
     while((scanf("%d%d",&b,&c))!=EOF)
     {
         if (b==0&&c==0)
         break;
         i++;
         sign[i]=b;
         score[i]=c;
     }
     while(sign[k]!=a)
     k++;
     k=score[k];
     for (j=1,y=1;j<=i;j++)
     {
         if (score[j]>k)
         y++;
     }
     printf("%d\n",y);
     return 0;
}
样例输出没错呀,但是没法AC,求解。
搜索更多相关主题的帖子: his top Jackson between numbers 
2012-11-06 18:40
czz5242199
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:小飞侠
威 望:4
帖 子:660
专家分:2400
注 册:2011-10-26
收藏
得分:7 
y的初值何在?
2012-11-06 18:57
redfire
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2012-10-30
收藏
得分:0 
回复 2楼 czz5242199
倒数第八行的FOR循环里的初始化语句里面啊。。
2012-11-06 20:14
青春无限
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
来 自:江苏
等 级:贵宾
威 望:24
帖 子:3451
专家分:19340
注 册:2012-3-31
收藏
得分:7 
学习

学 会看代码…学习写程序…学会搞开发…我的目标!呵呵是不是说大话啊!!一切皆可能
2012-11-06 20:48
zxd543
Rank: 11Rank: 11Rank: 11Rank: 11
来 自:内蒙古
等 级:贵宾
威 望:17
帖 子:453
专家分:2351
注 册:2012-4-12
收藏
得分:7 
你的程序我看了看 感觉有点乱
20070102 100
本来是一组数据 你却存到两个数组里 实现起来应该不怎么好
见你你用二维数组或是结构体写这个程序

马马虎虎 不吝赐教 我是路过蹭分滴
2012-11-07 23:34
快速回复:杭电1718题,样例能过,但是没法AC,求大神看看我的代码。
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015237 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved