| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 547 人关注过本帖
标题:答案错误?
只看楼主 加入收藏
glglzb
Rank: 2
等 级:论坛游民
帖 子:47
专家分:22
注 册:2011-10-12
结帖率:93.33%
收藏
已结贴  问题点数:15 回复次数:3 
答案错误?
在sicily在线测试平台上,我的代码在VS上的结果和输出结果上一模一样,但是sicily上说是答案错误。
希望大家看一下,谢谢。
题目要求:
1157. The hardest problem
题目描述
In the final exam, you are given n problems to solve, each one of which has an integer value indicating its difficulty, the larger, the harder. You need to find out which problem is the hardest.

输入格式

Input may contain several test cases, one per line. For each test case, the first integer indicates n (1<=n<=4), the number of problems. And then n signed 32-bit integers follow. A case with n=0 indicates the end of input, which should not be processed.


输出格式
For each test case, you must output the difficulty value of the hardest problem in a single line.

样例输入
1 1
2 1 2
3 1 3 2
4 1 2 3 4
0
样例输出
1
2
3
4
我的代码:
#include <stdio.h>
int main()
{     
    int n,a[100];
    int b[100];
    int i,m=0,j,max,k;     
    while (1)     
    {         
        max=0;
        scanf("%d",&n);         
        if(n==0)            
            break;        
        for(i=0;i<n;i++)        
    {            
        scanf("%d",&a[i]);        
    }
        
        
        for(j=0;j<=n;j++)
        {
            if(max<a[j])
                max=a[j];
        }
        b[m]=max;
        m++;
        
        
        
    }
   
        {for( k=0;k<m;k++)
    {
    printf("%d\n",b[k]);
    }
    }
    return 0;
    }
搜索更多相关主题的帖子: difficulty 在线测试 problems contain 
2012-01-26 16:33
zhangxiangD
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:39
专家分:119
注 册:2011-12-20
收藏
得分:15 
楼主的程序我改了一下,你用的括号太多,不好看懂
#include <stdio.h>
int main()
{     
     int n,a[100];
     int b[100];
     int i,m=0,j,max,k;  //  m的初值为0   
     while (1)     
     {         
         max=0;     //  max初值为0
         printf("输入n的值:");
         scanf("%d",&n);    //  输入n的值      
         if(n==0)      //  若n为0,跳出循环        
            break;
         printf("输入%d个数:",n);      
         for(i=0;i<n;i++)    //  读入n个数   
            scanf("%d",&a[i]);        
         for(j=0;j<n;j++)   //   n个数中的非负数的最大值,并装在数组b中
            if(max<a[j])
               max=a[j];
         b[m]=max;
         m++;
     }
     printf("以上%d组数中的最大值分别为:\n",m);
     for(int k=0;k<m;k++)
         printf("%d\n",b[k]);   //输出数组b
     return 0;
    }

     
2012-01-26 17:43
glglzb
Rank: 2
等 级:论坛游民
帖 子:47
专家分:22
注 册:2011-10-12
收藏
得分:0 
谢谢,
2012-01-26 18:00
beyondyf
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
等 级:贵宾
威 望:103
帖 子:3282
专家分:12654
注 册:2008-1-21
收藏
得分:0 
楼上代码通过了吗,你就结贴了

重剑无锋,大巧不工
2012-01-26 20:09
快速回复:答案错误?
数据加载中...
 
   



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

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