当前位置:网站首页>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 ");
}边栏推荐
- AFNetworking速成教程
- The method of implementing simple student achievement management system with C language
- Node文件操作
- How many ways can multithread run in sequence?
- Some problems encountered in the development of Excel VBA, solutions, and continuous updates
- How to perform batch operations in core data
- pix2pix
- Excel VBA 免密查看VBE加密代码
- How to effectively conduct the review meeting (Part 1)?
- ZABBIX distributed
猜你喜欢

2022 melting welding and thermal cutting examination questions and online simulation examination

九、uni-popup用法 下拉框底部弹窗效果

2022年熔化焊接与热切割考题及在线模拟考试

基于 MinIO 对象存储保障 Rancher 数据

Analysis of thrift serialization protocol

TDengine 助力西门子轻量级数字化解决方案

The method of implementing simple student achievement management system with C language

Various pitfalls encountered in UI development

八、picker用法 下拉框选择效果
![[ecmascript6] async and await](/img/3c/c7de42ad572dc95b188243c02dd228.png)
[ecmascript6] async and await
随机推荐
使用Weka与Excel进行简单的数据分析
On July 29, apachecon | apachepulsar's exploration and practice in vivo will be broadcast soon
Redis persistence
468 product planning and promotion plan (150 copies)
TDengine 助力西门子轻量级数字化解决方案
JS instantiation method
Store and guarantee rancher data based on Minio objects
Realization of chat room function
Why can the anonymous functions of JQ access the methods inside
2022 safety officer-a certificate operation certificate examination question bank simulated examination platform operation
Thoughts on the construction of some enterprise data platforms
如何只降3D相机不降UI相机的分辨率
Redis-配置文件讲解
Various pitfalls encountered in UI development
Hand in hand from 0 to a "Nuggets special attention" Google plug-in, 5000 words detailed vue3 responsive principle, the advantages, disadvantages and choices of several cache read-write schemes, flyin
Excel VBA password free view VBE encryption code
[ecmascript6] async and await
Swiftui layout - size (bottom)
多线程顺序运行有几种方法?
How many ways can multithread run in sequence?