您的位置:首页 > 其它

第七讲 项目2-三数最大值

2015-11-04 01:46 330 查看
任务和代码:

<pre name="code" class="cpp">/*
*Copyright (c)2015 CSDN学院
*All rights reserved
*文件名字:main.c
*作者:修红国
*完成日期:2015年11月4日
*版本号:V1.0
* 问题描述:输入3个整数,输出其中的最大值。
* 提示:求出两数的大值,再求这个大值与第三数间的大值,为三数最大值
*/
#include <stdio.h>
#include <stdlib.h>

int main( )
{
int a,b,c,iMax;
printf("请输入3个整数:");
scanf("%d %d %d", &a, &b, &c);
if(a>b)
{
iMax=a;
}

else
{
iMax=b;
}

if(c>iMax) //再求出c和max的大值
{
iMax=c;
}

printf("最大值是: %d\n", iMax);
return 0;
}



运行结果:



知识点总结:

输入3个整数,输出其中的最大值
心得:

有些误区 大小转来转去有些迷糊 还好有答案 能对照下 理解了
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: