C++ 为什么赢了';t代码在c+中正确运行+; intmain() { std::cout输入; std::cin.ignore(); 如果(输入=“+”) { 国际贸易1号; std::cout>no1; std::cin.ignore(); std::cout

C++ 为什么赢了';t代码在c+中正确运行+; intmain() { std::cout输入; std::cin.ignore(); 如果(输入=“+”) { 国际贸易1号; std::cout>no1; std::cin.ignore(); std::cout,c++,C++,在第5行,您将输入声明为int。在第9行,您将输入(整数)与字符串进行比较,这是不可能的。如果您将“+”更改为“+”,检查将起作用。 但是,将输入更改为char并将条件更改为if(input='+')会更好(如所述) >将正确的错误发布。对它的广泛解释不是很有帮助。你试图比较字符串和int。我认为C++不允许。如果你希望使用字符串,你应该把输入作为字符串。你应该改变 int输入;< /C> > 字符输入;当然, >如果代码(输入= = +),请更改。到如果(输入=='+')。“运行程序”是一个编

在第5行,您将输入声明为
int
。在第9行,您将输入(整数)与
字符串进行比较,这是不可能的。如果您将
“+”
更改为
“+”
,检查将起作用。
但是,将输入更改为
char
并将条件更改为
if(input='+')
会更好(如所述)

>将正确的错误发布。对它的广泛解释不是很有帮助。你试图比较字符串和int。我认为C++不允许。如果你希望使用字符串,你应该把输入作为字符串。你应该改变<代码> int输入;< /C> > <代码>字符输入;当然,<代码> >如果代码(输入= = +),请更改<代码>。

如果(输入=='+')
。“运行程序”是一个编译器。
int main()
{

    std::cout << " Here is my calculator!\n ";
    int input;
    std::cout << " What operation do you wish to use? Use +, -, x, / as signs!\n ";
    std::cin >> input;
    std::cin.ignore();
    if ( input == "+" )
 {
    int no1;
    std::cout << " Okay, addition what is your first number? ";
    std::cin >> no1;
    std::cin.ignore();
    std::cout << " Okay, So your first number is " << no1 << "!\n";
    int no2;
    std::cout << " So you're first number is " << no1 << " What do you wish you're second number to be? " << "!\n";
    std::cin >> no2;
    std::cin.ignore();
    std::cout << " Okay so you're second number is " << no2 << "In the end the equation is " << no1 << "+" << no2 << "!\n";
    std::cout << " The answer to you're question is " << no1 << "+" << no2 << "=" << no2 + no1 << "!\n";
    std::cout << " Thank you for using my calculator, Bye!\n";

}