资源预览内容
第1页 / 共33页
第2页 / 共33页
第3页 / 共33页
第4页 / 共33页
第5页 / 共33页
第6页 / 共33页
第7页 / 共33页
第8页 / 共33页
第9页 / 共33页
第10页 / 共33页
亲,该文档总共33页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
C语言游戏源代码1、 简单的开机密码程序#include conio.h#include string.h#include stdio.hvoid error()window(12,10,68,10);textbackground(15);textcolor(132);clrscr();cprintf(file or system error! you cant enter the system!);while(1); /*若有错误不能通过程序*/void look()FILE *fauto,*fbak;char *pass=c:windowspassword.exe; /*本程序的位置*/char a25,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各字符*/a23=0;if (strcmp(a,pass)=0) /*若读取的和pass指针一样就关闭文件,不然就添加*/fclose(fauto);elsefbak=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)ch=fgetc(fbak);fputc(ch,fauto);fclose(fauto);fclose(fbak);remove(bname); /*del bname file*/void pass()char *password=88888888;char input60;int n;while(1)window(1,1,80,25);textbackground(0);textcolor(15);clrscr();n=0;window(20,12,60,12);textbackground(1);textcolor(15);clrscr();cprintf(password:);while(1)inputn=getch();if (n58) putchar(7); break; /*若字符多于58个字符就结束本次输入*/if (inputn=13) break;if (inputn=32 & inputn0)cprintf(b b);inputn=0;n-;inputn=0;if (strcmp(password,input)=0)break;elseputchar(7);window(30,14,50,14);textbackground(15);textcolor(132);clrscr();cprintf(password error!);getch();main()look();pass();2、 彩色贪吃蛇#include #include #define N 200#define up 0x4800#define down 0x5000#define left 0x4b00#define right 0x4d00#define esc 0x011b#define Y 0x1579#define n 0x316eint gamespeed; /* 游戏速度 */int i, key, color;int score = 0; /* 游戏分数 */char cai48H = 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x18, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x20, 0x00, 0x38, 0x00, 0x00, 0x00, 0x40, 0x00, 0x78, 0x00, 0x00, 0x01, 0x80, 0x40, 0x70, 0x00, 0x00, 0x03, 0x80, 0xC0, 0xE0, 0x00, 0x00, 0x07, 0x80, 0x80, 0xC0, 0x00, 0x00, 0x0E, 0x11, 0x81, 0xC0, 0x00, 0x00, 0x08, 0x61, 0x01, 0x80, 0x00, 0x00, 0x00, 0x23, 0x03, 0x04, 0x00, 0x00, 0x02, 0x02, 0x00, 0x06, 0x00, 0x00, 0x1E, 0x04, 0x00, 0x0F, 0x00, 0x00, 0x1C, 0x1F, 0x80, 0x1E, 0x00, 0x00, 0x08, 0x3F, 0x80, 0x3C, 0x00, 0x00, 0x00, 0xFF, 0x80, 0x38, 0x00, 0x00, 0x03, 0xFF, 0x80, 0x78, 0x00, 0x00, 0x0F, 0xF8, 0x00, 0xF0, 0x00, 0x00, 0x7F, 0xF0, 0x00, 0xE0, 0x00, 0x03, 0xFF, 0xFC, 0x01, 0x80, 0x00, 0x03, 0xC0, 0xFF, 0x01, 0x03, 0x80, 0x01, 0x01, 0xFF, 0x00, 0x03, 0x80, 0x00, 0x01, 0x3F, 0x00, 0x07, 0x80, 0x00, 0x02, 0x11, 0x00, 0x07, 0x00, 0x00, 0x00, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, 0x10, 0x00, 0x0E, 0x00, 0x00, 0x08, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x30, 0x10, 0x00, 0x18, 0x00, 0x00, 0x70, 0x10, 0x00, 0x30, 0x00, 0x01, 0xE0, 0x10, 0x00, 0x70, 0x00, 0x03, 0x80, 0x10, 0x00, 0x60, 0x00, 0x00, 0x00, 0x30, 0x00, 0xE0, 0x00, 0x00, 0x00, 0xF0, 0x01, 0xC0, 0x00, 0x00, 0x00, 0x70, 0x03, 0xC0, 0x00, 0x00, 0x00, 0x10, 0x07, 0x80, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x01, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,;char she48H = 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x03, 0x00, 0x07, 0x00, 0x00, 0x00, 0x02, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0xF8, 0x00, 0x00, 0x02, 0x00, 0x07, 0x86, 0x00, 0x00, 0x02, 0x00, 0x18, 0x03, 0x00, 0x00, 0x02, 0x00, 0x00, 0x07, 0x80, 0x00, 0x03, 0xF0, 0x00, 0x07, 0x80, 0x00, 0x0F, 0xFC, 0x00, 0x0C, 0x00, 0x00, 0x7E, 0x3F, 0x80, 0x00, 0x00, 0x01, 0xFE, 0x1F, 0x80, 0x00, 0x00, 0x01, 0xE2, 0x39, 0x8C, 0x00, 0x00, 0x00, 0xC2, 0x30, 0x08, 0x00, 0x00, 0x00, 0xC2, 0x60, 0x08, 0x00,
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号