当前位置:网站首页>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;
}
边栏推荐
- Attributes of classfile
- Chrome user script manager tempermonkey monkey
- Vs+qt set application icon
- 攻防世界-Web进阶区-unserialize3
- 2837xd 代码生成——补充(1)
- MySQL事务
- QT信号槽总结-connect函数错误用法
- 一次聊天勾起的回忆
- Inverter Simulink model -- processor in the loop test (PIL)
- Navicat 远程连接Mysql报错1045 - Access denied for user ‘root‘@‘222.173.220.236‘ (using password: YES)
猜你喜欢
随机推荐
Pool de connexion redis personnalisé
Required request body is missing:(跨域问题)
Is the C language too fat
C语言之二进制与十进制
View the port of the application published by was
因上努力,果上随缘
Chrome user script manager tempermonkey monkey
int与string、int与QString互转
MySQL default transaction isolation level and row lock
分享一篇博客(水一篇博客)
How to use pyqt5 to make a sensitive word detection tool
Who is better for Beijing software development? How to find someone to develop system software
VIM操作命令大全
2837xd 代码生成——StateFlow(2)
Supplier selection and prequalification of Oracle project management system
Hystrix implements request consolidation
Break the cocoon | one article explains what is the real cloud primordial
Ckeditor 4.10.1 upload pictures to prompt "incorrect server response" problem solution
Insight into cloud native | microservices and microservice architecture
并网逆变器PI控制(并网模式)









