文号
t21468
阅读
7554
回复
7
收藏
5
无聊程序---数字冰雹
2009/12/20
IP:江苏
我刚学c,编了这个来练练手,呵呵,很简单的[s:258]
#include "stdafx.h"
#include<iostream>
using namespace std;
int a;
int b;
int n;
int _tmain(int argc, _TCHAR* argv[])
{
    n=1;
    cout<<"请输入检测数字:";
    cin>>a;
    cout<<"\n";
    while(a!=1){
     if(a%2==0)
        a=a*0.5;
     else
        a=(a*3+1)/2;
     cout<<"第"<<n<<"个数:"<<a<<"\t";
     n++;
    };
    cin>>b;
    return 0;
}

不过,谁能告诉我怎么让它执行完后返回重新执行吗???
还有,"cin>>b;"这条是多余的,但不加的话计算完毕就关掉了,看不到结果.
attachment icon 数字冰雹.rar 10.05KB RAR 19次下载
笔记
{{note.content}}
{{n.user.username}}
{{fromNow(n.toc)}} {{n.status === noteStatus.disabled ? "已屏蔽" : ""}} {{n.status === noteStatus.unknown ? "正在审核" : ""}} {{n.status === noteStatus.deleted ? '已删除' : ''}}
  • 编辑
  • 删除
  • {{n.status === 'disabled' ? "解除屏蔽" : "屏蔽" }}
我也是有底线的