当前位置:网站首页>Judging right triangle in C language
Judging right triangle in C language
2022-07-02 09:44:00 【FF small confused acridine~】
A closed figure composed of three line segments that are not on the same straight line connected in sequence is called a triangle . Triangles are widely used in mathematics and real life . There are right triangles and non right triangles in triangles , According to the title, please , Program to judge whether it is a right triangle .
problem :
Please write the program : Enter the three sides of the triangle , Judge whether it is a right angle .
Programming requirements :
1、 Judge the triangle according to the requirements given in the title , With the help of printf Function output result ;
2、 Use scanf Function to input data ;
3、 It is required that the data type of the input three sides must be an integer ;
4、 Please output strictly according to the output effect ;( Affect the performance evaluation )
5、 When submitting the code of the task, it is necessary to ensure that it conforms to the industry code specification , You need to indent and wrap as necessary .( Affect the performance evaluation )
Running effect 1:
Please enter the three sides of the triangle , Space off :4 3 5
The triangle is a right triangle !
The right angle side is :4 3, Bevel is :5
Please press any key to continue . . .
Running effect 2:
Please enter the three sides of the triangle , Space off :4 4 4
This triangle is not a right triangle !
Please press any key to continue . . .
Running effect 3:
Please enter the three sides of the triangle , Space off :2 2 4
The input side length is incorrect !
Please press any key to continue . . .
Running effect 4:
Please enter the three sides of the triangle , Space off :-3 4 5
The input side length is incorrect !
Please press any key to continue . . .
#include <stdio.h>
int main(void)
{
int a, b, c;
printf(" Please enter the three sides of the triangle , Space off :");
scanf("%d%d%d", &a, &b, &c);
if(a <= 0 || b <= 0 || c <= 0 ||
b + c <= a || a + c <= b || a + b <= c)
printf(" The input side length is incorrect !\n");
else{
if(a * a + b * b == c * c)
printf(" The triangle is a right triangle !\n The right angle side is :%d %d, Bevel is :%d \n", a, b, c);
else if(a * a + c * c == b * b)
printf(" The triangle is a right triangle !\n The right angle side is :%d %d, Bevel is :%d \n", a, c, b);
else if(b * b + c * c == a * a)
printf(" The triangle is a right triangle !\n The right angle side is :%d %d, Bevel is :%d \n", b, c, a);
else
printf(" This triangle is not a right triangle !\n");
}
return 0;
}
#include <stdio.h>
int main(void)
{
int a,b,c;
printf(" Please enter the three sides of the triangle , Space off :");
scanf("%d %d %d",&a,&b,&c);
if(a+b>c && b+c>a && a+c>b){
if(a*a+b*b==c*c){
printf(" The triangle is a right triangle !\n The right angle side is :%d %d, Bevel is :%d\n",a,b,c);
}else if(a*a+c*c==b*b){
printf(" The triangle is a right triangle !\n The right angle side is :%d %d, Bevel is :%d\n",a,c,b);
}else if(b*b+c*c==a*a){
printf(" The triangle is a right triangle !\n The right angle side is :%d %d, Bevel is :%d\n",b,c,a);
}else{
printf(" This triangle is not a right triangle !\n");
}
}else{
printf(" The input side length is incorrect !\n");
}
return 0;
}
边栏推荐
- Elastic Stack之Beats(Filebeat、Metricbeat)、Kibana、Logstash教程
- 2837xd 代码生成——StateFlow(4)
- Discussion on improving development quality and reducing test bug rate
- Say goodbye to 996. What are the necessary plug-ins in idea?
- 因上努力,果上随缘
- Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedd
- QT QLabel样式设置
- How to choose between efficiency and correctness of these three implementation methods of distributed locks?
- Idea view bytecode configuration
- VIM operation command Encyclopedia
猜你喜欢

Redis installation and deployment (windows/linux)

并网逆变器PI控制(并网模式)

Pool de connexion redis personnalisé

Tinyxml2 reading and modifying files

Mysql默认事务隔离级别及行锁

Fragmenttabhost implements the interface of housing loan calculator

2837xd代码生成模块学习(4)——idle_task、Simulink Coder

Chrome browser plug-in fatkun installation and introduction

BugkuCTF-web21(详细解题思路及步骤)

企业级SaaS CRM实现
随机推荐
BugkuCTF-web21(详细解题思路及步骤)
Share a blog (water blog)
Record personal understanding and experience of game console configuration
图像识别-数据标注
QT qlabel style settings
Beats (filebeat, metricbeat), kibana, logstack tutorial of elastic stack
2837xd 代码生成——StateFlow(1)
Alibaba / popular JSON parsing open source project fastjson2
What is the function of laravel facade
Learn combinelatest through a practical example
分享一篇博客(水一篇博客)
Image recognition - data annotation
MySQL error: unblock with mysqladmin flush hosts
Don't look for it. All the necessary plug-ins for Chrome browser are here
Break the cocoon | one article explains what is the real cloud primordial
Memories of a chat
图像识别-数据采集
三相逆变器离网控制——PR控制
每天睡前30分钟阅读Day5_Map中全部Key值,全部Value值获取方式
企业级SaaS CRM实现