#include <iostream>
#include <string>
#include <sstream>
using namespace std;
int main() {
string gun = "";
cout << "Enter The Gun You Would Like To Know The Type Of Ammo For: \n";
getline(cin, gun);
if (gun == "b95" || "B95" || "windchester" || "wind chester" || "Windchester" || "Wind Chester" || "longhorn" || "Long Horn" || "fal" || "FAL")
{
cout << "The Type Of Ammo For The " << gun << " Is 308 Windchester";
}
if (gun == "izh rifle" || "IZH Rifle" || "izhrifle" || "izh rifle" || "sks" || "SKS" || "akm" || "AKM")
{
cout << "The Type Of Ammo For The " << gun << " 7.62x39mm";
}
if (gun == "Mangnum" || "mangnum" || "Repetor" || "repetor")
{
cout << "The Type Of Ammo For The " << gun << ".357";
}
return 0;
}
当程序运行时,例如我会输入sks,它会输出所有的cout消息,例如:对于sks的弹药类型是308 WindchesterThe类型的弹药对于sks 7.62x39mmThe类型的弹药对于sks.357试图获得用户输入和输出一个消息,当我输入一个有效的名字时,它会全部输出
如果条件不符合你的要求,请[读一本好书](https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list)并从它学习C++而不是猜测。 – Rakete1111