用switch方法写出由键盘输入任意三个数,计算以这三个数为边长的三角形周长先判断是否为三角形
时间: 2023-04-03 21:05:20 浏览: 66
可以回答这个问题。以下是代码:
#include <stdio.h>
int main() {
int a, b, c;
printf("请输入三个数,用空格隔开:");
scanf("%d %d %d", &a, &b, &c);
if (a + b > c && a + c > b && b + c > a) {
int perimeter = a + b + c;
printf("这是一个三角形,周长为:%d\n", perimeter);
} else {
printf("这不是一个三角形\n");
}
return 0;
}
相关推荐
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![ppt](https://img-home.csdnimg.cn/images/20210720083527.png)
![pptx](https://img-home.csdnimg.cn/images/20210720083543.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)