Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

一次A过,求改进

Posted by speedcell4 at 2011-02-03 05:10:32 on Problem 1504
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator