当前位置:网站首页>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;
}
边栏推荐
- Say goodbye to 996. What are the necessary plug-ins in idea?
- QT signal slot summary -connect function incorrect usage
- 2837xd 代码生成——补充(2)
- 2837xd 代码生成——补充(3)
- What are the differences between TP5 and laravel
- Supplier selection and prequalification of Oracle project management system
- How to choose between efficiency and correctness of these three implementation methods of distributed locks?
- Idempotent design of Internet API interface
- VIM operation command Encyclopedia
- Amq6126 problem solving ideas
猜你喜欢

Web security and defense

图像识别-数据清洗

攻防世界-Web进阶区-unserialize3

2837xd code generation - stateflow (4)

PI control of grid connected inverter (grid connected mode)

Bold prediction: it will become the core player of 5g

Off grid control of three-phase inverter - PR control

Matplotlib swordsman line - first acquaintance with Matplotlib

Fragmenttabhost implements the interface of housing loan calculator

Navicat remote connection MySQL reports an error 1045 - access denied for user 'root' @ '222.173.220.236' (using password: yes)
随机推荐
YOLO物体识别,生成数据用到的工具
ZK configuration center -- configuration and use of config Toolkit
MySql报错:unblock with mysqladmin flush-hosts
Image recognition - data augmentation
三相并网逆变器PI控制——离网模式
C语言之数据插入
Save video opencv:: videowriter
Difference between redis serialization genericjackson2jsonredisserializer and jackson2jsonredisserializer
上班第一天的报错(AWVS卸载不彻底)
Amq6126 problem solving ideas
Int to string, int to qstring
道阻且长,行则将至
PI control of grid connected inverter (grid connected mode)
FragmentTabHost实现房贷计算器界面
Chrome browser plug-in fatkun installation and introduction
Personal experience & blog status
QT qlabel style settings
2837xd code generation - stateflow (4)
Chrome video download Plug-in – video downloader for Chrome
Activity的创建和跳转