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

此题代码很短,,请各位看一下我在 调用函数f ( ) 中调用 函数min ( ) 能否这样写。。。

Posted by 13107222 at 2008-09-15 21:21:36 on Problem 3278
#include"stdio.h"
long f(long );
long min(long ,long ,long );
long m,n;
void main()
{
  scanf("%ld%ld",&m,&n);
    printf("%ld",f(m));
  getch();
}

long f(long m)
{
 if(m>=n)
 return (m-n);

   return (min(1+f(m+1),1+f(m-1),1+f(2*m)));
}

long min(long a,long b,long c)
{
  long min;
  min=a;
  if(b<min)
  min=b;
  if(c<min)
  min=c;
  return min;
}

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