xibaby @ 2023-12-03 15:06:15
#include<bits/stdc++.h>
using namespace std;
long long n;
int main(){
scanf("%lld",&n);
while(n>1)
if(n%2){
printf("%lld*3+1=%lld",n,n*3+1);
n=n*3+1;
}
else{
printf("%lld/2=%lld\n",n,n/2);
n/=2;
}
printf("END");
return 0;
}
by Patronus @ 2023-12-03 15:11:18
第一个输出没换行
最后应该输出
by xibaby @ 2023-12-03 15:23:43
@Patronus 非常感谢!
by xiangyu666888 @ 2023-12-30 09:35:54
@xibaby #include <iostream>
int main() { int n; std::cin >> n;
while (n != 1) {
std::cout << n << (n % 2 ? "*3+1=" : "/2=") << (n = (n % 2 ? 3 * n + 1 : n / 2)) << std::endl;
}
std::cout << "End" << std::endl;
return 0;
}
#include <iostream>
int main() {
int n;
std::cin >> n;
while (n != 1) {
std::cout << n << (n % 2 ? "*3+1=" : "/2=") << (n = (n % 2 ? 3 * n + 1 : n / 2)) << std::endl;
}
std::cout << "End" << std::endl;
return 0;
}