C语言是一种计算机程序设计语言。它既具有高级语言的特点,又具有汇编语言的特点。它由美国贝尔研究所的DMRitchie于1972年推出。1978后,C语言已先后被移植到大、中、小及微型机上。它可以作为工作系统设计语言,编写系统应用程序,也可以作为应用程序设计语言,编写不依赖计算机硬件的应用程序。它的应用范围广泛,具备很强的数据处理能力,不仅仅是在软件开发上,而且各类科研都需要用到C语言,适于编写系统软件,三维,二维图形和动画。具体应用比如单片机以及嵌入式系统开发。
1. C是高级语言。它把高级语言的基本结构和语句与低级语言的实用性结合起来。C 语言可以像汇编语言一样对位、字节和地址进行 *** 作,而这三者是计算机最基本的工作单元。
2.C是结构式语言。结构式语言的显著特点是代码及数据的分隔化,即程序的各个部分除了必要的信息交流外彼此独立。这种结构化方式可使程序层次清晰,便于使用、维护以及调试。C 语言是以函数形式提供给用户的,这些函数可方便的调用,并具有多种循环、条件语句控制程序流向,从而使程序完全结构化。
3.C语言功能齐全。具有各种各样的数据类型,并引入了指针概念,可使程序效率更高。而且计算功能、逻辑判断功能也比较强大,可以实现决策目的的游戏。
4. C语言适用范围大。适合于多种 *** 作系统,如Windows、DOS、UNIX等等;也适用于多种机型。
C语言对编写需要硬件进行 *** 作的场合,明显优于其它高级语言,有一些大型应用软件也是用C语言编写的。
学c语言可以用的软件推荐如下:
1、TurboC是由美国Borland公司开发的一套C语言程序开发工具,Borland公司是一家专门从事软件开发、研制的大公司。该公司相继推出了一套Turbo系列软件,如TurboBASIC、TurboPascal、TurboProlog,这些软件很受用户欢迎。TurboC集成了程序编辑、调试、链接等多种功能。
2、WIN-TC是一个TC2WINDOWS平台开发工具。该软件使用TC2为内核,提供WINDOWS平台的开发界面,因此也就支持WINDOWS平台下的功能,例如剪切、复制、粘贴和查找替换等。
1C语言编程软件有哪些。
Mcrosoft Visual C++ 、Microsoft Visual Studio、 DEV C++、Code::Blocks、Borland C++、WaTCom C++、Borland C++ Builder、GNU DJGPP C++、Lccwin32 C Compiler31、High C、Turb C、gcc、C-Free和Win-TC、My Tc等等,由于C语言比较成熟,所以编程环境很多。
2C语言入门,不推荐使用VC,因为VC不但庞大,而且应用开发比较高级。入门编程荐使用Dev-C 和 WIN-TC。
1)WIN-TC,该软件使用TC2为内核,提供WINDOWS平台的开发界面,因此也就支持WINDOWS平台下的功能,例如剪切、复制、粘贴和查找替换等。而且在功能上也有它的独特特色例如语法加亮、C内嵌汇编、自定义扩展库的支持等。并提供一组相关辅助工具令你在编程过程中更加游刃有余。
2)Dev-C ,Dev-C 是一个Windows下的C和C 程序的集成开发环境。它使用MingW32/GCC编译器,遵循C/C 标准。开发环境包括多页面窗口、工程编辑器以及调试器等,在工程编辑器中集合了编辑器、编译器、连接程序和执行程序,提供高亮度语法显示的,以减少编辑错误,还有完善的调试功能,能够适合初学者与编程高手的不同需求,是学习C或C的首选开发工具。
C语言是一门通用计算机编程语言,应用广泛
C语言的设计目标是提供一种能以简易的方式编译、处理低级存储器、产生少量的机器码以及不需要任何运行环境支持便能运行的编程语言
软件开发是根据用户要求建造出软件系统或者系统中的软件部分的过程
软件开发是一项包括需求捕捉、需求分析、设计、实现和测试的系统工程
软件一般是用某种程序设计语言来实现的
通常采用软件开发工具可以进行开发
软件分为系统软件和应用软件,并不只是包括可以在计算机上运行的程序,与这些程序相关的文件一般也被认为是软件的一部分
软件设计思路和方法的一般过程,包括设计软件的功能和实现的算法和方法、软件的总体结构设计和模块设计、编程和调试、程序联调和测试以及编写、提交程序
要用C语言编写一个窗体应用程序需要调用系统或第三方提供的API函数,一般的步骤是:
定义窗口类
注册窗口类
创建窗口
显示、更新窗口
进行消息循环,不断处理窗口消息
C语言做游戏
点灯游戏(把灯都打开变黄):
#include <conioh>
#include <stdioh>
#include <stdlibh>
#include <timeh>
int j[8][6][6]={
0,0,0,0,0,0,0,1,1,0,1,1,0,1,0,1,0,1,0,0,1,1,1,0,0,1,0,1,0,1,0,1,1,0,1,1,
0,0,0,0,0,0,0,0,1,0,1,0,0,1,1,0,1,1,0,0,1,0,1,0,0,1,0,1,0,1,0,1,0,1,0,1,
0,0,0,0,0,0,0,1,1,0,1,1,0,0,0,0,0,0,0,1,1,0,1,1,0,0,0,0,0,1,0,1,1,0,0,0,
0,0,0,0,0,0,0,1,0,0,0,1,0,1,1,0,1,1,0,0,0,1,0,0,0,1,0,1,0,0,0,1,0,1,1,0,
0,0,0,0,0,0,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,
0,0,0,0,0,0,0,1,1,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,1,1,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,1,1,1,1,1,0,0,1,1,1,0,0,0,0,0,0,0
},x,y,s,i,h=0,r=0,n;
pr(int u)
{ int g,f;
for (g=1;g<=5;g++)
for (f=1;f<=5;f++)
if (j[u][g][f]==1)
{gotoxy(f,g); textcolor(1); putch('o');}
else {gotoxy(f,g); textcolor(14); putch('o');}
}
hkg(int t,int y)
{ if (j[h][t][y]==1) {j[h][t][y]=0;}
else {j[h][t][y]=1;}
}
kg()
{ int e,r;
hkg(y,x); hkg(y-1,x); hkg(y,x+1); hkg(y+1,x); hkg(y,x-1); pr(h);
}
inkey()
{ char o;
if (kbhit()) {
o=getch();
if (o==27) {exit(0);}
if (o==13) {
kg(); r++;
gotoxy(7,5); printf("Bu Shu: %d",r);
if (r>=299) {over(); getch(); exit(0);}
}
if (o==0) {
o=getch();
if (o==72&&y>1) {y--;}
if (o==77&&x<5) {x++;}
if (o==80&&y<5) {y++;}
if (o==75&&x>1) {x--;}
}
}
}
test()
{ int o,p,k=0;
for (o=1;o<=5;o++)
for (p=1;p<=5;p++)
if (j[h][o][p]==1) {k=1;}
if (k==0)
{gotoxy(7,3); printf("Ni Ying Le! An Jian Ji Xu"); getch(); h++; pr(h);
gotoxy(7,3); printf(" ");
textcolor(10); gotoxy(3,7); printf("Di %d Guan",h+1);
}
}
over()
{ int v,b;
for (v=1;v<=24;v++)
for (b=1;b<=40;b++)
{gotoxy(b,v); textcolor(v); putch(219); delay(1000);}
for (v=1;v<=40;v++)
for (b=1;b<=24;b++)
{gotoxy(v,b); textcolor(v); putch(219); delay(1000);}
gotoxy(20,12); printf("Ni Shu Le!");
}
zai()
{ int g,h,y; gotoxy(15,10); printf("Zai Ru");
gotoxy(15,15); printf("Zai Ru : Dong Hua ");
for (g=10;g<=15;g++)
{gotoxy(g,12); textcolor(2); putch(219);
for (h=1;h<=5;h++) delay(g10000000);
gotoxy(19,17); printf("%d%",(g-10)5);}
gotoxy(15,15); printf("Zai Ru : Di Tu ");
for (g=16;g<=25;g++)
{gotoxy(g,12); textcolor(2); putch(219);
for (h=1;h<=5;h++) delay(g10000000);
gotoxy(19,17); printf("%d%",(g-10)5);}
gotoxy(15,15); printf("Zai Ru : Tu Xing He Zi Ti");
for (g=26;g<=30;g++)
{gotoxy(g,12); textcolor(2); putch(219);
for (h=1;h<=5;h++) delay(g10000000);
gotoxy(19,17); printf("%d%",(g-10)5);}
for (y=1;y<=5;y++) delay(10000);
}
main()
{ textmode(C40); randomize(); clrscr(); zai(); clrscr(); textcolor(10);
gotoxy(7,5); printf("Bu Shu: %d",0);
gotoxy(3,7); printf("Di %d Guan",h+1);
for (i=1;i<=n;i++) {
do {x=rand()%5+1; y=rand()%5+1;} while (j[h][y][x]==1);
j[h][y][x]=1;
} pr(h); x=1; y=1;
while (1)
{ inkey(); gotoxy(x,y); test();
}
getch();
}
作者: 54qiuwenda
2008-7-26 12:17 回复此发言
--------------------------------------------------------------------------------
3 回复:C语言做游戏
走迷宫(用工具走到):
#include <conioh>
#include <timeh>
#include <stdlibh>
#include <stdioh>
main()
{ int map[20][20]={1,1,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
1,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,7,
1,0,1,0,0,0,0,0,0,0,0,1,1,1,1,0,1,1,0,7,
1,0,1,1,1,1,3,3,1,1,0,1,0,0,1,0,0,1,0,7,
1,0,0,0,1,2,4,2,0,1,0,1,1,0,1,0,0,1,1,7,
1,0,0,0,1,2,1,2,1,1,0,0,1,0,1,2,1,1,2,7,
1,0,1,1,1,0,1,2,2,2,2,1,1,0,2,2,1,2,2,7,
1,0,1,0,0,0,1,2,1,2,2,1,1,0,1,2,2,2,2,7,
1,0,1,1,1,0,1,2,1,2,2,1,0,0,1,1,2,1,2,7,
1,0,0,0,1,0,1,2,1,2,2,1,0,1,1,0,2,1,2,7,
1,0,1,0,0,0,1,2,1,1,0,1,0,0,0,0,2,1,2,7,
1,0,1,1,1,1,1,2,2,3,0,1,1,1,1,2,2,1,2,7,
1,0,0,0,2,2,2,2,8,1,0,0,1,2,2,2,1,1,2,7,
1,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,2,7,
1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,1,2,7,
1,2,1,1,1,1,0,0,1,1,1,1,2,2,1,2,2,2,2,7,
1,2,1,6,0,1,0,0,0,0,0,2,2,2,1,2,1,1,1,7,
1,2,1,1,5,1,1,1,1,1,1,2,2,2,1,2,1,2,0,7,
1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,0,9,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}
,x,y,q,w,
z[5][2]={{-1,0},{0,1},{1,0},{0,-1},{0,0}},l=4,s=0,d=0,j,i,u=0;
char o;
textmode(C40); randomize(); q=2; w=2; clrscr();
while (1) {
gotoxy(22,3); printf("D: ChuanQiang");
gotoxy(22,4); printf("(CrossWall)");
gotoxy(22,6); putch(219); printf(": QiangBi(Wall)");
gotoxy(22,8); printf("=: Shui(Water)");
gotoxy(22,10); printf("F: ShuiShang");
gotoxy(22,11); printf("FeiXing(FlyOn");
gotoxy(22,12); printf("Water)");
gotoxy(22,14); printf("/: Men(Door)");
gotoxy(22,16); printf(": BaoZang");
gotoxy(22,17); printf("(Treasure)");
gotoxy(22,19); printf("Esc:TuiChu(Exit)");
for (y=0;y<20;y++) {
for (x=0;x<20;x++) {
if (map[y][x]==1||map[y][x]==7) {gotoxy(x+1,y+1); putch(219);}
if (map[y][x]==9) {gotoxy(x+1,y+1); putch('');}
if (map[y][x]==3) {gotoxy(x+1,y+1); putch(219);}
if (map[y][x]==2) {gotoxy(x+1,y+1); putch('=');}
if (map[y][x]==5) {gotoxy(x+1,y+1); putch('/');}
if (map[y][x]==8) {gotoxy(x+1,y+1); putch('8');}
if (map[y][x]==4) {gotoxy(x+1,y+1); putch('F');}
if (map[y][x]==6) {gotoxy(x+1,y+1); putch('D');}
}
}
if (kbhit()) {
o=getch();
if (o==27) {exit(0);}
if (o==72) {l=0;}
if (o==77) {l=1;}
if (o==80) {l=2;}
if (o==75) {l=3;}
j=map[q-1+z[l][0]][w-1+z[l][1]];
if (j!=0&&j!=4&&j!=8&&j!=3&&j!=s2&&j!=9&&j!=6&&j!=u1&&j!=7)
{l=4;}
gotoxy(w,q); putch(' ');
gotoxy(22,22); for (i=1;i<=18;i++) putch(' ');
q=q+z[l][0]; w=w+z[l][1]; l=4;
if (j==4) {map[q-1][w-1]=0; s=1; gotoxy(35,10); printf(" /");
gotoxy(35,11); printf(" \\/");}
if (j==8) {map[q-1][w-1]=0; map[17][4]=0; gotoxy(5,18); putch(' ');
gotoxy(35,14); printf(" /"); gotoxy(35,15); printf(" \\/");}
if (j==3) {gotoxy(22,22); printf("AnMen(SecretDoor)");}
if (j==6) {map[q-1][w-1]=0; u=1; gotoxy(4,16); putch(' ');
gotoxy(35,3); printf(" /"); gotoxy(35,4); printf(" \\/");}
} gotoxy(w,q); putch(178);
if (map[q-1][w-1]==9)
{gotoxy(10,23); printf("You won! Very good!"); gotoxy(35,16);
printf(" /"); gotoxy(35,17); printf(" \\/"); break;}
delay(8000);
}
getch();
}
贪吃蛇(上下左右移动吃食物):
#include <stdioh>
#include <conioh>
#include <stdlibh>
#include <timeh>
int x=5,y=2,r=1,mx[4]={0,1,0,-1},my[4]={-1,0,1,0},s[40][3],u=5,g=1,
map[40][24]={0},score=0;
boxx(int x1,int y1,int x2,char c)
{ int j;
for (j=x1;j<=x2;j++) {gotoxy(j,y1); putch©;}
}
boxy(int x1,int y1,int y2,char c)
{ int j;
for (j=y1;j<=y2;j++) {gotoxy(x1,j); putch©;}
}
inkey()
{ char o;
randomize();
if (kbhit()) {
o=getch();
if (o==27) {exit(0);}
if (o==0) {
o=getch();
if (o==72) r=0;
if (o==77) r=1;
if (o==80) r=2;
if (o==75) r=3;
}
}
x=x+mx[r]; y=y+my[r];
if (x<2||x>39) {x=x-mx[r];}
if (y<2||y>23) {y=y-my[r];}
gotoxy(x,y); putch(178); p(u); if (map[x][y]==1) {score++;
gotoxy(20,1); printf("Score : %d",score); map[x][y]=0;
u++; s[u][1]=s[u-1][1]; s[u][2]=s[u-1][2];
}
gotoxy(s[g][1],s[g][2]); putch(' ');
s[g][1]=x; s[g][2]=y; g=g++;
if (g>u) g=1;
}
p(int h)
{int z; for (z=1;z<=h;z++) {gotoxy(s[z][1],s[z][2]); putch(178);}
}
egg()
{int ex,ey,h;
for (h=1;h<=30;h++){ex=rand()%38+2; ey=rand()%22+2;
map[ex][ey]=1; gotoxy(ex,ey); putch('O');}
}
main()
{ randomize();
textmode(C40); textcolor(rand()%16);
s[1][1]=2; s[1][2]=2; s[2][1]=3; s[2][2]=2; s[3][1]=4;
s[3][2]=2; s[4][1]=5; s[4][2]=2; s[5][1]=6; s[5][2]=2;
boxx(1,1,40,219); boxx(1,24,40,219);
boxy(1,1,24,219); boxy(40,1,24,219); egg();
gotoxy(20,1); printf("Score : %d",score);
while (1) {
gotoxy(x,y); putch(' ');
inkey();
delay(30000); delay(30000);
}
getch();
}
猫捉老鼠(躲开猫吃食物):
#include<stdioh>
#include<conioh>
#include<stdlibh>
#include<timeh>
main()
{ int cx,cy,x,y,xx,yy,fx,fy,n,kb,r=0,p,o,g=0,sc=0; int set[25][41]={0};
int mx[2][5]={{0,1,0,-1,0},{0,2,0,-2,0}},
my[2][5]={{0,0,-1,0,1},{0,0,-2,0,2}};
clrscr(); textmode(C40); randomize(); n=0;
while (n<50) { do{ fx=rand()%38+2; fy=rand()%22+2;} while(set[fy][fx]!=0);
set[fy][fx]=1; gotoxy(fx,fy); putch(''); n++;} n=3;
while (n) { do{ fx=rand()%38+2;fy=rand()%22+2;} while (set[fy][fx]!=0);
set[fy][fx]=2; gotoxy(fx,fy); putch('o'); n--;}
gotoxy(2,2); cx=2; cy=2; putch('&');
for (x=1;x<=40;x++) {gotoxy(x,1); putch(219); gotoxy(x,24); putch(219);
if (x<=24) {gotoxy(1,x); putch(219); gotoxy(40,x); putch(219);}}
gotoxy(15,1); printf("Score: %d",sc);
gotoxy(39,23); putch('@'); x=39; y=23;
gotoxy(40,8); putch(' '); gotoxy(1,16); putch(' ');
while (1)
{ if (kbhit()) { kb=getch(); if (kb==27) exit(0); kb=getch();
if (x==40&&y==8) {
if (kb==75)
{gotoxy(x,y); putch(' '); x=x-1; gotoxy(x,y); putch('@');}
if (kb==77)
{gotoxy(x,y); putch(' '); x=2; gotoxy(x,y); putch('@');}
}
if (x==1&&y==16) {
if (kb==75)
{gotoxy(x,y); putch(' '); x=39; gotoxy(x,y); putch('@');}
if (kb==77)
{gotoxy(x,y); putch(' '); x=x+1; gotoxy(x,y); putch('@');}
}
if (kb==77&&y==8&&x==39) {gotoxy(x,y); putch(' ');
x=x+1; gotoxy(x,y); putch('@');} else
if (kb==75&&y==16&&x==2) {gotoxy(x,y); putch(' ');
x=x-1; gotoxy(x,y); putch('@');} else
{if (kb==77&&x<39) r=1; else if (kb==72&&y>2) r=2; else
if (kb==75&&x>2) r=3; else if (kb==80&&y<23) r=4; else r=0;
gotoxy(x,y); putch(' '); xx=x+mx[0][r]; yy=y+my[0][r];
if (g==0) {x=x+mx[0][r]; y=y+my[0][r];} else
{x=x+mx[1][r]; y=y+my[1][r]; g=g-1;
gotoxy(3,1); printf("Gao neng:%d",g); putch(219);}
if ((x==39&&kb==77)||(x==38&&kb==77&&g>0)) x=2;
if ((y==2&&kb==72)||(y==3&&kb==72&&g>0)) y=23;
if ((x==2&&kb==75)||(x==3&&kb==75&&g>0)) x=39;
if ((y==23&&kb==80)||(y==22&&kb==80&&g>0)) y=2;
gotoxy(x,y); putch('@'); if (set[y][x]==1||set[yy][xx]==1)
{gotoxy(15,1); printf("Score: %d",sc+1); sc=sc+1; set[y][x]=0;
gotoxy(xx,yy); putch(' '); gotoxy(x,y); putch('@');} else
if (set[y][x]==2||set[yy][xx]==2)
{gotoxy(3,1); printf("Gao neng:%d",g+10); putch(219); g=g+10;
set[y][x]=0; set[yy][xx]=0;}
if (g==0) { gotoxy(3,1); for (n=1;n<=11;n++) putch(219);}}
if (sc==20) break; if (x==cx&&y==cy) break;}
if ((x==40&&y==8)||(x==1&&y==16)) {} else {
gotoxy(cx,cy); if (set[cy][cx]==1) putch(''); else putch(' ');
if (cx<x) cx=cx+1; if (cx>x) cx=cx-1;
if (cy<y) cy=cy+1; if (cy>y) cy=cy-1;
gotoxy(cx,cy); putch('&'); delay(10000); if (x==cx&&y==cy) break;}
}
if (cx==x&&cy==y) {gotoxy(15,3); printf("The cat win!");} else
if (sc>=20) {gotoxy(15,3); printf("The mouse(you) win!");}
getch();
}
俄罗斯方块(移动方块消行):
#include <stdioh>
#include <stdlibh>
#include <timeh>
#include <conioh>
int x[8][4]={0,0,0,0,
0,1,2,0,
0,1,-1,0,
0,0,0,0,
0,0,1,2,
0,1,0,1,
0,-1,0,1,
0,1,0,-1};
int y[8][4]={0,0,0,0,
0,0,0,-1,
0,0,0,-1,
0,1,2,3,
0,1,0,0,
0,0,1,1,
0,0,1,1,
0,0,1,1};
int fxj[4]={0,1,0,-1},fyj[4]={-1,0,1,0},k[8]={0,0,0,3,1,3,2,2};
int fx,fy,j=2,map[25][41]={0},mapc[25][41]={0},h,w=0,z,nx[4],ny[4],score;
p(int t,char o,int b)
{ int i;
for (i=0;i<=3;i++)
{textcolor(t); gotoxy(fx+nx[i],fy+ny[i]); putch(o);
map[fy+ny[i]][fx+nx[i]]=b;
}
}
inkey()
{ int l,e,k,nnx[4],nny[4]; char o;
if (kbhit()) {
o=getch();
if (o==27) exit(0);
if (o==0) {
o=getch();
if (o==77)
{e=0; for (l=0;l<=3;l++) {
if (fx+nx[l]+1==41) {e=1; break;}
if (map[fy+ny[l]][fx+nx[l]+1]==1) {e=1; break;}
}
if (e==0) {j=1;}
}
if (o==75)
{e=0; for (l=0;l<=3;l++) {
if (fx+nx[l]-1==10) {e=1; break;}
if (map[fy+ny[l]][fx+nx[l]-1]==1) {e=1; break;}
}
if (e==0) {j=3;}
}
if (o==80)
{e=0; for (l=0;l<=3;l++) {
if (map[fy+ny[l]+1][fx+nx[l]]==1) {e=1; break;}
}
if (e==0) {w=10; z=19;}
}
if (o==72)
{ k=0;
for (l=0;l<=3;l++) {
e=nx[l]; nx[l]=ny[l](-1); ny[l]=e;
if (map[fy+ny[l]][fx+nx[l]]==1) {k=1;}
if (fx+nx[l]<11||fx+nx[l]>40) {k=1;}
if (fy+ny[l]>24||fy+ny[l]<2) {k=1;}
}
if (k==1)
for (l=0;l<=3;l++) {e=nx[l]; nx[l]=ny[l]; ny[l]=e/(-1);}
}
}
}
}
win()
{gotoxy(20,12); textcolor(3); printf("You won!");
}
over()
{gotoxy(19,12); textcolor(14); printf("Game over!");
}
main()
{ int g,c,u,b,v; textmode(C40); clrscr(); randomize(); h=rand()%7+1;
for (g=1;g<=24;g++) {gotoxy(10,g); putch('|');}
gotoxy(3,3); printf("Next :"); gotoxy(3,15); printf("Score:");
gotoxy(3,16); printf("%d",0); gotoxy(3,11); printf("Esc=");
gotoxy(3,12); printf("TuiChu");
while (1) {
c=0; for (g=0;g<=3;g++) {nx[g]=x[h][g]; ny[g]=y[h][g];}
b=rand()%7+1; fx=25; fy=2;
for (g=0;g<=3;g++)
{textcolor(b); gotoxy(3+x[b][g],5+y[b][g]); putch(219);
}
while (c==0) {
inkey();
p(h,219,0); for (g=1;g<=30-z;g++) delay(1000);
w=w-1; if (w==0) z=0;
p(h,32,0); if (j!=2) {fx=fx+fxj[j]; fy=fy+fyj[j];}
j=2; fx=fx+fxj[2]; fy=fy+fyj[2];
for (g=0;g<=3;g++) {
if (fy+ny[g]>24) {c=1; break;}
if (map[fy+ny[g]][fx+nx[g]]==1) {c=1; break;}
}
} fx=fx-fxj[j]; fy=fy-fyj[j];
p(h,219,1); u=0; w=0;
for (g=0;g<=3;g++) {mapc[fy+ny[g]][fx+nx[g]]=h;}
for (g=0;g<=3;g++)
{textcolor(b); gotoxy(3+x[b][g],5+y[b][g]); putch(32);
}
for (g=1;g<=40;g++) if (map[2][g]==1||map[1][g]) {u=1; break;}
if (u==1)
{ over(); b=rand()%7+1; fx=30; fy=2;
for (g=0;g<=3;g++)
{textcolor(b); gotoxy(3+x[b][g],5+y[b][g]); putch(219);}
getch(); exit(0);
}
h=b; z=1;
do {
u=0; for (g=11;g<=40;g++) {if (map[z][g]==0) {u=1; break;}}
if (u==0) {
for (g=11;g<=40;g++) {gotoxy(g,z); putch(32);}
for (g=z-1;g>=1;g--) for (v=11;v<=40;v++) {map[g+1][v]=map[g][v];}
for (g=z-1;g>=1;g--) for (v=11;v<=40;v++) {mapc[g+1][v]=mapc[g][v];}
for (g=1;g<=24;g++) for (v=11;v<=40;v++)
{gotoxy(v,g); textcolor(mapc[g][v]); putch(219);}
score=score+10; gotoxy(3,16); printf("%d",score);
if (score>=30) {win(); getch(); exit;}
}
z++;
} while (z<25); z=0;
}
}
圈圈叉叉游戏(光标控制):
#include <conioh>
#include <stdioh>
int w[3][3]={2,1,2,
1,3,1,
2,1,2},i,j,k,l,kk,ll,x,y,m,prx=3,pry=3,s=0,f,g,e,r,h,m,q;
inkey()
{ char o,c[1];
if (kbhit())
{ o=getch();
if (o==27) {exit(0);}
if (o==13) {
gettext(x,y,x,y,&c);
if (c[0]==32) {gotoxy(x,y); putch('o'); s=1;
w[(y-pry)/2][(x-prx)/2]=-1;
}
}
if (o==0) {
o=getch();
if (o==72&&y>pry) {y--;}
if (o==77&&x<prx+4) {x++;}
if (o==80&&y<pry+4) {y++;}
if (o==75&&x>prx) {x--;}
}
}
}
pr()
{ gotoxy(prx,pry+0); printf(" | | ");
gotoxy(prx,pry+1); printf("-+-+-");
gotoxy(prx,pry+2); printf(" | | ");
gotoxy(prx,pry+3); printf("-+-+-");
gotoxy(prx,pry+4); printf(" | | ");
}
p()
{ for (h=0;h<=2;h++) {
q=0; for (m=0;m<=2;m++) if (w[h][m]==-1) q++;
if (q==3) {gotoxy(10,5); printf("Ni Ying Le"); getch(); exit(0);}
q=0; for (m=0;m<=2;m++) if (w[m][h]==-1) q++;
if (q==3) {gotoxy(10,5); printf("Ni Ying Le"); getch(); exit(0);}
q=0; for (m=0;m<=2;m++) if (w[h][m]==-2) q++;
if (q==3) {gotoxy(10,5); printf("Wo Ying Le"); getch(); exit(0);}
q=0; for (m=0;m<=2;m++) if (w[m][h]==-2) q++;
if (q==3) {gotoxy(10,5); printf("Wo Ying Le"); getch(); exit(0);}
}
q=w[0][0]+w[1][1]+w[2][2];
if (q==-6) {gotoxy(10,5); printf("Wo Ying Le"); getch(); exit(0);}
q=w[0][2]+w[1][1]+w[2][0];
if (q==-6) {gotoxy(10,5); printf("Wo Ying Le"); getch(); exit(0);}
q=0; for (h=0;h<=2;h++) for (m=0;m<=2;m++) if (w[h][m]>0) {q=1;}
if (q==0) {gotoxy(10,5); printf("Ping Ju"); getch(); exit(0);}
}
main()
{ textmode(C40); pr(); gotoxy(prx+2,pry+2); putch('x');
w[1][1]=-2; x=prx; y=pry; gotoxy(10,7); printf("Esc Tui Chu");
while (1) {
inkey(); gotoxy(x,y);
if (s==1) {s=0; e=-1; r=-1;
for (i=0;i<=2;i++)
{ l=0; f=-1; g=-1; ll=0; for (j=0;j<=2;j++) {
if (w[i][j]==-1) {l++;}
if (w[i][j]==-2) {ll++;}
if (w[i][j]>0) {f=i; g=j;}
}
if ((l==2)&&(e<0||r<0)&&f>=0&&g>=0) {e=f; r=g;}
if (ll==2&&f>=0&&g>=0) {e=f; r=g;}
k=0; f=-1; g=-1; kk=0; for (j=0;j<=2;j++) {
if (w[j][i]==-1) {k++;}
if (w[j][i]==-2) {kk++;}
if (w[j][i]>0) {f=j; g=i;}
}
if ((k==2)&&(e<0||r<0)&&f>=0&&g>=0) {e=f; r=g;}
if (kk==2&&f>=0&&g>=0) {e=f; r=g;}
}
k=0; f=-1; g=-1;
if (w[0][0]==-1) {k++;} if (w[0][0]>0) {f=0; g=0;}
if (w[1][1]==-1) {k++;} if (w[1][1]>0) {f=1; g=1;}
if (w[2][2]==-1) {k++;} if (w[2][2]>0) {f=2; g=2;}
if (k==2) {e=f; r=g;}
l=0; f=-1; g=-1;
if (w[0][2]==-1) {l++;} if (w[0][2]>0) {f=0; g=0;}
if (w[1][1]==-1) {l++;} if (w[1][1]>0) {f=1; g=1;}
if (w[2][0]==-1) {l++;} if (w[2][0]>0) {f=2; g=2;}
if (l==2&&f>=0&&g>=0) {e=f; r=g;}
if (e<0||r<0) {
k=0; l=0; m=0;
for (i=0;i<=2;i++)
for (j=0;j<=2;j++)
if (w[i][j]>m) {m=w[i][j]; k=i; l=j;}
gotoxy(l+prx+l,k+pry+k); w[k][l]=-2; putch('x');
} else {gotoxy(r+prx+r,e+pry+e); putch('x'); w[e][r]=-2;}
p();
}
}
}
d球游戏(WASD和8546控制):
#include <stdioh>
#include <conioh>
main()
{ int x,y,xf=1,yf=1,bf=6,bg=22,pf=30,pg=22,k=800,o,j,i,score=0;
char p;
clrscr(); textmode(C40);
for (x=1;x<=40;x++) { gotoxy(x,1); putch(219); gotoxy(x,24); putch(219);}
for (y=1;y<=24;y++) { gotoxy(1,y); putch(219); gotoxy(40,y); putch(219);}
gotoxy(3,3); putch('O'); x=3; y=3; gotoxy(bf,bg); printf("----");
gotoxy(pf,pg); printf("----");
gotoxy(3,1); printf("<=-20--Lost");
gotoxy(16,1); printf("Score: %d ",score);
gotoxy(30,1); printf(">=50--Win");
while (k&&score<50&&score>-20)
{ gotoxy(bf,bg); printf("----");
gotoxy(pf,pg); printf("----");
gotoxy(x,y); putch('O'); delay(1000000000);
gotoxy(x,y); putch(' ');
if (x==39) {xf=-1;} if (x==2) {xf=1;}
if (y==23) {yf=-1;} if (y==2) {yf=1;}
x+=xf; y+=yf;
if (y==bg-1&&x>=(bf-1)&&x<=(bf+6)&&yf==1)
if ((x==bf-1&&xf==1)||(x>=bf&&x<=(bf+5))||(x==bf+6&&xf==-1)) {
if (x==bf-1&&xf==1) xf=-1; if (x==bf+6&&xf==-1) xf=1; yf=-1;
if (yf==1) {score+=5; gotoxy(15,1);
printf("Score: %d +5",score); putch(219);}
}
if (y==pg-1&&x>=(pf-1)&&x<=(pf+6))
if ((x==pf-1&&xf==1)||(x>=pf&&x<=(pf+5))||(x==pf+6&&xf==-1)) {
yf=-1; score+=5; gotoxy(15,1);
printf("Score: %d +5",score); putch(219);}
if (y==23) {score-=5; gotoxy(15,1);
printf("Score: %d -5",score); putch(219);}
if (kbhit())
{ p=getch(); o=p;
if (o==27) exit();
if (p=='a'&&bf>3) {gotoxy(bf,bg); printf(" "); bf=bf-2;
gotoxy(bf,bg); printf("----");}
if (p=='d'&&bf+5<pf-1) {gotoxy(bf,bg); printf(" "); bf=bf+2;
gotoxy(bf,bg); printf("----");}
if (p=='w'&&bg-1>1) {gotoxy(bf,bg); printf(" "); bg=bg-1;
gotoxy(bf,bg); printf("----");}
if (p=='s'&&bg+1<24) {gotoxy(bf,bg); printf(" "); bg=bg+1;
gotoxy(bf,bg); printf("----");}
if (p=='4'&&pf>bf+6) {gotoxy(pf,pg); printf(" "); pf=pf-2;
gotoxy(pf,pg); printf("----");}
if (p=='6'&&pf+5<38) {gotoxy(pf,pg); printf(" "); pf=pf+2;
gotoxy(pf,pg); printf("----");}
if (p=='8'&&pg-1>1) {gotoxy(pf,pg); printf(" "); pg=pg-1;
gotoxy(pf,pg); printf("----");}
if (p=='5'&&pg+1<24) {gotoxy(pf,pg); printf(" "); pg=pg+1;
gotoxy(pf,pg); printf("----");}
}
k--;
} gotoxy(x,y); putch('O');
if (score>=50) {gotoxy(10,3); printf("Score>=50! You win!");}
if (score<=-20) {gotoxy(10,3); printf("Score<=-20! You lost!");}
getch();
}
以上就是关于c语言可以编写怎么样的程序应用。全部的内容,包括:c语言可以编写怎么样的程序应用。、c语言用什么编程软件、C语言编程有哪些好用的软件等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)