我应该如何编写在C ++中执行相同操作的代码?我觉得很难......
### X,Y and Z will all be integers (numbers). The user will input a number 3 three times thus determining the type of triangle###
x = int(input("Input your first length: "))
y = int(input("Input your second length: "))
z = int(input("Input your third length: "))
### "=" is an equality operater. If the side of x, y and x are all equal the triangle will be equilateral.###
if (x == y == z):
print ("The program recognises this as an Equilateral triangle.")
答案 0 :(得分:2)
我不会为你编写代码,但我会给你一些指导:
除了为您编写代码之外,这将是您获得的最大帮助(这对您的学习没有帮助。)
答案 1 :(得分:0)
#include <iostream>
int main()
{
int x, y, z;
std::cin >> x;
std::cin >> y;
std::cin >> z;
if (x == y && x == z)
std::cout << "equilateral" << std::endl;
}
请注意,在C ++中没有==
运算符和三个操作数。 (x == y) == z
会将x与y进行比较并返回true或false。然后它会将真/假与z进行比较,这不是你想要的。