您好,欢迎访问三七文档
1C语言游戏源代码1、简单的开机密码程序#includeconio.h#includestring.h#includestdio.hvoiderror(){window(12,10,68,10);textbackground(15);textcolor(132);clrscr();cprintf(fileorsystemerror!youcan'tenterthesystem!!!);while(1);/*若有错误不能通过程序*/}voidlook(){FILE*fauto,*fbak;char*pass=c:\\windows\\password.exe;/*本程序的位置*/chara[25],ch;char*au=autoexec.bat,*bname=hecfback.^^^;/*bname是autoexec.bat的备份*/setdisk(2);/*setcurrentlydiskc:*/chdir(\\);/*setcurrentlydirectory\*/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))2{ch=fgetc(fbak);fputc(ch,fauto);}fclose(fauto);fclose(fbak);remove(bname);/*delbnamefile*/}}voidpass(){char*password=;charinput[60];intn;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){input[n]=getch();if(n58){putchar(7);break;}/*若字符多于58个字符就结束本次输入*/if(input[n]==13)break;if(input[n]=32&&input[n]=122)/*若字符是数字或字母才算数*/{putchar('*');n++;}if(input[n]==8)/*删除键*/if(n0){cprintf(\b\b);input[n]='\0';n--;}}input[n]='\0';if(strcmp(password,input)==0)break;else{putchar(7);window(30,14,50,14);textbackground(15);textcolor(132);clrscr();3cprintf(passworderror!);getch();}}}main(){look();pass();}2、彩色贪吃蛇#includegraphics.h#includestdlib.h#defineN200#defineup0x4800#definedown0x5000#defineleft0x4b00#defineright0x4d00#defineesc0x011b#defineY0x1579#definen0x316eintgamespeed;/*游戏速度*/inti,key,color;intscore=0;/*游戏分数*/charcai48H[]={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,40xFF,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,};charshe48H[]={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,0x00,0x00,0xC3,0xE0,0x08,0x60,0x00,0x00,0x7F,0xE0,0x01,0xE0,0x00,0x00,0x3F,0x80,0x1F,0xE0,0x00,0x00,0x1E,0x00,0x1F,0x80,0x00,0x00,0x1E,0x00,0x1F,0x00,0x00,0x00,0x02,0x38,0x1E,0x00,0x00,0x00,0x07,0xFC,0x1C,50x00,0x20,0x00,0x07,0xFC,0x18,0x00,0x20,0x00,0x1F,0x0C,0x10,0x00,0x20,0x00,0x7C,0x04,0x10,0x00,0x60,0x01,0xF0,0x00,0x10,0x00,0x60,0x01,0xE0,0x00,0x08,0x00,0xF0,0x00,0x80,0x00,0x08,0x03,0xF0,0x00,0x00,0x00,0x07,0xFF,0xF0,0x00,0x00,0x00,0x07,0xFF,0xF0,0x00,0x00,0x00,0x03,0xFF,0xE0,0x00,0x00,0x00,0x01,0xFF,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,0x00,0x00,0x00,0x00,};chartun48H[]={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,0x0E,0x00,0x00,0x00,0x00,0x00,0x3E,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x00,0x00,0x00,0x00,0xE0,0x00,0x00,0x00,0x00,0x03,0xC0,0x00,0x00,0x00,0x00,0x1
本文标题:C语言游戏源代码
链接地址:https://www.777doc.com/doc-6050250 .html