主题:C语言中的max,报错了,怎么调试?
#include <stdio.h>
main(){
int a,b,c;
scanf(“%d,%d,%d”,&a,&b,&c); /*input this way: 4,68,34*/
if (a>b)
if(a>c)
max=a;
else
max=c;
else
if(b>c)
max=b;
else
max=c;
printf(“%d”,max);
}
The running result for the input 4,68,34:
#include <stdio.h>
main(){
int a,b,c;
scanf(“%d,%d,%d”,&a,&b,&c); /*input this way: 4,68,34*/
if (a>b)
if(a>c)
max=a;
else
max=c;
else
if(b>c)
max=b;
else
max=c;
printf(“%d”,max);
}
The running result for the input 4,68,34:
沙发
板凳
#include <stdio.h>
int main(void)
{
int a, b, c;
int max;
printf("Input: ");
scanf("%d, %d, %d", &a, &b, &c);
if (a > b)
if (a > c)
max = a;
else
max = c;
else if (b > c)
max = b;
else
max = c;
printf("Output: %d\n", max);
return 0;
}
// max 没定义
3 楼
4 楼
5 楼
可以这样
#include<stdio.h>
int main()
{
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
int max = a>b?a:b;
max = max>c?max:c;
printf("%d",max);
return 0;
}
您尚未登录,请登录后再回复。点此登录或注册