#include <iostream>
#include <string>
using namespace std;
void questions(int a,long long gold)
{
string b;
if(a == 1){
if(gold >= 0)
{
gold = gold - 0;
//第1关
cout << "1+1=? " << endl;
cin >> b;
if(b == '2')
{
//正确
cout << "答案正确" << endl;
//第2题
cout << "3+5=?" << endl;
cin << b;
if(b == '8')
{
//正确
cout << "答案正确" << endl;
//第3题
cout << "2+5=?" << endl;
if(b == '7')
{
//正确
cout << "恭喜通关" << endl;
gold = gold + 10;
}
else
{
//错误
cout << "啊哦,错了" << endl;
}
}
else
{
//错误
cout << "啊哦,错了" << endl;
}
}
else
{
//错误
cout << "啊噢,错了";
}
}
else
{
cout << "Error:No 0 gold you have!" << endl <<
}
}
if(a == 2){
if(gold >= 5)
{
gold = gold - 5;
//第2关
cout << "8+6=? " << endl;
cin >> b;
if(b == '14')
{
//正确
cout << "答案正确" << endl;
//第二题
cout << "9+5=?" << endl;
cin << b;
if(b == '14')
{
//正确
cout << "答案正确" << endl;
//第三题
cout << "10+8=?" << endl;
if(b == '18')
{
//正确
cout << "恭喜通关" << endl;
gold = gold + 15;
}
else
{
//错误
cout << "啊哦,错了" << endl;
}
}
else
{
//错误
cout << "啊哦,错了" << endl;
}
}
else
{
//错误
cout << "啊噢,错了";
}
}
else
{
cout << "Error:No 5 gold you have!" << endl <<
}
}
int main()
{
long c;
while(1)
{
cout << "关卡选择" << endl;
cout << "输入关卡的数字" << endl;
cin >> c;
questions(c,100);
}
return 0;
}
报错:> 官方微信2133688724
开始编译
编译失败/storage/emulated/0/Code/Project/CPlusPlus/n/main.cpp:7:15: error: stray '\357' in program if(a == 1){ ^ compilation terminated due to -Wfatal-errors.