tjm20101204 @ 2022-10-26 21:23:32
#include <iostream>
using namespace std;
int main()
{
int n;
cin>>n;
if(n==1) {
cout<<"End"<<endl;
return 0;
}
if(n!=1){
if(n%2==0) {
n/=2;
cout<<n*2<<"/"<<2<<"="<<n;
}
if(n%2==1) {
n*=3,n++;
cout<<(n-1)/3<<"/"<<3<<"+1="<<n;
}
}
}
by Memory_Lin @ 2022-10-26 21:27:17
你要写一个循环呀,你这样就只会执行一遍
by tjm20101204 @ 2022-10-26 21:27:35
求助大佬
by siyue @ 2022-10-26 21:27:58
while是个好东西
by tjm20101204 @ 2022-10-26 21:28:22
谢谢大佬, 谢谢大佬,
by siyue @ 2022-10-26 21:28:37
#include <iostream>
using namespace std;
int main()
{
int n;
cin>>n;
if(n==1) {
cout<<"End"<<endl;
return 0;
}
while(n!=1){
if(n%2==0) {
n/=2;
cout<<n*2<<"/"<<2<<"="<<n;
}
if(n%2==1) {
n*=3,n++;
cout<<(n-1)/3<<"/"<<3<<"+1="<<n;
}
}
}
by tjm20101204 @ 2022-10-28 21:26:40
thank you,da lao
by tkm2013 @ 2023-08-23 11:32:56
int ->long long