广告广告
  加入我的最爱 设为首页 风格修改
首页 首尾
 手机版   订阅   地图  繁体 
您是第 2631 个阅读者
 
发表文章 发表投票 回覆文章
  可列印版   加为IE收藏   收藏主题   上一主题 | 下一主题   
hannah93135
个人文章 个人相簿 个人日记 个人地图
路人甲
级别: 路人甲 该用户目前不上站
推文 x0 鲜花 x0
分享: 转寄此文章 Facebook Plurk Twitter 复制连结到剪贴簿 转换为繁体 转换为简体 载入图片
推文 x0
[C/C++][求助] 有个ACM10141的问题
我在输入的地方就发生问题了
可是我不知道是哪里错了
可不可以帮我看看阿~~~
拜托拜托了~(急) thx^^

对了!这里是题目↓↓


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int orfin;
char name_fin;
void swap(int*,int*);
void bubble(int*[],int*[],int);
int main()
{
int n,p,i,j,k,cheap,flag,num=0;
while(1)
{scanf("%d %d",&n,&p);
if(n==0&&p==0)
break;
char need,com_name;
double d;
int r,ra,or;
num+=1;
for(i=0;i<n;i++)
gets(need);
for(i=0;i<p;i++)
{
or=i;
ra=0;
gets(com_name);
..

访客只能看到部份内容,免费 加入会员 或由脸书 Google 可以看到全部内容



[ 此文章被hannah93135在2008-07-05 00:10重新编辑 ]



献花 x0 回到顶端 [楼 主] From:台湾中华电信 | Posted:2008-07-04 20:58 |
daviddr
个人文章 个人相簿 个人日记 个人地图
小人物
级别: 小人物 该用户目前不上站
推文 x0 鲜花 x7
分享: 转寄此文章 Facebook Plurk Twitter 复制连结到剪贴簿 转换为繁体 转换为简体 载入图片


ACM 一般是读文字档作为输入,非手动输入。
这是我的解法,你可以对照着去 debug。
复制程式
int main()
{
    FILE* f;
    float cost[100], max_cost;
    int   chk[100], max_chk;
    int   round=0, i, n, p, nCo, nItem, i_cost, i_chk;
    char  co[100][80], t[80];
    f = fopen ("rfp.txt", "rt");

    while (!feof(f))
    {
        round++;
        fscanf (f,"%d %d\n", &n, &p);
        if (0 == n+p) break;
        for (i=0; i<n; i++) fgets (t,80,f);

        max_cost = max_chk = i_cost = i_chk = 0;
        for (i=0; i<p; i++) {
            fgets (co[i],80,f);
            fscanf (f,"%f %d\n", cost+i, chk+i);
            for (n=0; n<chk[i]; n++) fgets (t,80,f);
            if (chk[i] > max_chk) max_chk = chk[i], i_chk = i;            
        }
        for (n=i=0; i<p; i++) 
            if (chk[i] == max_chk) n++;

        if (n > 1)
            for (i_chk=i=0; i<p; i++)
                if (chk[i] == max_chk && cost[i] > max_cost) 
                    max_cost = cost[i], i_chk = i;

        printf ("RFP #%d\n%s\n", round, co[i_chk]);        
    }    
    fclose(f);
    getch();
    return 0;
}


献花 x0 回到顶端 [1 楼] From:台湾中华 | Posted:2008-07-06 05:04 |
hannah93135
个人文章 个人相簿 个人日记 个人地图
路人甲
级别: 路人甲 该用户目前不上站
推文 x0 鲜花 x0
分享: 转寄此文章 Facebook Plurk Twitter 复制连结到剪贴簿 转换为繁体 转换为简体 载入图片

噢噢~
谢谢你︿︿
不过我发现我不能登入acm耶= =


献花 x0 回到顶端 [2 楼] From:台湾中华电信 | Posted:2008-07-07 12:09 |

首页  发表文章 发表投票 回覆文章
Powered by PHPWind v1.3.6
Copyright © 2003-04 PHPWind
Processed in 0.022768 second(s),query:16 Gzip disabled
本站由 瀛睿律师事务所 担任常年法律顾问 | 免责声明 | 本网站已依台湾网站内容分级规定处理 | 连络我们 | 访客留言