新桐随想
发表于 2017-11-21 16:03:55
想知道,C/C++工程师的程度到哪一步了
葳蕤无为
发表于 2017-11-21 17:13:43
怕是看的头晕脑胀哦
匆匆过客001
发表于 2017-11-22 08:12:22
回复来看看
Namelessk
发表于 2017-11-22 15:35:27
{:10_257:}
ralphla
发表于 2017-11-22 17:25:21
谢谢
技术员
发表于 2017-11-24 11:12:57
看看到底是啥
1363646276
发表于 2017-11-24 13:04:59
谢谢
fanchencloud
发表于 2017-11-27 08:59:04
1#
还差几 发表于 2017-8-15 17:17:39 121866 | 只看该作者 |只看大图 回帖奖励
做不好请提出
本帖隐藏的内容
#include<stdio.h>
#include<stdlib.h>
#include<windows.h>
#include<time.h>
#include<conio.h>
#define MOD 28
#define SIZE_N 19
#define SIZE_M 12
int cur_x,cur_y;
int score,mark,next,map,Gamespeed=300;
int shape={
{0,-1,0,-2,1,0}, {0,1,1,0,2,0}, {-1,0,0,1,0,2}, {0,-1,-1,0,-2,0},
{0,-1,0,1,-1,0}, {0,1,1,0,-1,0}, {1,0,0,-1,0,1}, {1,0,-1,0,0,-1},
{-1,1,0,1,1,0}, {0,-1,1,0,1,1}, {-1,0,0,-1,1,-1}, {-1,-1,-1,0,0,1},
{-1,0,0,1,1,1}, {0,1,1,-1,1,0}, {-1,0,0,1,1,1}, {0,1,1,-1,1,0},
{-1,0,0,-1,0,-2}, {-1,0,-2,0,0,1}, {0,1,0,2,1,0}, {0,-1,1,0,2,0},
{0,1,1,0,1,1}, {0,-1,1,0,1,-1}, {-1,0,0,-1,-1,-1}, {-1,0,-1,1,0,1},
{0,1,0,2,0,3}, {1,0,2,0,3,0}, {0,-1,0,-2,0,-3}, {-1,0,-2,0,-3,0}
};
void gotoxy(int x,int y){
COORD c;
c.X=x-1; c.Y=y-1;
SetConsoleCursorPosition (GetStdHandle(STD_OUTPUT_HANDLE), c);
}
void Gameover(){
int i,j,flag=0;
for(j=1;j<SIZE_M-1;j++){
if(map!=0){
flag=1;break;
}
}
if(flag==1){
for(i=1;i<SIZE_N-1;i++){
gotoxy(2,i+1);
for(j=1;j<SIZE_M-1;j++){
printf("□");
}puts("");
}
gotoxy(7,9);
printf("GAME OVER!");
gotoxy(1,SIZE_N+1);
exit(0);
}
}
void ShowMap(int id){
int i,j;
gotoxy(1,1);
if(id!=-1){
for(i=0;i<SIZE_N;i++){
for(j=0;j<SIZE_M;j++){
if(i==0&&j==0 || i==0&&j==SIZE_M-1 || j==0&&i==SIZE_N-1 || j==SIZE_M-1&&i==SIZE_N-1)printf(" ");
else if(i==0 || i==SIZE_N-1)printf("--");
else if(j==0 || j==SIZE_M-1)printf("|");
else if(map==2) printf("■");
else if(i==cur_x+shape && j==cur_y+shape ||
i==cur_x+shape && j==cur_y+shape ||
i==cur_x+shape && j==cur_y+shape ||
i==cur_x && j==cur_y)
printf("■");
else if(map==0) printf("");
}
if(i==1)printf(" 下一个 :");
if(i==11)printf(" 等分 : %d",score);
if(i==14)printf(" 速度 : %d",score/100+1);
puts("");
}
}
else {
mark=1;
for(i=0;i<SIZE_N;i++)
{
for(j=0;j<SIZE_M;j++)
{
if(i==0&&j==0 || i==0&&j==SIZE_M-1 || j==0&&i==SIZE_N-1 || j==SIZE_M-1&&i==SIZE_N-1)printf(" ");
else if(i==0 || i==SIZE_N-1)printf("--");
else if(j==0 || j==SIZE_M-1)printf("|");
else if(map==2) printf("■");
else if(map==0) printf("");
}
if(i==1)printf(" next:");
if(i==11)printf(" score : %d",score);
if(i==14)printf(" speed : %d",score/100+1);
puts("");
}
}
gotoxy(30,6); printf("");
for(i=0;i<6;i=i+2){
gotoxy(30+2*shape,6+shape); printf("");
}
gotoxy(30,6); printf("■");
for(i=0;i<6;i=i+2)
{
gotoxy(30+2*shape,6+shape); printf("■");
}
Sleep(Gamespeed);
}
void init(int id)
{
int i,j;
memset(map,0,sizeof(map));
for(i=0;i<SIZE_N;i++){
for(j=0;j<SIZE_M;j++)
if(i==SIZE_N-1 || j==0 || j==SIZE_M-1)
map=-1;
}
cur_x=0; cur_y=5;
ShowMap(id);
}
int judge_in(int x,int y,int id)
{
int i;
if(map!=0)return 0;
for(i=0;i<6;i=i+2)
{
if(map[ x+shape ][ y+shape ]!=0)return 0;
}return 1;
}
void fun_score()
{
int i,j,ii,jj;
for(i=1;i<SIZE_N-1;i++)
{
int flag=0;
for(j=1;j<SIZE_M-1;j++)
{
if(map!=2){ flag=1;break; }
}
if(flag==0)
{
int k=3;
while(k--)
{
gotoxy(2,i+1);
for(ii=1;ii<SIZE_M-1;ii++)
{
if(map==2)
{
if(k%2==1)printf("");
else printf("■");
}
}
Sleep(100);
}
for(ii=i;ii>1;ii--)
{
for(jj=1;jj<SIZE_M-1;jj++) map=map;
}
ShowMap(-1);
score+=10;
if(score%100==0 && score!=0)Gamespeed-=50;
}
}
}
int main(){
int i,id,set=1;
int pan;
printf("按1开始游戏,其他结束。\n");
scanf("%d",&pan);
MNBVCXZ:
if(pan==1)
{
srand(time(NULL));
id=rand()%MOD; id=(id+MOD)%MOD;
next=rand()%MOD; next=(next+MOD)%MOD;
init(id);
while(1)
{
Here:
mark=0;
if(set==0)
{
id=next;
next=rand()%MOD; next=(next+MOD)%MOD;
cur_x=0;cur_y=5;
set=1;
}
while(!kbhit()){
Gameover();
if(judge_in(cur_x+1,cur_y,id)==1) cur_x++;
else
{
map=2;
for(i=0;i<6;i=i+2)
map[ cur_x+shape ][ cur_y+shape ]=2;
fun_score();
set=0;
}
if(mark!=1)ShowMap(id);
goto Here;
}
char key;
key=getch();
if(key==72)
{
int tmp=id;
id++;
if( id%4==0 && id!=0 )id=id-4;
if(judge_in(cur_x,cur_y,id)!=1)id=tmp;
}
else if(key==80 && judge_in(cur_x+1,cur_y,id)==1)cur_x++;
else if(key==75 && judge_in(cur_x,cur_y-1,id)==1)cur_y--;
else if(key==77 && judge_in(cur_x,cur_y+1,id)==1)cur_y++;
else if(key==27){gotoxy(1,SIZE_N+1);exit(0);}
}
}
else
{
printf("你真的要退出吗?按1开始游戏,其他结束。\n");
scanf("%d",&pan);
goto MNBVCXZ;
}
srand(time(NULL));
id=rand()%MOD; id=(id+MOD)%MOD;
next=rand()%MOD; next=(next+MOD)%MOD;
init(id);
while(1)
{
HERE:
mark=0;
if(set==0){
id=next;
next=rand()%MOD; next=(next+MOD)%MOD;
cur_x=0;cur_y=5;
set=1;
}
while(!kbhit()){
Gameover();
if(judge_in(cur_x+1,cur_y,id)==1) cur_x++;
else
{
map=2;
for(i=0;i<6;i=i+2)
map[ cur_x+shape ][ cur_y+shape ]=2;
fun_score();
set=0;
}
if(mark!=1)ShowMap(id);
goto HERE;
}
char key;
key=getch();
if(key==72)
{
int tmp=id;
id++;
if( id%4==0 && id!=0 )id=id-4;
if(judge_in(cur_x,cur_y,id)!=1)id=tmp;
}
else if(key==80 && judge_in(cur_x+1,cur_y,id)==1)cur_x++;
else if(key==75 && judge_in(cur_x,cur_y-1,id)==1)cur_y--;
else if(key==77 && judge_in(cur_x,cur_y+1,id)==1)cur_y++;
else if(key==27){gotoxy(1,SIZE_N+1);exit(0);}
system("pause");
getch();
return 0;
}
}
高高的裤腰带
发表于 2017-11-27 14:58:22
我肯定支持的
ForgetMe
发表于 2017-11-27 16:15:57
感谢楼主分享
Perry__
发表于 2017-11-27 16:42:15
啊啊啊啊啊
1055560667
发表于 2017-11-27 22:44:49
学习学习。。
397016103
发表于 2017-11-30 13:32:03
000
°蓝鲤歌蓝
发表于 2017-11-30 18:26:49
看看
963739051
发表于 2017-11-30 18:48:42
虽然才刚学,但还是想来观摩一下的新手
翁某某
发表于 2017-11-30 22:10:41
!
DoKo
发表于 2017-12-1 06:10:22
看看能不能
fc123456
发表于 2017-12-4 12:49:02
来看看。
l不败
发表于 2017-12-5 08:35:19
连个面向对象都没有,关c++什么事
一封遗书
发表于 2017-12-5 11:56:20
..