当前位置:网站首页>C language program: judging triangles
C language program: judging triangles
2022-07-28 14:47:00 【Youth is short!】
Define a function , Judge whether the three reshaped side lengths can form a triangle , If it's a triangle , Then judge whether it is a right triangle .
1) Declare functions judge;
2) Implementation function judge, Judge whether a triangle can be formed according to the input three side lengths ;
3) stay main Call in judge;
4) stay main According to the judge The return value of determines whether it is a triangle , If it forms a triangle, it is further judged whether it is a right triangle , Output the corresponding result .
Problem analysis :
(1) The key factor of triangle formation is the value of three sides , It is also the basis of our judgment
(2) So let's first write a judge Function to judge whether it can form a triangle , And return a similar bool Judgement of type , It is convenient to call the main function quickly
(3) Further in the main function “ Data groups that can form triangles ” Judge whether it can constitute “ right triangle ”
#include <stdio.h>
int judge(int x,int y,int z)
{
int m;
if (((x+y)>z)&&((x-y)<z)&&((x+z)>y)&&((x-z)<y)&&((y+z)>x)&&((y-z)<x))
m=1;
else
m=0;
return m;
}
main()
{
int a,b,c,n;
printf(" Please enter a,b,c:");
scanf("%d%d%d",&a,&b,&c);
n=judge(a,b,c);
if (n==1)
if (((a*a+b*b)==c*c)||((a*a+c*c)==b*b)||(b*b+c*c==a*a)) // Or condition to judge whether it is a right triangle
printf(" Can form a right triangle ");
else
printf(" Can form a triangle ");
else
printf(" Can't make a triangle ");
}边栏推荐
- 在 SwiftUI 视图中打开 URL 的若干方法
- 企鹅一面:为什么不建议使用SELECT * ?
- 2022 safety officer-a certificate operation certificate examination question bank simulated examination platform operation
- When Xcode writes swiftui code, it is a small trap that compiles successfully but causes the preview to crash
- [ecmascript6] modularization
- How to use the C language library function getchar ()
- 58子站安居,经纪人营销管理平台登录接口加密逆向
- C # 7 methods to obtain the current path
- Brief introduction and use of mqtt entry level
- 如何有效进行回顾会议(上)?
猜你喜欢

2022 low voltage electrician examination questions and answers

35道MySQL面试必问题图解,这样也太好理解了吧

2022 safety officer-a certificate operation certificate examination question bank simulated examination platform operation

2022 high altitude installation, maintenance, removal of examination question bank and online simulated examination

Copy excel row to specified row

使用Weka与Excel进行简单的数据分析

复制excel行到指定行

Thrift 序列化协议浅析

Read the introduction tutorial of rainbow
C# 读取ini文件、键值对操作
随机推荐
Chi square distribution and gamma function
Several methods of opening URL in swiftui view
分集技术简略
[ecmascript6] modularization
[leetcode] 1331. Array sequence number conversion
SwiftUI 布局 —— 对齐
OKR and grad
Swiftui layout - size (top)
Copy excel row to specified row
Unittest executes runtestcase prompt <_ io. Textiowrapper name= '< stderr>' mode=W encoding=UTF-8 > solution
Open source project - taier1.2 release, new workflow, tenant binding simplification and other functions
C# 读取ini文件、键值对操作
AFNetworking速成教程
2022高处安装、维护、拆除考试题库及在线模拟考试
Qt中QTableView设置分页显示的三种方法[通俗易懂]
基础架构之日志管理平台及钉钉&邮件告警通知
2022年熔化焊接与热切割考题及在线模拟考试
Redis-持久化
How to effectively conduct the review meeting (Part 1)?
2022年熔化焊接与热切割考题及在线模拟考试