标题:一个简单的代码 执行时间太长 疑惑 求解惑!
取消只看楼主
xiaoloveyao
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2012-7-11
 问题点数:0 回复次数:0 
一个简单的代码 执行时间太长 疑惑 求解惑!
#include<iostream.h>
int odd(int x)
{
    static int m=0,n=0;
    if(x%2!=0)
    {
        n++;
    }
    else
        m++;
    return(n);
}

void main()
{
    int a=0,od,ev,i=0;
    cout<<"please input Sequence of integers:"<<endl;
    do{
        cin>>a;
        i++;
        od=odd(a);
        ev=i-od;
    }while(a!=-1);
    cout<<"the sun of odd is:"<<od<<endl;
    cout<<"the sum of even is:"<<ev<<endl;
}
这段代码执行的时候窗口出来比较慢,我很疑惑,程序哪边占空间了 有人知道吗
注:Rebulit All之后执行很慢,第二次又很快了,为什么前一次会那么慢呢?
搜索更多相关主题的帖子: please include return 
2012-07-11 15:15



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-373165-1-1.html




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

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