编写一个简单的if…else语句,比较两个数的大小。

[复制链接]
查看11 | 回复4 | 2020-12-30 21:02:12 | 显示全部楼层 |阅读模式
if a>b thenmax=aelsemax=bendif例如:# includemain (){int a,b,max;scanf("%d,"%d,&a,&b);if (a>b)max=a;else max=b;frintf("较大数字是%d\n",max);}扩展资料:if语句的一般形式如下:if(表达式)语句1[else语句2]if语句中的“表达式”可以是关系表达式、逻辑表达式,甚至是数值表达式。其中最直观、最容易理解的是关系表达式。所谓关系表达式就
回复

使用道具 举报

千问 | 2020-12-30 21:02:12 | 显示全部楼层
#include void main(){ int a,b,max;
scanf("%d%d",&a,&b);
if(a>b) max=a;else
max=b;printf("两者较大值为%d\n",max);}
回复

使用道具 举报

千问 | 2020-12-30 21:02:12 | 显示全部楼层
vb,或ASP语言的写法是:if a>b then
max=aelse max=bWF,或.NET的写法:if(a>b)
max=aelse
max=b
回复

使用道具 举报

千问 | 2020-12-30 21:02:12 | 显示全部楼层
if a>b then max=aelse max=bendif
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行