三数最大值。
程序 :
/*
*All rights reserved.
*文件名称:7
*作 者:孙丽
*完成时间:2018年10月11日
*版 本 号:V1.0
*
*问题描述:输入三个整数,输出其中的最大值。
*程序输出:三数最大值。
*/
#include <stdio.h>
int main()
{
int a,b,c,max;
printf("请输入三个整数a、b和c:");
scanf("%d %d %d",&a,&b,&c);
if(a>b)
max=a;
else
max=b;
if(c>max)
max=c;
printf("a、b和c中的最大值是%d。\n",max);
return 0;
}
运行结果:
知识点总结:
if(表达式)
语句1;
else
语句2;
心得:
使用scanf时注意数字输入间隔是空格还是逗号。