3 条评论
-
liruihao LV 3 @ 2026-10-4 12:01:59
不要太死板了,可以用string啊,不用再累死累活的处理数字了代码如下:
#include<bits/stdc++.h> using namespace std; string s,ans; int main() { ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL); cin>>s; for(int i=s.size()-1;i>=0;i--) { ans+=s[i]; } cout<<ans; return 0; } ```*** -
@ 2026-8-19 12:26:32
#include<bits/stdc++.h> using namespace std; int main(){ int n,num=0,count=0; cin>>n; int t=n8/8; int l=1; while(t>0){ t/=10; count++; } for(int i=1;i<=count-1;i++){ l=10; } while(n>0){ int a; a=n%10; n/=10; a*=l; l/=10; num+=a; } cout<<num;
} 这样就行
-
@ 2026-8-13 22:15:43
自己看题解
#include<bits/stdc++.h> using namespace std; int c=0; long long n; int w[10]; int i=1; int main() { cin>>n; while(n!=0) { w[++c]=n%10; n/=10; } while(w[i]==0) { i++; } for(;i<=c;i++) { cout<<w[i]; } cout<<'\n'; return 0; }
- 1