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

第一个递归题,突然的灵感,学会了递归,附代码留念·····

Posted by 512336048 at 2012-10-30 21:32:51 on Problem 1664
#include<stdio.h>
int f(int M,int N)
{
     if(N==1||M==1||N==0||M==0)
     return(1);
    else if(M>=N)
     return (f(M-N,N)+f(M,N-1));
    else if(M<N)
     return(f(M,M));
}
void main()
{
    int a,b,c,i;
    scanf("%d",&c);
    for(i=0;i<c;i++)
    {
        scanf("%d %d",&a,&b);
    printf("%d\n",f(a,b));
    }
}

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