第七讲程序分支结构体验 2三数最大值

来源:互联网 发布:如何防止网络购物诈骗 编辑:程序博客网 时间:2024/06/05 19:35
【项目2-三数最大值】
输入3个整数,输出其中的最大值。

提示:求出两数的大值,再求这个大值与第三数间的大值,为三数最大值

代码

#include <stdio.h>#include <stdlib.h>int main(){    int a,b,c,max;    printf("请输入3个整数:");    scanf("%d %d %d",&a,&b,&c);    if (a<b)    //先求出a和b的最大值    {        max=a;    }    else    {        max=b;    }    if(c>max)    {        max=c;    }    printf("最大值是:%d\n",max);    return 0;}

运行结果



体验心得:

通过这个程序的练习,我学会了  if   else   语句的使用。

0 0
原创粉丝点击