- C++
究极无敌石山代码,可算三位数的颠倒数,耗时三天,惊天巨史
- @ 2026-2-3 19:44:35
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
int a=1,b=0,c,n,x=1,y=0,q,p,g;
cin>>n;
q=n;
g=n;
while(a!=0){
a=a/10;
b=b+1;
}
p=b;
while(b!=0){
x=x*10;
b=b-1;
}
while(n!=0){
c=n;
y=y+c%10*x*10;
x=x/10;
n=n/10;
}
while(p!=-1){
q=q/10;
p=p-1;
}
cout<<y+q+g;
return 0;
}
4 条评论
-
lizongxian LV 6 @ 2026-2-4 19:36:59已修改
1234 5555 -------------------------------- Process exited after 3.447 seconds with return value 0 请按任意键继续. . . -
@ 2026-2-4 19:34:59
123 444 -------------------------------- Process exited after 1.366 seconds with return value 0 请按任意键继续. . . -
@ 2026-2-4 14:18:44
真是太无敌了666!
🤣 1 -
@ 2026-2-3 19:46:59
四位数版本
#include <iostream> #include <iomanip> using namespace std; int main(){ int a=1,b=0,c,n,x=1,y=0,q,p,g; cin>>n; q=n; g=n; while(a!=0){ a=a/10; b=b+1; } p=b; while(b!=-1){ x=x*10; b=b-1; } while(n!=0){ c=n; y=y+c%10*x*10; x=x/10; n=n/10; } while(p!=-2){ q=q/10; p=p-1; } cout<<y+q+g; return 0; }
- 1