问题如下,VC6.0.主函数为什么调用不了子函数。在线等。
#include"stdafx.h"#include<stdio.h>intmain(){inta,b,t;scanf("%d%d",&a,&b);intmax(intx...
#include "stdafx.h"
#include <stdio.h>
int main()
{
int a,b,t;
scanf("%d %d",&a,&b);
int max(int x,int y);
t=max(a,b);
printf("%d\n",t);
}
int max(int x,int y)
{
int t,t1,t2,t3;
if(x>y)
{
t=x;
x=y;
y=t;
}
while (t1>=0)
{
t1=y/x;
}
if(t1==0)
t=t1;
else
while(t2>=0)
t2=t1/y;
if(t2==0)
t=t2;
else
while(t3>=0)
{
t3=t2/t1;
t=t3;
}
return (t);
} 展开
#include <stdio.h>
int main()
{
int a,b,t;
scanf("%d %d",&a,&b);
int max(int x,int y);
t=max(a,b);
printf("%d\n",t);
}
int max(int x,int y)
{
int t,t1,t2,t3;
if(x>y)
{
t=x;
x=y;
y=t;
}
while (t1>=0)
{
t1=y/x;
}
if(t1==0)
t=t1;
else
while(t2>=0)
t2=t1/y;
if(t2==0)
t=t2;
else
while(t3>=0)
{
t3=t2/t1;
t=t3;
}
return (t);
} 展开
展开全部
方法一:在主函数中声明,在主函数加上int max(int x,int y)
方法二:如下修改
#include "stdafx.h"
#include <stdio.h>
int max(int x,int y)
{
int t,t1,t2,t3;
if(x>y)
{
t=x;
x=y;
y=t;
}
while (t1>=0)
{
t1=y/x;
}
if(t1==0)
t=t1;
else
while(t2>=0)
t2=t1/y;
if(t2==0)
t=t2;
else
while(t3>=0)
{
t3=t2/t1;
t=t3;
}
return (t);
}
int main()
{
int a,b,t;
scanf("%d %d",&a,&b);
int max(int x,int y);
t=max(a,b);
printf("%d\n",t);
}
方法二:如下修改
#include "stdafx.h"
#include <stdio.h>
int max(int x,int y)
{
int t,t1,t2,t3;
if(x>y)
{
t=x;
x=y;
y=t;
}
while (t1>=0)
{
t1=y/x;
}
if(t1==0)
t=t1;
else
while(t2>=0)
t2=t1/y;
if(t2==0)
t=t2;
else
while(t3>=0)
{
t3=t2/t1;
t=t3;
}
return (t);
}
int main()
{
int a,b,t;
scanf("%d %d",&a,&b);
int max(int x,int y);
t=max(a,b);
printf("%d\n",t);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询