| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1158 人关注过本帖
标题:一运行就press any key to continue
只看楼主 加入收藏
空白先生
Rank: 2
等 级:论坛游民
帖 子:115
专家分:95
注 册:2012-12-9
结帖率:92.86%
收藏
已结贴  问题点数:20 回复次数:12 
一运行就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
azzbcc
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
来 自:江西财经大学
等 级:贵宾
威 望:81
帖 子:3293
专家分:12919
注 册:2012-11-4
收藏
得分:7 
a[20][100001]  数组开太大了,栈空间不足


[fly]存在即是合理[/fly]
2013-07-01 17:46
Han_FlyB
Rank: 6Rank: 6
等 级:侠之大者
帖 子:143
专家分:424
注 册:2013-3-25
收藏
得分:7 
你弄这个二维数组那么大干嘛,几十,几百个应该够你随便来了吧
2013-07-01 22:54
夏日小旺
Rank: 1
等 级:新手上路
帖 子:1
专家分:7
注 册:2013-7-2
收藏
得分:7 
你这个程序是干吗用的,编写的程序要达到什么目的。
还有,那times是不是常量,你可以把它定义成符号常量啊,改的时候也很方便啊,这样做感觉不好。
还有两个for循环,第二个那儿没看懂,不知道要干吗?
2013-07-02 13:28
空白先生
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
快速回复:一运行就press any key to continue
数据加载中...
 
   



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

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