拓展:输入三个整数,求最大的数。
分析:
输入3个整数(x,y,z)
找到前两个数(x,y)的较大的数t
再从较大的数t和z中间找较大的数---》t
输出t的值
#include <stdio.h>
int main()
{
int x,y,z,t;
scanf("%d%d%d",&x,&y,&z);
t=x;
if (t<y)
t=y;
if (t<z)
t=z;
printf("%d\n",t);
return 0;
}
格式2:
if (exp)
语句1
else
语句2
功能:如果exp成立,则执行语句1;否则执行语句2
上一页
[1]
[2]
[3]
[4]
[5]
下一页