上面兄弟的程序在VC6.0里虽然编译和连接都没什么问题,但是是得不出正确结果的,输入11,12,13只会显示11.这显然是不正确的.错误之处是下面这句
scanf("%d%d%d", &a, &b, &c); 应为scanf("%d,%d,%d", &a, &b, &c); 少了3个逗号.
以下是小弟写的 在VC6.0下调试通过:
#include <stdio.h>
void selmax(int *p1,int *p2,int *p3)
{
if (*p1<*p2) *p1=*p2;
if (*p1<*p3) *p1=*p3;
}
void main()
{
int a,b,c;
int *max=&a,*t1=&b,*t2=&c;
printf("请输入a,b,c三个数:\n");
scanf("%d,%d,%d",&a,&b,&c);
selmax(max,t1,t2);
printf("\n最大值为:%d\n",*max);
}
温馨提示:答案为网友推荐,仅供参考