| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 564 人关注过本帖
标题:怎样实现这样的循环?代码如下,求指教,谢谢
取消只看楼主 加入收藏
Jacsion
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2014-10-26
结帖率:0
收藏
已结贴  问题点数:5 回复次数:2 
怎样实现这样的循环?代码如下,求指教,谢谢
public double DWfromM() {
        if(t<=30)
        {
            DWGeneration += (Math.exp(workedDAreaGrowthM * t) - DWGeneration;
            t++;
        }
        else if(t<=60)
        {
            int k;
            k=60-t;
            DWGeneration += (Math.exp(workedDAreaGrowthM * t) - DWGeneration;
            t++;
        }
        else if(t<=90)
        {
            int k;
            k=t-60;
            DWGeneration += (Math.exp(workedDAreaGrowthM * t) - DWGeneration;
            t++;
        }
        else if(t<=120)
        {
            int k;
            k=120-t;
            DWGeneration +=(Math.exp(workedDAreaGrowthM * t) - DWGeneration;
            t++;
        }
        else if(t<=150)
        {
            int k;
            k=t-120;
            DWGeneration +=(Math.exp(workedDAreaGrowthM * t) - DWGeneration;
            t++;
        }
        else if(t<=180)
        {
            int k;
            k=180-t;
            DWGeneration +=(Math.exp(workedDAreaGrowthM * t) - DWGeneration;
            t++;
        }
        else if(t<=210)
        {
            int k;
            k=t-180;
            DWGeneration +=(Math.exp(workedDAreaGrowthM * t) - DWGeneration;
            t++;
        }
        else if(t<=240)
        {
            int k;
            k=240-t;
            DWGeneration += (Math.exp(workedDAreaGrowthM * t) - DWGeneration;
            t++;
        }
        else if(t<=270)
        {
            int k;
            k=t-240;
            DWGeneration +=(Math.exp(workedDAreaGrowthM * t) - DWGeneration;
            t++;
        }
        else if(t<=300)
        {
            int k;
            k=300-t;
            DWGeneration += (Math.exp(workedDAreaGrowthM * t) - DWGeneration;
            t++;
        }
        else if(t<=330)
        {
            int k;
            k=t-300;
            DWGeneration += (Math.exp(workedDAreaGrowthM * t) - DWGeneration;
            t++;
        }
        else if(t<=360)
        {
            int k;
            k=360-t;
            DWGeneration +=(Math.exp(workedDAreaGrowthM * t) - DWGeneration;
            t++;
        }
        else if(t<=390)
        {
            int k;
            k=t-360;
            DWGeneration += (Math.exp(workedDAreaGrowthM * t) - DWGeneration;
            t++;
        }
        else if(t<=420)
        {
            int k;
            k=420-t;
            DWGeneration += (Math.exp(workedDAreaGrowthM * t) - DWGeneration;
            t++;
        }
        else if(t<=450)
        {
            int k;
            k=t-420;
            DWGeneration +=(Math.exp(workedDAreaGrowthM * t) - DWGeneration;
            t++;
        }
        else if(t<=480)
        {
            int k;
            k=480-t;
            DWGeneration +=(Math.exp(workedDAreaGrowthM * t) - DWGeneration;
            t++;
        }
        else if(t<=510)
        {
            int k;
            k=t-480;
            DWGeneration +=(Math.exp(workedDAreaGrowthM * t) - DWGeneration;
            t++;
        }
        else if(t<=540)
        {
            int k;
            k=540-t;
            DWGeneration +=(Math.exp(workedDAreaGrowthM * t) - DWGeneration;
            t++;
        }
        else if(t<=570)
        {
            int k;
            k=t-540;
            DWGeneration += (Math.exp(workedDAreaGrowthM * t) - DWGeneration;
            t++;
        }
        else if(t<=600)
        {
            int k;
            k=600-t;
            DWGeneration += (Math.exp(workedDAreaGrowthM * t) - DWGeneration;
            t++;
        }
        else if(t<=630)
        {
            int k;
            k=t-600;
            DWGeneration +=(Math.exp(workedDAreaGrowthM * t) - DWGeneration;
            t++;
        }
        
        return DWGeneration;
    }
搜索更多相关主题的帖子: public double 
2014-10-26 08:52
Jacsion
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2014-10-26
收藏
得分:0 
公式中的t应该是k,不好意思啊
2014-10-26 09:44
Jacsion
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2014-10-26
收藏
得分:0 
回复 3 楼 日知己所无
private int t=0;
public double DWfromM() {
        if(t<=30)
        {
            int k;
            k=t;
            DWGeneration += (Math.exp(workedDAreaGrowthM * k) - DWGeneration;
        }
        else if(t<=60)
        {
            int k;
            k=60-t;
            DWGeneration += (Math.exp(workedDAreaGrowthM * k) - DWGeneration;
        }
        else if(t<=90)
        {
            int k;
            k=t-60;
           DWGeneration += (Math.exp(workedDAreaGrowthM * k) - DWGeneration;
        }
        else if(t<=120)
        {
            int k;
            k=120-t;
            DWGeneration += (Math.exp(workedDAreaGrowthM * k) - DWGeneration;
        }
        else if(t<=150)
        {
            int k;
            k=t-120;
            DWGeneration += (Math.exp(workedDAreaGrowthM * k) - DWGeneration;
        }
        else if(t<=180)
        {
            int k;
            k=180-t;
           DWGeneration += (Math.exp(workedDAreaGrowthM * k) - DWGeneration;
        }
        else if(t<=210)
        {
            int k;
            k=t-180;
            DWGeneration += (Math.exp(workedDAreaGrowthM * k) - DWGeneration;
        }
        else if(t<=240)
        {
            int k;
            k=240-t;
            DWGeneration += (Math.exp(workedDAreaGrowthM * k) - DWGeneration;
        }
        else if(t<=270)
        {
            int k;
            k=t-240;
           DWGeneration += (Math.exp(workedDAreaGrowthM * k) - DWGeneration;
        }
        else if(t<=300)
        {
            int k;
            k=300-t;
            DWGeneration += (Math.exp(workedDAreaGrowthM * k) - DWGeneration;
        }
        else if(t<=330)
        {
            int k;
            k=t-300;
           DWGeneration += (Math.exp(workedDAreaGrowthM * k) - DWGeneration;
        }
        else if(t<=360)
        {
            int k;
            k=360-t;
            DWGeneration += (Math.exp(workedDAreaGrowthM * k) - DWGeneration;
        }
        else if(t<=390)
        {
            int k;
            k=t-360;
             DWGeneration += (Math.exp(workedDAreaGrowthM * k) - DWGeneration;
            t++;
        }
        else if(t<=420)
        {
            int k;
            k=420-t;
            DWGeneration += (Math.exp(workedDAreaGrowthM * k) - DWGeneration;
        }
        else if(t<=450)
        {
            int k;
            k=t-420;
            DWGeneration += (Math.exp(workedDAreaGrowthM * k) - DWGeneration;
        }
        else if(t<=480)
        {
            int k;
            k=480-t;
            DWGeneration += (Math.exp(workedDAreaGrowthM * k) - DWGeneration;
        }
        else if(t<=510)
        {
            int k;
            k=t-480;
            DWGeneration += (Math.exp(workedDAreaGrowthM * k) - DWGeneration;
        }
        else if(t<=540)
        {
            int k;
            k=540-t;
           DWGeneration += (Math.exp(workedDAreaGrowthM * k) - DWGeneration;
        }
        else if(t<=570)
        {
            int k;
            k=t-540;
            DWGeneration += (Math.exp(workedDAreaGrowthM * k) - DWGeneration;
        }
        else if(t<=600)
        {
            int k;
            k=600-t;
            DWGeneration += (Math.exp(workedDAreaGrowthM * k) - DWGeneration;
        }
        else if(t<=630)
        {
            int k;
            k=t-600;
             DWGeneration += (Math.exp(workedDAreaGrowthM * k) - DWGeneration;
        }
        t++;
        return DWGeneration;
    }
主要是想要实现计算的时候仿真时间t取0-30,计算时k取0-30,仿真时间t取31-60,计算时k取30-0,仿真时间t取61-90,计算时k取0-30,仿真时间t取91-120,计算时k取30-0,这种循环一直下去,怎么是实现?求指教,谢谢。
2014-10-26 10:40
快速回复:怎样实现这样的循环?代码如下,求指教,谢谢
数据加载中...
 
   



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

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