大家看看我的程式哪错了?
要求是输入一个数字, 如果是单数就(数字*3)+1,如果是双数 就(数字/2),重复这个指令直到数字变成1。#include <iostream>
using namespace std;
main()
{
int number, count=0;
cout<<"Enter a positive integer value:\n";
cin>>number;
do
{
if(number%2=0)
{
number=number/2;
count++;
cout<<"The value is ";
cout<<number;
}
else if (number%2=1)
{
number=number*3+1;
count++;
cout<<"The value is ";
cout<<number;
}
else
{
cout<<"Error.\n";
}
}while(number!=1);
cout<<"Number of steps is ";
cout<<count;
return 0;
}