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 |
第一个递归题,突然的灵感,学会了递归,附代码留念·····#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator