商人过河C语言程序编程
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
#include
#include
#include
void basic_interface() //基本界面
{
system("clear");
system("tput cup 5 20");
printf("==========================================
====================================================\n
");
system("tput cup 6 20");
printf("* *\n");
system("tput cup 7 20");
printf("* ^_^欢迎使用商
人过河游戏!^_^
*\n");
system("tput cup 8 20");
printf("* *\n");
system("tput cup 9 20");
printf("* 游戏说明: *\n");
system("tput cup 10 20");
printf("* 三个商人带着三个随从和货物过河,船每次最
多只能载两个人,要求在过河期间,任一岸上商人的人数
*\n");
system("tput cup 11 20");
printf("* 要大于或等于随从的人数,否则随从会杀掉商
人抢走货物。
*\n");
system("tput cup 12 20");
printf("* *\n");
system("tput cup 13 20");
printf("* 游戏操作: *\n");
system("tput cup 14 20 ");
printf("* (1)依次输入过河的商人和随从人
数;
*\n");
system("tput cup 15 20");
printf("* (2)非法输入按键将重新开始。
*\n");
system("tput cup 16 20");
printf("*-----------------------------------------
---------------------------------------------------
*\n");
system("tput cup 17
20");printf("*\n");system("tput cup 17
113");printf("*\n");
system("tput cup 18
20");printf("*\n");system("tput cup 18
113");printf("*\n");
system("tput cup 19
20");printf("*\n");system("tput cup 19
113");printf("*\n");
system("tput cup 20
20");printf("*\n");system("tput cup 20
113");printf("*\n");
system("tput cup 21
20");printf("*\n");system("tput cup 21
113");printf("*\n");
system("tput cup 22
20");printf("*\n");system("tput cup 22
113");printf("*\n");
system("tput cup 23
20");printf("*\n");system("tput cup 23
113");printf("*\n");
system("tput cup 24
20");printf("*\n");system("tput cup 24
113");printf("*\n");
system("tput cup 25
20");printf("*\n");system("tput cup 25
113");printf("*\n");
system("tput cup 26
20");printf("*\n");system("tput cup 26
113");printf("*\n");
system("tput cup 27
20");printf("*\n");system("tput cup 27
113");printf("*\n");
system("tput cup 28 20");
printf("****************************************** ****************************************************\n ");
}
char a[6]; //此岸
char b[6]; //彼岸
void print_state(char a[],char b[]) //打印渡河状态
{
int i,j,ab,aa,ba,bb; //ab 此岸商人数,aa 此岸随从数 bb彼岸商人数,ba,彼岸随从数
aa=ab=ba=bb=0;
basic_interface() ;
system("tput cup 18 40");printf("此岸商人数:\n");
system("tput cup 19 40");printf("此岸随从数:\n");
system("tput cup 18 73");printf("彼岸商人数: \n");
system("tput cup 19 73");printf("彼岸随从数:\n");