需要帮助形成一个循环 [英] need help to form a loop

查看:95
本文介绍了需要帮助形成一个循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何为1、3、5、9、12、15、20、24、28、34、39、43 ...系列形成循环
编辑(由Nelek撰写):以下是OP的答复

我得到了答案并形成了循环:

如下:-

int n = 1;
int k;
cout<<"1";
for(int i = 2; i< 100; i ++)
{
cout<< k = n + i< k = k + i<< k = k + i + 2;
n = k;
}


克里斯蒂安·特纳克斯(Christian tnx)先生给了我建议....

How to form a loop for series 1,3,5,9,12,15,20,24,28,34,39,43....

EDIT (by Nelek): The OP answered below

I GOT THE ANSWER AND FORMED THE LOOP:

IT IS AS FOLLOWS:-

int n=1;
int k;
cout<<"1";
for(int i=2;i<100;i++)
{
cout<<k=n+i<<k=k+i<<k=k+i+2;
n=k;
}


and Mr christian tnx for giving me advice....

推荐答案

我相信您会发现这被称为作业.这意味着您应该自己解决问题.当您尝试自己学习一些东西并发现需要一点帮助时,请务必提出一个特定的问题.不要要求我们为您做这一切.从痛苦的经验中我们知道,如果我们帮助您,您将无所适从,并且会在工作场所向我们提出类似的问题.
I believe you''ll find that this is called homework. That means you''re supposed to work out how to do it yourself. By all means ask a specific question when you''ve tried to learn something by yourself and found you need a little help. Don''t ask us to do it all for you. We know from bitter experience that if we help you, you will pass without learning anything, and you''ll be asking us similar questions in the workplace.


我得到了答案并形成了循环:

如下:-

int n = 1;
int k;
cout<<"1";
for(int i = 2; i< 100; i ++)
{
cout<
I GOT THE ANSWER AND FORMED THE LOOP:

IT IS AS FOLLOWS:-

int n=1;
int k;
cout<<"1";
for(int i=2;i<100;i++)
{
cout<


您的循环是可以的,它将打印出意甲的编号,但这只是最后一件事...您将打印出类似以下内容的内容:
1359121520 ....

因此,您只需要添加空格和逗号即可使它作为意甲读取.
Your loop is Ok, that will print out the numbers of the serie, but just a last thing... with that you are going to print out something like:
1359121520....

So you just need to add the blank spaces and the comas to make it readable as a serie.


这篇关于需要帮助形成一个循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆