Input 3 numbers from keyboard, find the max among the 3 numbers and indicate which one is the max number. If there is more than one max number, show all of them. 输入的三个数中有可能有1个,2个或3个最大值,需要指示是哪几个数是最大值。
2条回答 默认 最新
- benbenli 2021-05-13 03:04关注
#include <stdio.h> int main() { int a, b, c, m; printf("Please enter 3 integers: "); scanf("%d%d%d", &a, &b, &c); m = a < b ? b : a; m = m < c ? c : m; printf("The max number is: \n"); if (a == m) { printf("The first number: %d\n", a); } if (b == m) { printf("The second number: %d\n", b); } if (c == m) { printf("The third number: %d\n", c); } } // Output Please enter 3 integers: 7 8 9 The max number is: The third number: 9 Please enter 3 integers: 3 3 3 The max number is: The first number: 3 The second number: 3 The third number: 3
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
- ¥170 如图所示配置eNSP
- ¥20 docker里部署springboot项目,访问不到扬声器
- ¥15 netty整合springboot之后自动重连失效
- ¥15 悬赏!微信开发者工具报错,求帮改
- ¥20 wireshark抓不到vlan
- ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
- ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
- ¥15 stata安慰剂检验作图但是真实值不出现在图上
- ¥15 c程序不知道为什么得不到结果