直角三角形...... [英] Right triangles...

查看:71
本文介绍了直角三角形......的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在,我已经创建了一个程序,当用户输入3个数字时,应该通过使用二次方程告诉用户是否是直角三角形



(a ^ 2 + b ^ 2 = c ^ 2)。现在,授予它可能很难在运行时得到3

数字,当通过该等式时出现真实,但是即使使用0'也是如此
,它应该是正确的。如果

以下代码有问题,我会很感激帮助,否则,请告诉我一些数字

将起作用。

#include< iomanip>

#include< iostream>


使用命名空间std;


int main()

{


//声明变量

int side1,side2,side3;

双倍金额;


//获得用户的支持

cout<< 输入表示三角形边的3个整数:;

cin>> side1>> side2>> side3;


//确定它是否为直角三角形

sum =(side1 ^ 2)+(side2 ^ 2);

side3 =(side3 ^ 2);


if(sum == side3)

cout<< 这是一个直角三角形。;

其他

cout<< 这不是一个直角三角形。;


返回0;


}

Now, I''ve made a program that when the user enters 3 numbers, it is supposed
to tell the user if it is a right triangle by using the quadratic equation
(a^2 + b^2 = c^2). Now, granted it can be difficult to come up with 3
numbers on the fly that when run through that equation come out true, but
even with using 0''s, it should be correct. If there is something wrong with
the following code, I''d appreciate the help, otherwise, tell me some numbers
that will work.
#include <iomanip>
#include <iostream>

using namespace std;

int main()
{

//declare variables
int side1, side2, side3;
double sum;

//get sides from the user
cout << "Enter 3 integers representing sides of a triangle: ";
cin >> side1 >> side2 >> side3;

//determine if it is a right triangle
sum = (side1 ^ 2) + (side2 ^ 2);
side3 = (side3 ^ 2);

if (sum == side3)
cout << "This is a right triangle.";
else
cout << "This is not a right triangle.";

return 0;

}

推荐答案

deanfamily11写道:
deanfamily11 wrote:
以下代码,我会感谢帮助,否则,请告诉我一些数字
即可。
side3 =(side3 ^ 2);
the following code, I''d appreciate the help, otherwise, tell me some numbers
that will work.
side3 = (side3 ^ 2);




^运算符不执行取幂。它按位执行

独家或。


Gregg



The "^" operator does not perform exponentiation. It performs bitwise
exclusive or.

Gregg


数字3 4 5和倍数他们会工作。

你还需要测试三个numbners的所有组合,

即,如果我输入5 3 4,你的程序就不会被检测到一个直角三角形。

" deanfamily11" <德********** @ verizon.net>在消息中写道

news:QKrUe.165
the numbers 3 4 5 and multiple of them will work.
You also need to test all the combinations of the three numbners,
that is, if I enter 5 3 4, you program won''t detect a right angle triangle.
"deanfamily11" <de**********@verizon.net> wrote in message
news:QKrUe.165


R9.0@trnddc02 ...
R9.0@trnddc02...
现在,我已经做了一个程序,当用户输入3个数字时,
应该通过使用二次方程(a ^ 2 + b ^ 2 = c ^ 2)告诉用户它是否是直角三角形。现在,授予它可能很难在运行时得到3个数字,当通过该等式时出现真实,但即使使用0',它也应该是正确的。如果使用以下代码有错误的
,我会感谢您的帮助,否则,请告诉我一些可用的
数字。

#include< iomanip>
#include< iostream>

使用命名空间std;

int main()
//声明变量
int side1,side2,side3;
double sum;

//从用户那里获得支持
cout<< 输入表示三角形边的3个整数:;
cin>> side1>> side2>> side3;

//确定它是否是直角三角形
sum =(side1 ^ 2)+(side2 ^ 2);
side3 =(side3 ^ 2);

if(sum == side3)
cout<< 这是一个直角三角形。;
其他
cout<< 这不是一个直角三角形。;

返回0;

}
Now, I''ve made a program that when the user enters 3 numbers, it is supposed to tell the user if it is a right triangle by using the quadratic equation
(a^2 + b^2 = c^2). Now, granted it can be difficult to come up with 3
numbers on the fly that when run through that equation come out true, but
even with using 0''s, it should be correct. If there is something wrong with the following code, I''d appreciate the help, otherwise, tell me some numbers that will work.
#include <iomanip>
#include <iostream>

using namespace std;

int main()
{

//declare variables
int side1, side2, side3;
double sum;

//get sides from the user
cout << "Enter 3 integers representing sides of a triangle: ";
cin >> side1 >> side2 >> side3;

//determine if it is a right triangle
sum = (side1 ^ 2) + (side2 ^ 2);
side3 = (side3 ^ 2);

if (sum == side3)
cout << "This is a right triangle.";
else
cout << "This is not a right triangle.";

return 0;

}



这篇关于直角三角形......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆