gpt4 book ai didi

c++ - 简单的嵌套 "If else"语句

转载 作者:行者123 更新时间:2023-11-30 02:51:48 26 4
gpt4 key购买 nike

<分区>

编译时没有错误...但是我的输出没有得到任何结果。我知道这是一种非常笨拙的编码尝试...我大部分时间都在处理数字...字符串的东西让我感到困惑。

#include <iostream>
#include <string>

using namespace std;
char chr;

int main()
{
string name;
string artist;
string Taylor;
string Alan;
string general;
string box;
string seating;

cout << "Enter your name followed by the return key" << endl;
cin >> name;
cout << endl;
cout << "Enter Taylor for Taylor Swift tickets or Alan for Alan Jacskon seats, followed" << endl << "by the enter key" << endl << endl;
cout << "Enter box for box seating or general for general seating, followed by the enter key" << endl << endl;
cin >> artist;
cin >> seating;

if ( artist + seating == Taylor + general )
cout << name << ", Your ticket will cost $60" << endl;
else if ( artist + seating == Taylor + box )
cout << name << ", Your ticket will cost $100" << endl;
else if ( artist + seating == Alan + box )
cout << name << ", Your ticket will cost $75" << endl;
else if ( artist + seating == Alan + general )
cout << name << ", Your ticket will cost $50" << endl;

cin >> chr;
return 0;
}

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com