一個驚險的故事_C++輸入輸出練習
阿新 • • 發佈:2019-02-08
//game_state 3.0
#include<iostream>
#include<string>
using namespace std;
int main()
{
const int GOLD=900;
int adventurers, killed, survivors;
string leader;
cout << "請輸入冒險隊長的名字:\n";
cin >> leader;
cout << "請輸入冒險人數:\n";
cin >> adventurers;
cout << "請輸入死亡人數:\n";
cin >> killed;
survivors = adventurers - killed;
cout <<" 這是一隻由" << leader << "帶領的" << adventurers << "人的冒險小隊,";
cout << "他們在一個荒漠裡的地下宮殿尋找到了一個寶箱,沒想到寶箱上面竟然有機關,當開啟箱子的時候,";
cout << "由於大意,箱子上突然射出了" << killed + 1 << "支暗箭" << "雖然有幾個隊員眼疾手快躲了過去,";
cout << "但是,還是有" << killed << "個人被箭射中了,箭上塗有劇毒,這" << killed << "個人當場死亡了。";
cout << "悲傷來的如此突然,一個由" << adventurers << "個人組成的活蹦亂跳的小隊現在只剩下" << survivors << "個人了。";
cout << "大家懷著悲痛的心情埋葬了這" << killed << "個隊友,然後剩下的人小心翼翼開啟寶箱,箱子裡再也沒有其他機關,裡面靜靜躺著";
cout << GOLD << "枚金幣,大家十分高興,然後把金幣分了";
if (GOLD%survivors)
{
cout<<"雖然還剩" << survivors << "個人," << "每人還能分" << GOLD / survivors;
cout << "枚金幣,剩下的" << GOLD%survivors << "枚不好分的金幣,大家把它同死去的隊友埋在了一起。\n";
cout << " 啊,真是一個驚險的的故事啊!\n";
}
else
{
cout << "雖然還剩" << survivors << "個人," << "每人還能分" << GOLD / survivors;
cout << "枚金幣。\n";
cout << " 啊,真是一個驚險的的故事啊!\n";
}
}
#include<iostream>
#include<string>
using namespace std;
int main()
{
const int GOLD=900;
int adventurers, killed, survivors;
string leader;
cout << "請輸入冒險隊長的名字:\n";
cin >> leader;
cout << "請輸入冒險人數:\n";
cin >> adventurers;
cout << "請輸入死亡人數:\n";
cin >> killed;
survivors = adventurers - killed;
cout <<" 這是一隻由" << leader << "帶領的" << adventurers << "人的冒險小隊,";
cout << "他們在一個荒漠裡的地下宮殿尋找到了一個寶箱,沒想到寶箱上面竟然有機關,當開啟箱子的時候,";
cout << "由於大意,箱子上突然射出了" << killed + 1 << "支暗箭" << "雖然有幾個隊員眼疾手快躲了過去,";
cout << "但是,還是有" << killed << "個人被箭射中了,箭上塗有劇毒,這" << killed << "個人當場死亡了。";
cout << "悲傷來的如此突然,一個由" << adventurers << "個人組成的活蹦亂跳的小隊現在只剩下" << survivors << "個人了。";
cout << "大家懷著悲痛的心情埋葬了這" << killed << "個隊友,然後剩下的人小心翼翼開啟寶箱,箱子裡再也沒有其他機關,裡面靜靜躺著";
cout << GOLD << "枚金幣,大家十分高興,然後把金幣分了";
if (GOLD%survivors)
{
cout<<"雖然還剩" << survivors << "個人," << "每人還能分" << GOLD / survivors;
cout << "枚金幣,剩下的" << GOLD%survivors << "枚不好分的金幣,大家把它同死去的隊友埋在了一起。\n";
cout << " 啊,真是一個驚險的的故事啊!\n";
}
else
{
cout << "雖然還剩" << survivors << "個人," << "每人還能分" << GOLD / survivors;
cout << "枚金幣。\n";
cout << " 啊,真是一個驚險的的故事啊!\n";
}
}