一行数逆序数
#include <stdio.h> int main ( ) { int n,a[1000],s,t,k,i=0,j; scanf("%d",&n); while(n>=10) { a[i++]=n%10; n=n/10; } a[i]=n; for(k=0;k<=i;k++)printf("%d ",a[k]);printf("\n"); s=0 ; t=0;j=0; for(k=0;k<=i;k++) { j=i-k; t=a[k]; while(j--) { t=t*10; } s=s+t; } printf("%d\n",s); return 0; }
#include<iostream> using namespace std; int main() { int x,t,n,j,t1; while(cin>>x) { t=x; n=1;j=1; while(t=t/10)n++;//n是记录整数x的位数 for(int i=0;i<n;i++) { t1=x/j%10;//t1用来记录整数x的第i位数据 j=j*10; if(t==0&&t1==0)continue;//排除尾数的0 else {cout<<t1;t++;} } cout<<endl; } return 0; }
#include <stdio.h> int main ( ) { int n,a[1000],k,i=0; scanf("%d",&n); while(n>=10) { a[i++]=n%10; n=n/10; } a[i]=n; for(k=0;k<=i;k++)printf("%d",a[k]); printf("\n"); }