田忌赛马C++程序源代码 不用class的

田忌赛马C++程序源代码 不用class的,第1张

#include <iostream>

#include <string>

#include <vector>

#include <algorithm>

#include <time.h>

const std::string GetGongziHorse(std::vector<std::string>& horse)

{

int size = horse.size()

int choose = rand()%size

std::string horseChoosed = horse[choose]

std::vector<std::string>::iterator it 

= find(horse.begin(), horse.end(), horseChoosed)

horse.erase(it)

return horseChoosed

}

const std::string GetTianjiHorse(const std::string& horseChoosed)

{

if (strcmp(horseChoosed.c_str(), "千里马") == 0)

return "劣马"

else if (strcmp(horseChoosed.c_str(), "好马") == 0)

return "千里马"

else

return "好马"

}

int main(void)

{

srand(time(NULL))

std::string strHorse[] = {"千里马", "好马", "劣马"}

std::vector<std::string> horseGongzi

horseGongzi.insert(horseGongzi.end(), strHorse, strHorse + 3)

int i = 1

while(horseGongzi.size())

{

std::string horseChoosed = GetGongziHorse(horseGongzi)

std::cout << "第" << i << "场" << std::endl

std::cout << "虚空公子派出了:" << horseChoosed << std::endl

std::cout << "田忌派出了:" 

                  <<  GetTianjiHorse(horseChoosed) << std::endl

i++

std::cout << std::endl

}

std::cout << "田忌无耻的赢了" << std::endl

getchar()

return 0 

}

原因是电瓶与车子接触不良,导致熔断丝管烧坏、电池触点或插头接触不良、电池线虚焊断路等。建议及时检查汽车的电路情况。电瓶使用的时间太长容易导致电瓶老化,电池电压不足以启动启动机就无法启动引擎


欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/zaji/7067285.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-01
下一篇 2023-04-01

发表评论

登录后才能评论

评论列表(0条)

保存