| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1158 人关注过本帖
标题:一运行就press any key to continue
取消只看楼主 加入收藏
空白先生
Rank: 2
等 级:论坛游民
帖 子:115
专家分:95
注 册:2012-12-9
结帖率:92.86%
收藏
已结贴  问题点数:20 回复次数:9 
一运行就press any key to continue
#include<stdio.h>
int main()
{
    int Sum(int a[100001],int m,int n);
    int a[20][100001];
    int bg,ed;
    int times;
    int i,j,k;
    int max[20]={0};
    scanf("%d",&times);
    for(k=0;k<times;k++)
    {
        scanf("%d",&a[k][0]);
        for(i=1;i<=a[k][0];i++)
            scanf("%d",&a[k][i]);
    }
    for(k=0;k<times;k++)
    {
        for(i=1;i<=a[k][0];i++)
            for(j=i;j<=a[k][0];j++)
                if(Sum(a[k],i,j)>max[k])
                {
                    max[k]=Sum(a[k],i,j);
                    bg=i;
                    ed=j;
                }
         printf("%d %d %d\n",max[k],bg,ed);
    }
    return 0;
}
int Sum(int a[100001],int m,int n)
{
    int sum=0;
    int i;
    for(i=m;i<=n;i++)
        sum=sum+a[i];
    return sum;
}
搜索更多相关主题的帖子: continue include 
2013-07-01 15:56
空白先生
Rank: 2
等 级:论坛游民
帖 子:115
专家分:95
注 册:2012-12-9
收藏
得分:0 
不懂啊,至少也要运行scanf("%d",&times);
这个吧

printf("My goal is to be  good at computer")
2013-07-01 15:56
空白先生
Rank: 2
等 级:论坛游民
帖 子:115
专家分:95
注 册:2012-12-9
收藏
得分:0 
Max Sum
Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 109135    Accepted Submission(s): 25151

Problem Description
Given a sequence a[1],a[2],a[3]......a[n], your job is to calculate the max sum of a sub-sequence. For example, given (6,-1,5,4,-7), the max sum in this sequence is 6 + (-1) + 5 + 4 = 14.
 

Input
The first line of the input contains an integer T(1<=T<=20) which means the number of test cases. Then T lines follow, each line starts with a number N(1<=N<=100000), then N integers followed(all the integers are between -1000 and 1000).
 

Output
For each test case, you should output two lines. The first line is "Case #:", # means the number of the test case. The second line contains three integers, the Max Sum in the sequence, the start position of the sub-sequence, the end position of the sub-sequence. If there are more than one result, output the first one. Output a blank line between two cases.
 

Sample Input
2
5 6 -1 5 4 -7
7 0 6 -1 1 -6 7 -5
 

Sample Output
Case 1:
14 1 4

Case 2:
7 1 6
是在做这道题目,题目输入要求The first line of the input contains an integer T(1<=T<=20) which means the number of test cases. Then T lines follow, each line starts with a number N(1<=N<=100000), then N integers followed(all the integers are between -1000 and 1000).
想了种拙劣的方法,就是计算出每种可能的值

printf("My goal is to be  good at computer")
2013-07-02 20:34
空白先生
Rank: 2
等 级:论坛游民
帖 子:115
专家分:95
注 册:2012-12-9
收藏
得分:0 
回复 3楼 azzbcc
那是不是应该改成指针?

printf("My goal is to be  good at computer")
2013-07-02 20:35
空白先生
Rank: 2
等 级:论坛游民
帖 子:115
专家分:95
注 册:2012-12-9
收藏
得分:0 
翻译一下题目,题目大意是让你输入一些数字,然后算出连续相加的最大值

printf("My goal is to be  good at computer")
2013-07-02 20:36
空白先生
Rank: 2
等 级:论坛游民
帖 子:115
专家分:95
注 册:2012-12-9
收藏
得分:0 
并输出相加的开始和结束的位置

printf("My goal is to be  good at computer")
2013-07-02 20:37
空白先生
Rank: 2
等 级:论坛游民
帖 子:115
专家分:95
注 册:2012-12-9
收藏
得分:0 
回复 4楼 Han_FlyB
题目要求测试的数据有点多

printf("My goal is to be  good at computer")
2013-07-02 20:38
空白先生
Rank: 2
等 级:论坛游民
帖 子:115
专家分:95
注 册:2012-12-9
收藏
得分:0 
回复 5楼 夏日小旺
输入部分
    scanf("%d",&times);
    for(k=0;k<times;k++)
    {
        scanf("%d",&a[k][0]);
        for(i=1;i<=a[k][0];i++)
            scanf("%d",&a[k][i]);
    }
输入要测试的次数
输入每次测试的数据的长度,输入要测试的数据

printf("My goal is to be  good at computer")
2013-07-02 20:56
空白先生
Rank: 2
等 级:论坛游民
帖 子:115
专家分:95
注 册:2012-12-9
收藏
得分:0 
回复 4楼 Han_FlyB
我也很无奈呀,每次输入的数据长度要求是1-100000

printf("My goal is to be  good at computer")
2013-07-02 20:58
空白先生
Rank: 2
等 级:论坛游民
帖 子:115
专家分:95
注 册:2012-12-9
收藏
得分:0 
对不起对不起,我该把注释写好的,害大家烦恼了

printf("My goal is to be  good at computer")
2013-07-02 20:59
快速回复:一运行就press any key to continue
数据加载中...
 
   



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

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