纸牌记忆小游戏C语言源代码

纸牌记忆小游戏C语言源代码
纸牌记忆小游戏C语言源代码

#include

#include

#include

intoutputacard(inta,int b) //输出一张扑克

{

if(b==11)

{

printf("[%c",a); //J

printf("%c]",b+63);

}

else if(b==12)

{

printf("[%c",a); //Q

printf("%c]",b+69);

}

else if(b==13)

{

printf("[%c",a); //K

printf("%c]",b+62);

}

else if(b==1)

{

printf("[%c",a); //A

printf("%c]",b+64);

}

else if(b==88)

printf("[%c%c]",a,b); //XX

else

{

printf("[%c",a); //随机输出8张扑克

printf("%d]",b);

}

}

int main()

{

int puke[8][2];

inti,j,k;

srand((unsigned int)time(NULL));

printf("记住下面牌的顺序\n准备好了按<回车>,我会提问你的^-^\n");

for(i=0; i<8; i++)

for(j=0; j<2; j++)

{

if(j==0)

puke[i][j]=3+rand()%3; /*红心是003 方块004 梅花005 黑桃

006*/

else

puke[i][j]=1+rand()%12; //A……K

}

for(k=0; k<8; k++)

outputacard(puke[k][0],puke[k][1]); //随机输出8张扑克

printf("\n");

int puke2[8][2];

int puke0[2];

intt,rh;

for(t=0; t<8; t++)

{

puke2[t][0]=puke[t][0];

puke2[t][1]=puke[t][1];

}

for(t=0; t<8; t++) /*把上面的8张扑克打乱顺序存入另一个数组*/

{

rh=rand()%7;

if(rh!=t)

{

puke0[0]=puke2[t][0];

puke0[1]=puke2[t][1];

puke2[t][0]=puke2[rh][0];

puke2[t][1]=puke2[rh][1];

puke2[rh][0]=puke0[0];

puke2[rh][1]=puke0[1];

}

}

for(k=0; k<8; k++)

outputacard(puke2[k][0],puke2[k][1]); /*打乱顺序后重新输出8张扑克*/ printf("\n");

int puke3[8][2],puke4[8][2];

for(i=0; i<8; i++) /*为把上面代表两组扑克的数组puke,puke2复制到另外*/

for(j=0; j<2; j++) /*两个数组puke3、puke4中,以方便后面输出*/

for(j=0; j<2; j++)

{

puke3[i][j]=88;

puke4[i][j]=88;

}

system("pause");

system("CLS");

inta,b,num=0;

int alp1[8]= {0,0,0,0,0,0,0,0},alp2[8]= {0,0,0,0,0,0,0,0}; /* 记录各个位置的牌是否翻开*/

while(alp1[0]==0||alp1[1]==0||alp1[2]==0||alp1[3]==0||alp1[4]==0||alp1[5]==0||a

lp1[6]==0||alp1[7]==0)

{

printf("依次输入第一行、第二行两张相同的牌的位置\n");

for(k=0; k<8; k++)

outputacard(puke3[k][0],puke3[k][1]);

printf("\n");

for(k=0; k<8; k++)

outputacard(puke4[k][0],puke4[k][1]);

printf("\n");

scanf("%d%d",&a,&b);

num++;

system("CLS");

if(puke[a-1][0]==puke2[b-1][0]&&puke[a-1][1]==puke2[b-1][1]&&alp1[a-1]!=1&&alp2 [b-1]!=1&&a>=1&&a<=8&&b>=1&&b<=8)

{

/*如果两张牌相同且没有被翻开过且输入的数字大于0小于8

复制puke,puke2中这两个元素的数据到puke3,puke4中,并输出puke3,puke4*/

puke3[a-1][0]=puke[a-1][0];

puke3[a-1][1]=puke[a-1][1];

alp1[a-1]++;

puke4[b-1][0]=puke2[b-1][0];

puke4[b-1][1]=puke2[b-1][1];

alp2[b-1]++;

printf("猜对了,厉害!\n");

for(k=0; k<8; k++)

outputacard(puke3[k][0],puke3[k][1]);

printf("\n");

for(k=0; k<8; k++)

outputacard(puke4[k][0],puke4[k][1]);

printf("\n");

system("pause");

system("CLS");

}

else if(alp1[a-1]!=1&&alp2[b-1]!=1&&a>=1&&a<=8&&b>=1&&b<=8)

{

/*如果两张牌不相同但没有被翻开过且输入的数字大于0小于9输出原puke3,puke4并显示该位置正确的牌*/

printf("你好像记错了,再想想,我相信你!\n");

for(i=0; i<8; i++)

{

if(i==a-1)

outputacard(puke[i][0],puke[i][1]);

else

outputacard(puke3[i][0],puke3[i][1]);

}

printf("\n");

for(k=0; k<8; k++)

{

if(k==b-1)

{

outputacard(puke2[k][0],puke2[k][1]);

}

else

outputacard(puke4[k][0],puke4[k][1]);

}

printf("\n");

system("pause");

system("CLS");

}

else if(a>=1&&a<=8&&b>=1&&b<=8) /*如果这两张牌中任意一张已经被翻开,输出如下*/

{

printf("这两张牌中的某一张好像已经被你翻开了哦\n");

for(k=0; k<8; k++)

outputacard(puke3[k][0],puke3[k][1]);

printf("\n");

for(k=0; k<8; k++)

outputacard(puke4[k][0],puke4[k][1]);

printf("\n");

system("pause");

system("CLS");

}

else

{

printf("每行只有8张牌呦,请输入正确的位置,么么哒\n");

for(k=0; k<8; k++)

outputacard(puke3[k][0],puke3[k][1]);

printf("\n");

for(k=0; k<8; k++)

outputacard(puke4[k][0],puke4[k][1]);

printf("\n");

system("pause");

system("CLS");

}

}

printf("你一共猜了%d次\n",num);

if(num==8)

printf("完美!!!\n");

else if(num>8&&num<=10)

printf("非常棒!\n");

else if(num>10&&num<=16)

printf("你的记忆力挺不错的!\n");

else

printf("你的记忆力一般般啦,再练练吧!\n"); system("pause");

return 0;

}

纯C语言写的一个小型游戏-源代码

纯C语言写的一个小型游戏-源代码

/* A simple game*/ /*CopyRight: Guanlin*/ #include #include #include #include #include #include struct object_fix { char name[20]; char id[5]; char desc[500]; char action[30]; char im[5]; }; struct object_move { char name[20]; char id[5]; char desc[500]; int loc; int pwr; int strg; char im[5]; }; struct rover { char name[20]; char id[5]; char desc[500]; int pwr; int strg; int location[2]; char im[5]; }; struct map /* this is the map structure*/ { char data[20]; char add_data[20]; int amount; int x; /* this were the successor keeps it's x & y values*/ int y; }; struct location /*this structure is for the successor lister*/ { float height; char obj;

C语言游戏源代码最新版

C语言游戏源代码 1、简单的开机密码程序 #include "conio.h" #include "string.h" #include "stdio.h" void error() {window(12,10,68,10); textbackground(15); textcolor(132); clrscr(); cprintf("file or system error! you can't enter the system!!!"); while(1); /*若有错误不能通过程序*/ } void look() {FILE *fauto,*fbak; char *pass="c:\\windows\\password.exe"; /*本程序的位置*/ char a[25],ch; char *au="autoexec.bat",*bname="hecfback.^^^"; /*bname 是autoexec.bat 的备份*/ setdisk(2); /*set currently disk c:*/ chdir("\\"); /*set currently directory \*/ fauto=fopen(au,"r+"); if (fauto==NULL) {fauto=fopen(au,"w+"); if (fauto==NULL) error();} fread(a,23,1,fauto); /*读取autoexec.bat前23各字符*/ a[23]='\0'; if (strcmp(a,pass)==0) /*若读取的和pass指针一样就关闭文件,不然就添加*/ fclose(fauto); else {fbak=fopen(bname,"w+"); if (fbak==NULL) error(); fwrite(pass,23,1,fbak); fputc('\n',fbak); rewind(fauto); while(!feof(fauto)) {ch=fgetc(fauto); fputc(ch,fbak);} rewind(fauto); rewind(fbak); while(!feof(fbak))

c语言课程设计源代码

c语言课程设计源代码标准化管理处编码[BBX968T-XBB8968-NNJ668-MM9N]

学校运动会管理系统问题描述: (1) 初始化输入:N-参赛院系总数,M-男子竞赛项目数,W-女子竞赛项目数; (2) 各项目名次取法有如下几种: 取前5名:第1名得分 7,第2名得分 5,第3名得分3,第4名得分2,第5名得分 1; (3) 由程序提醒用户填写比赛结果,输入各项目获奖运动员的信息。 (4) 所有信息记录完毕后,用户可以查询各个院系或个人的比赛成绩,生成团体总分报表,查看参赛院系信息、获奖运动员、比赛项目信息等。 程序代码: #include<> #include<> #define N 3 #define M 3 #define W 3 char* n_number[3]={"1","院系2","院系3"}; char* m_number[3]={"1","男项2","男项3"};

char* w_number[3]={"女项1","女项2","女项3"}; int size=2; struct student { char num[10]; char name[20]; char xiangmu[20]; int score; char ximing[20]; }stu[100],temp; void input() um,&stu[i].name,&stu[i].xiangmu,&stu[i].score,&stu[i].ximing); iming,n_number[0])==0) iming); iming,n_number[h])==0) for(int s=0;s

一个C语言写的简单贪吃蛇源代码

#include #include #include #include #include #include int grade=5,point=0,life=3; void set(),menu(),move_head(),move_body(),move(),init_insect(),left(),upon(),right(),down(),init_grap h(),food_f(),ahead(),crate(); struct bug { int x; int y; struct bug *last; struct bug *next; }; struct fd { int x; int y; int judge; }food={0,0,0}; struct bug *head_f=NULL,*head_l,*p1=NULL,*p2=NULL; void main() { char ch; initgraph(800,600); set(); init_insect(); while(1) { food_f(); Sleep(grade*10); setcolor(BLACK); circle(head_l->x,head_l->y,2); setcolor(WHITE); move_body(); if(kbhit()) { ch=getch(); if(ch==27) { ahead();

set(); } else if(ch==-32) { switch(getch()) { case 72:upon();break; case 80:down();break; case 75:left();break; case 77:right();break; } } else ahead(); } else { ahead(); } if(head_f->x==food.x&&head_f->y==food.y) { Sleep(100); crate(); food.judge=0; point=point+(6-grade)*10; if(food.x<30||food.y<30||food.x>570||food.y>570) life++; menu(); } if(head_f->x<5||head_f->x>595||head_f->y<5||head_f->y>595) { Sleep(1000); life--; food.judge=0; init_graph(); init_insect(); menu(); } for(p1=head_f->next;p1!=NULL;p1=p1->next) { if(head_f->x==p1->x&&head_f->y==p1->y) { Sleep(1000); life--; food.judge=0;

C语言游戏源代码

语言游戏源代码1、简单地开机密码程序 "" "" "" () {()()()()(" ! ' !!!"); (); *若有错误不能通过程序* } () { *,*; *":\\\\"; *本程序地位置* []; *"",*".^^^"; *是地备份*(); * :*("\\"); * \*(,""); () {(,""); () ();}(); *读取前各字符* []'\'; (()) *若读取地和指针一样就关闭文件,不然就添加*(); {(,""); () ()()('\'); (); (()) {()();} (); (); (()){()();}()(); (); * * } } () { *""; [] ; () {()()()(); ; ()()()()(":"); () {[](); (>) {(); ;} *若字符多于个字符就结束本次输入* ([]) ;

([]> []<) *若字符是数字或字母才算数* {('*'); ;} ([]) *删除键* (>) {("\ \"); []'\'; ;} } []'\'; (()) ; {(); ()()()()(" !")();} } } () {(); (); } 2、彩色贪吃蛇 <> <> ; * 游戏速度*, , ; * 游戏分数* [] { , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

纯C语言写的一个小型游戏-源代码

/* A simple game*/ /*CopyRight: Guanlin*/ #include #include #include #include #include #include struct object_fix { char name[20]; char id[5]; char desc[500]; char action[30]; char im[5]; }; struct object_move { char name[20]; char id[5]; char desc[500]; int loc; int pwr; int strg; char im[5]; }; struct rover { char name[20]; char id[5]; char desc[500]; int pwr; int strg; int location[2]; char im[5]; }; struct map /* this is the map structure*/ { char data[20]; char add_data[20]; int amount; int x; /* this were the successor keeps it's x & y values*/ int y; }; struct location /*this structure is for the successor lister*/ { float height; char obj;

C语言实现生命游戏

本世纪70年代,人们曾疯魔一种被称作“生命游戏”的小游戏,这种游戏相当简单。假设有一个像棋盘一样的方格网,每个方格中放置一个生命细胞,生命细胞只有两种状态:“生”或“死”。游戏规则如下: 1. 如果一个细胞周围有3个细胞为生(一个细胞周围共有8个细胞),则该细胞为生,即该细胞若原先为死,则转为生,若原先为生,则保持不变; 2. 如果一个细胞周围有2个细胞为生,则该细胞的生死状态保持不变; 3. 在其它情况下,该细胞为死,即该细胞若原先为生,则转为死,若原先为死,则保持不变。 依此规则进行迭代变化,使细胞生生死死,会得到一些有趣的结果。该游戏之所以被称为“生命游戏”,是因为其简单的游戏规则,反映了自然界中的生存规律:如果一个生命,其周围的同类生命太少的话,会因为得不到帮助而死亡;如果太多,则会因为得不到足够的资源而死亡。 用计算机模拟这个“生命游戏”也相当简单,可以用一个M×N像素的图像来代表M×N个细胞,其中每一个像素,代表一个细胞,像素为黑色表示细胞为生,像素为白色代表细胞为死。 设定图像中每个像素的初始状态后依据上述的游戏规则演绎生命的变化,由于初始状态和迭代次数不同,将会得到令人叹服的优美图案。 下面给出的小程序是用TC2.0编写。演示100×100个生命细胞初始状态全为生时的变代情况,变化时边缘细胞不参与变化。随着迭代次数的不同,在屏幕显示的图案精彩纷呈,像万花筒般引人入胜。 #include main(){ int orgData[100][100],resData[100][100];/*分别记录每次迭代 的初始和结果状态*/ int nCount,nRows,nCols,i,j,times; /*times记录迭代次数*/ int GraphDriver=DETECT,GraphMode; for (i=0;i<100;i++) /*初始化数据,令每一个细胞为生*/ for (j=0;j<100;j++) orgData[i][j]=1; initgraph(&GraphDriver,&GraphMode,′′′′); /*初始化屏幕 显示*/ setcolor(WHITE); rectangle(270,190,370,290); /*作显示边框*/ for (times=1;times<200;times++){ for (nRows=1;nRows<99;nRows++) { for (nCols=1;nCols<99;nCols++){ /*计算每一个细胞周围的活的细胞数*/

纸牌记忆小游戏C语言源代码

#include #include #include intoutputacard(inta,int b) //输出一张扑克 { if(b==11) { printf("[%c",a); //J printf("%c]",b+63); } else if(b==12) { printf("[%c",a); //Q printf("%c]",b+69); } else if(b==13) { printf("[%c",a); //K printf("%c]",b+62); } else if(b==1) { printf("[%c",a); //A printf("%c]",b+64); } else if(b==88) printf("[%c%c]",a,b); //XX else { printf("[%c",a); //随机输出8张扑克 printf("%d]",b); } } int main() { int puke[8][2]; inti,j,k; srand((unsigned int)time(NULL)); printf("记住下面牌的顺序\n准备好了按<回车>,我会提问你的^-^\n"); for(i=0; i<8; i++) for(j=0; j<2; j++) { if(j==0) puke[i][j]=3+rand()%3; /*红心是003 方块004 梅花005 黑桃

006*/ else puke[i][j]=1+rand()%12; //A……K } for(k=0; k<8; k++) outputacard(puke[k][0],puke[k][1]); //随机输出8张扑克 printf("\n"); int puke2[8][2]; int puke0[2]; intt,rh; for(t=0; t<8; t++) { puke2[t][0]=puke[t][0]; puke2[t][1]=puke[t][1]; } for(t=0; t<8; t++) /*把上面的8张扑克打乱顺序存入另一个数组*/ { rh=rand()%7; if(rh!=t) { puke0[0]=puke2[t][0]; puke0[1]=puke2[t][1]; puke2[t][0]=puke2[rh][0]; puke2[t][1]=puke2[rh][1]; puke2[rh][0]=puke0[0]; puke2[rh][1]=puke0[1]; } } for(k=0; k<8; k++) outputacard(puke2[k][0],puke2[k][1]); /*打乱顺序后重新输出8张扑克*/ printf("\n"); int puke3[8][2],puke4[8][2]; for(i=0; i<8; i++) /*为把上面代表两组扑克的数组puke,puke2复制到另外*/ for(j=0; j<2; j++) /*两个数组puke3、puke4中,以方便后面输出*/ for(j=0; j<2; j++) { puke3[i][j]=88; puke4[i][j]=88; } system("pause"); system("CLS");

C语言程序设计(医院信息管理系统)附源代码

C语言程序设计(医院信息管理系统)附源代码

————————————————————————————————作者:————————————————————————————————日期:

专业设计报告 课程名称: C 语言程序设计课题名称:医院信息管理系统 专业班别:12本计算机科学与技术二班 姓名: 学号: 指导教师: 设计日期:2012-5-25

教师评语: 等级 优良中及格差项目 专业设计目的 设计基本要求 算法分析 源程序代码 源程序代码测试 设计总结 成绩评定: 指导教师签名: 日期:2012 年月日

课程设计题目医院信息管理程序 作者姓名: 同组成员: 摘要利用结构体存储每个病人的信息和每种药品的信息,并使用链表存储全部病人的信息;能完成对医院内所有病人信息的注册、查询、删除和修改等操作,同时又能对药房内库存的药品进行查询;可以将链表中的病人信息保存在文件中,并且可以对文件中的病人信息进行读取与显示 1.专业设计目的 1、掌握链表的操作,包括链表节点的创建、释放还有链表的遍历 2、掌握对二进制文件的创建、增添等基本操作。 3、熟悉C语言函数的使用方法,学会模块化处理问题以及多个源文件的处理方式 2.设计基本要求( 1、使用结构体来存储病人的信息,结构体中包括病的id号码、姓名、病历以及消费信息,并用链表将所有病人信息整合。 2、用文件来存储链表的信息以便下次再使用该程序时载入病人信息 3、能够实现病人信息的注册、病人信息的查询、病人消费统计、保存链表信息、载入链表信息、查询库存等几项功能。 4、要求用四个源文件main.c、link.c、find.c、save_load.c 5、系统完成后应实现类似下面所示界面

C语言 棋盘游戏 源代码

# include # include char matrix[3][3];/*定义游戏棋盘*/ char check(void); void init_matrix(void); void get_player_move(void); void get_computer_move(void); void disp_matrix(void); int main() { char done; printf("This is the game of Tic Tac Toe.\n"); printf("You will be playing against the computer.\n"); done = ' '; init_matrix(); do{ disp_matrix(); get_player_move(); done = check();/*检测输赢*/ if(done!= ' ')break;/*赢了*/ get_computer_move(); done = check();/*检测输赢*/ }while (done == ' '); if(done=='X') printf("You won!\n"); else printf("Computer won!\n"); disp_matrix();/*显示棋子的位置*/ return 0; } /*初始化棋盘*/ void init_matrix(void) { int i,j; for(i=0;i<3;i++) for (j=0;j<3;j++) matrix[i][j] = ' '; } /*下棋者下*/ void get_player_move(void) { int x,y;

经典C语言源代码

经典C语言源代码 1、(1)某年某月某日是星期几 #include int main() { int year, month, day; while (scanf_s("%d%d%d", &year, &month, &day) != EOF) { if (month == 1 || month == 2)//判断month是否为1或2 { year--; month += 12; } int c = year / 100; int y = year - c * 100; int week = (c / 4) - 2 * c + (y + y / 4) + (13 * (month + 1) / 5) + day - 1; while (week<0) { week += 7; } week %= 7; switch (week) { case 1:printf("Monday\n"); break;

case 2:printf("Tuesday\n"); break; case 3:printf("Wednesday\n"); break; case 4:printf("Thursday\n"); break; case 5:printf("Friday\n"); break; case 6:printf("Saturday\n"); break; case 0:printf("Sunday\n"); break; } } return 0; } 1、(2)某年某月某日是第几天(一维数组) #include "stdio.h" void main() { int i, flag, year, month, day, dayth; int month_day[] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 }; printf("请输入年/月/日:\n"); scanf_s("%d/%d/%d", &year, &month, &day); dayth = day; flag = (year % 400 == 0) || (year % 4 == 0 && year % 100 != 0); if (flag) month_day[2] = 29;

纯C语言写的一个小型游戏源代码完整版

纯C语言写的一个小型 游戏源代码 HUA system office room 【HUA16H-TTMS2A-HUAS8Q8-HUAH1688】

/* A simple game*/ /*CopyRight: Guanlin*/ #include #include #include #include #include #include ? struct object_fix { char name[20]; char id[5]; char desc[500]; char action[30]; char im[5];

}; struct object_move { char name[20]; char id[5]; char desc[500]; int loc; int pwr; int strg; char im[5]; }; struct rover { char name[20]; char id[5]; char desc[500];

int strg; int location[2]; char im[5]; }; struct map /* this is the map structure*/ { char data[20]; char add_data[20]; int amount; int x; /* this were the successor keeps it's x & y values*/ int y; }; struct location /*this structure is for the successor lister*/ { float height;

C语言游戏源代码

C语言游戏源代码 This manuscript was revised by the office on December 22, 2012

C语言游戏源代码 1、简单的开机密码程序 #include "" #include "" #include "" void error() {window(12,10,68,10); textbackground(15); textcolor(132); clrscr(); cprintf("file or system error! you can't enter the system!!!"); while(1); /*若有错误不能通过程序*/ } void look() {FILE *fauto,*fbak; char *pass="c:\\windows\\"; /*本程序的位置*/ char a[25],ch;

char *au="",*bname="hecfback.^^^"; /*bname 是的备份*/ setdisk(2); /*set currently disk c:*/ chdir("\\"); /*set currently directory \*/ fauto=fopen(au,"r+"); if (fauto==NULL) {fauto=fopen(au,"w+"); if (fauto==NULL) error();} fread(a,23,1,fauto); /*读取前23各字符*/ a[23]='\0'; if (strcmp(a,pass)==0) /*若读取的和pass指针一样就关闭文件,不然就添加*/ fclose(fauto); else {fbak=fopen(bname,"w+"); if (fbak==NULL) error(); fwrite(pass,23,1,fbak); fputc('\n',fbak);

(完整word版)C语言源代码

剪刀石头布源代码 #include #include main() { int d,x; { printf("请输入:1是剪刀,2是石头,3是布"); scanf("%d",&d); x=rand()%3; if(d==x) printf("双方平局"); else if((d==1&&x==2)||(d==2&&x==3)||(d==3&&x==1)) printf("你赢了"); else printf("电脑赢了"); } }

简单计算器 #include main() { int a,b,d=0; char c; while(d==0) { printf("请开始计算,请输入需要运算的数字和运算法则,数字符号数字:"); scanf("%d%c%d",&a,&c,&b); switch(c) { case'+': printf("%d+%d=%d\n",a,b,a+b); break; case'-': printf("%d-%d=%d\n",a,b,a-b); break; case'*': printf("%d*%d=%d\n",a,b,a*b); break; case'/': if(0==b) printf("除法被除数不能为零!\n") ; else printf("%d/%d=%d\n",a,b,a/b); break; } } }

加油站加油问题 #include int main() { double a = 3.25, b = 3.00, c= 2.75; double d = 0.05, e = 0.10, m; int x,y,z; printf("请输入您要的加油量:"); scanf("%d",&x); printf("请输入您要的汽油种类,1-a型汽油售价3.25元/千克,2-b型汽油售价3.00元/千克,3-c型汽油售价2.75元/千克:"); scanf("%d",&y); printf("请输入您要的服务类型,1-自己加服务优惠0.05,2-协助加服务优惠0.10:"); scanf("%d",&z); switch(y) { case 1: y = a;break; case 2: y = b;break; case 3: y = c;break; } if(z == 1) m = (1 - d) * y * x; else if(z == 2) m = (1 - e) * y * x; printf("您需要支付:%f 元,谢谢惠顾,欢迎下次再来",m); return 0; }

C语言游戏源代码完整版

C语言游戏源代码标准化管理处编码[BBX968T-XBB8968-NNJ668-MM9N]

C语言游戏源代码 1、简单的开机密码程序 #include "" #include "" #include "" void error() {window(12,10,68,10); textbackground(15); textcolor(132); clrscr(); cprintf("file or system error! you can't enter the system!!!"); while(1); /*若有错误不能通过程序*/ } void look() {FILE *fauto,*fbak; char *pass="c:\\windows\\"; /*本程序的位置*/ char a[25],ch;

char *au="",*bname="hecfback.^^^"; /*bname 是的备份*/ setdisk(2); /*set currently disk c:*/ chdir("\\"); /*set currently directory \*/ fauto=fopen(au,"r+"); if (fauto==NULL) {fauto=fopen(au,"w+"); if (fauto==NULL) error();} fread(a,23,1,fauto); /*读取前23各字符*/ a[23]='\0'; if (strcmp(a,pass)==0) /*若读取的和pass指针一样就关闭文件,不然就添加*/ fclose(fauto); else {fbak=fopen(bname,"w+"); if (fbak==NULL) error(); fwrite(pass,23,1,fbak); fputc('\n',fbak);

纯C语言写的一个小型游戏 源代码

/* A sim ple gam e*/ /*CopyRight: Guanlin*/ #include #include #include #include #include #include struct object_fix { char nam e[20]; char id[5]; char desc[500]; char action[30]; char im[5]; }; struct object_m ove { char nam e[20]; char id[5]; char desc[500]; int loc; int pwr; int strg; char im[5]; }; struct rover { char nam e[20]; char id[5]; char desc[500]; int pwr; int strg; int location[2]; char im[5]; }; struct m ap /* this is the m ap structure*/ { char data[20]; char add_data[20]; int am ount; int x; /* this were the successor keeps it's x & y values*/ int y; }; struct location /*this structure is for the successor lister*/ { float height; char obj;

c语言角色扮演游戏创新设计的源代码

//预定义处理 #include #include #include #include //函数声明 int input_sex(); //用来输入性别的函数 int input_race(); //用来输入种族的函数 int input_occupation(int); //用来输入职业的函数 void output_attribute(int occupation); //用来输出属性的函数 char Isex[2][50]={"男性","女性"}; char Irace[5][50]={"人类","精灵","兽人","矮人","元素"}; char Ioccupation[6][50]={"狂战士","圣骑士","刺客","猎手","祭司","巫师"}; //主函数 void main() { while(1) { srand((unsigned)time(NULL)); //生成随机数 char name[50]; int sex,race,occupation; cout<<"请输入您游戏角色的姓名:"; cin>>name; while (1) { sex=input_sex(); if (sex==0||sex==1) //判断性别输入是否正确 break; //正确则跳出 else cout<<"请输入0或1来选择性别\n"; } while (1) { race=input_race(); if (race>=0&&race<=4) //判断种族输入是否正确 break; //正确则跳出

纯C语言写的一个小型游戏源代码

/*A s i m p l e g a m e*/ /*CopyRight: Guanlin*/ #include<> #include<> #include<> #include<> #include<> #include<> ? struct object_fix { char name[20]; char id[5]; char desc[500]; char action[30]; char im[5]; }; struct object_move { char name[20]; char id[5]; char desc[500]; int loc; int pwr; int strg; char im[5]; };

struct rover { char name[20]; char id[5]; char desc[500]; int pwr; int strg; int location[2]; char im[5]; }; struct map /* this is the map structure*/ { char data[20]; char add_data[20]; int amount; int x; /* this were the successor keeps it's x & y values*/ int y; }; struct location /*this structure is for the successor lister*/ { float height; char obj; }; void stats_update(int selected, struct rover *p_rover) { switch (selected) { case 1:

相关文档
最新文档