アニメ!アニメ!

2015年5月11日月曜日

[C++]条件分岐

#include <iostream>
using namespace std;


void Ending()//エンディング
{
cout << "スライムを倒した!\n" << endl;
cout << "経験値を獲得した";
}

void GameOver()//ゲームオーバー
{
cout << "ゲームオーバー" << endl;
}
void GotoRight()//B
{
int Attack;
cout << "スライムが現れた!" << endl;
cout << "1:戦う" << endl;
cout << "2:逃げる" << endl;

cin >> Attack;
if (Attack == 1)
{
Ending();
}
else
{
GameOver();
}
}

void GotoLeft()//A
{

cout << "左に進みました" << endl;
cout << "エンディング" << endl;
}

void StartGame() //スタート
{
cout << "エンディング" << endl;
cout << "ゲームオーバー" << endl;
cout << "0 :右の道を進む" << endl;
cout << "1 : 左の道を進む" << endl;

int start;
cin >> start;
// cout << start << endl;

if (0 == start)
{
GotoRight();
}
else
{
GotoLeft();
}
}

int main()
{
StartGame(); //関数呼び出し
}