当前位置:网站首页>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;
}
边栏推荐
- Chrome browser plug-in fatkun installation and introduction
- Don't look for it. All the necessary plug-ins for Chrome browser are here
- web安全与防御
- Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedd
- MySQL error: unblock with mysqladmin flush hosts
- 记录一下初次使用Xray的有趣过程
- 一次聊天勾起的回忆
- 2837xd 代码生成——StateFlow(2)
- Activity的创建和跳转
- QT QLabel样式设置
猜你喜欢
In SQL injection, why must the ID of union joint query be equal to 0
Bugkuctf-web21 (detailed problem solving ideas and steps)
In depth analysis of how the JVM executes Hello World
ZK configuration center -- configuration and use of config Toolkit
Timed thread pool implements request merging
c语言编程题
Statistical learning methods - Chapter 5, decision tree model and learning (Part 1)
Chrome video download Plug-in – video downloader for Chrome
Required request body is missing: (cross domain problem)
TD conducts functional simulation with Modelsim
随机推荐
web安全与防御
Redis 序列化 GenericJackson2JsonRedisSerializer和Jackson2JsonRedisSerializer的区别
Chrome video download Plug-in – video downloader for Chrome
c语言编程题
View the port of the application published by was
攻防世界-Web进阶区-unserialize3
Matplotlib swordsman line - first acquaintance with Matplotlib
What are the waiting methods of selenium
逆变器simulink模型——处理器在环测试(PIL)
PI control of three-phase grid connected inverter - off grid mode
How to choose between efficiency and correctness of these three implementation methods of distributed locks?
2837xd Code Generation - stateflow (4)
DTM distributed transaction manager PHP collaboration client V0.1 beta release!!!
分享一篇博客(水一篇博客)
Image recognition - Data Cleaning
企业级SaaS CRM实现
Memories of a chat
Attributes of classfile
Mysql 多列IN操作
Say goodbye to 996. What are the necessary plug-ins in idea?