Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
一次A过,求改进#include<stdio.h> int t,a,b; int pow(int a,int b) { if(b==0) return 1; else return a*pow(a,b-1); } int wei(int n) { if(n<10) return 1; else return 1+wei(n/10); } int kan(int n) { int a[100]={0},i,l=wei(n); for(int i=0;l-i;i++) { a[i]=n%10; n/=10; } n=0; for(int i=0;l-i;i++) { n+=a[i]*pow(10,l-i-1); } return n; } int main() { scanf("%d",&t); while(t--) { scanf("%d%d",&a,&b); int tot=kan(a)+kan(b); tot=kan(tot); printf("%d\n",tot); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator