當前位置:首頁 » 游戲種類 » 用c編寫小游戲

用c編寫小游戲

發布時間: 2022-08-26 06:08:35

『壹』 如何使用C語言編寫簡單小游戲

C語言是計算機專業都要學習的一門基礎學科。一般來說,是比較枯燥的.那麼,我們能不能通過編一些小游戲來提高它的趣味性呢?這樣學習程序設計,就不會是一件艱苦 ,枯燥的事,它變得象電腦游戲一樣充滿好奇,富有樂趣。

例如2048這款游戲:

方法/步驟:

#include<stdio.h>

#include<stdlib.h>

#include<time.h>

#include<conio.h>

#include<windows.h>

#define SIZE 4

static int score=0;

void putn(int n[][SIZE]);

void getn(int n[][SIZE]);

int isempty(int n[][SIZE]);

int isfull(int n[][SIZE]);

void math(int n[][SIZE],char c);

void tow(int n[][SIZE]);

void toa(int n[][SIZE]);

void tos(int n[][SIZE]);

void tod(int n[][SIZE]);

  • //主函數

    int main()

    {

    int i,j;

    int n[SIZE][SIZE];

    char c=' ';

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

    {

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

    {

    n[i][j]=0;

    }

    }

    printf( "*********************** "

    " 2048(%dX%d) "

    " control:W/A/S/D "

    "press any key to begin "

    "*********************** ",SIZE,SIZE);

    getch();

    system("cls");

    //n[0][1]=2048;

    //n[0][3]=2048;

    while(1)

    {

    if(isempty(n))

    getn(n);

    putn(n);

    if(!isempty(n)&&isfull(n))

    break;

    sleep(200);

    c=getch();

    while(c!='w'&&c!='a'&&c!='s'&&c!='d')

    c=getch();

    math(n,c);

    system("cls");

    }

    printf(" Game Over! ",score);

    return 0;

    }

  • //函數

    void putn(int n[][SIZE])

    {

    int i,j;

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

    {

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

    printf("| ");

    printf("| ");

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

    {

    if(n[i][j]==0)

    printf("| ");

    else

    printf("|%4d ",n[i][j]);

    }

    printf("| ");

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

    printf("|_____");

    printf("| ");

    }

    printf("score: %d",score);

    }

    void getn(int n[][SIZE])

    {

    int a,b;

    a=rand()%SIZE;

    b=rand()%SIZE;

    while(n[a][b]!=0)

    {

    a=rand()%SIZE;

    b=rand()%SIZE;

    }

    n[a][b]=2;

    }

    int isempty(int n[][SIZE])

    {

    int i,j,count=0;

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

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

    if(n[i][j]==0)

    count++;

    return count;

    }

    int isfull(int n[][SIZE])

    {

    int i,j,count=0;

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

    {

    for(j=1;j<SIZE-1;j++)

    {

    if(n[i][j]==n[i][j+1]||n[i][j]==n[i][j-1])

    count++;

    }

    }

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

    {

    for(i=1;i<SIZE-1;i++)

    {

    if(n[i][j]==n[i+1][j]||n[i][j]==n[i-1][j])

    count++;

    }

    }

    return count>0?0:1;

    }

    void math(int n[][SIZE],char c)

    {

    switch(c)

    {

    case 'w':tow(n);break;

    case 'a':toa(n);break;

    case 's':tos(n);break;

    case 'd':tod(n);break;

    default :;

    }

    }

    void tow(int n[][SIZE])

    {

    int i,j,a;

    int m[SIZE];

    for(a=0;a<SIZE;a++)

    m[a]=0;

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

    {

    for(a=0;a<SIZE;a++)

    {

    for(i=0;i<SIZE-1;i++)

    {

    if(n[i][j]==0)

    {

    n[i][j]=n[i+1][j];

    n[i+1][j]=0;

    }

    }

    }

    }

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

    {

    for(a=0,i=0;i<SIZE;i++)

    {

    if(n[i][j]!=n[i+1][j]&&n[i][j]!=0||n[i][j]==2048)

    {

    m[a++]=n[i][j];

    n[i][j]=0;

    }

    else if(n[i][j]==n[i+1][j])

    {

    m[a++]=n[i][j]+n[i+1][j];

    score+=m[a-1];

    n[i][j]=0,n[i+1][j]=0;

    }

    }

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

    {

    n[i][j]=m[i];

    m[i]=0;

    }

    }

    }

    void toa(int n[][SIZE])

    {

    int i,j,a;

    int m[SIZE];

    for(a=0;a<SIZE;a++)

    m[a]=0;

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

    {

    for(a=0;a<SIZE;a++)

    {

    for(j=0;j<SIZE-1;j++)

    {

    if(n[i][j]==0)

    {

    n[i][j]=n[i][j+1];

    n[i][j+1]=0;

    }

    }

    }

    }

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

    {

    for(a=0,j=0;j<SIZE;j++)

    {

    if(n[i][j]!=n[i][j+1]&&n[i][j]!=0||n[i][j]==2048)

    {

    m[a++]=n[i][j];

    n[i][j]=0;

    }

    else if(n[i][j]==n[i][j+1])

    {

    m[a++]=n[i][j]+n[i][j+1];

    score+=m[a-1];

    n[i][j]=0,n[i][j+1]=0;

    }

    }

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

    {

    n[i][j]=m[j];

    m[j]=0;

    }

    }

    }

    void tos(int n[][SIZE])

    {

    int i,j,a;

    int m[SIZE];

    for(a=0;a<SIZE;a++)

    m[a]=0;

    for(j=SIZE-1;j>=0;j--)

    {

    for(a=SIZE-1;a>=0;a--)

    {

    for(i=SIZE-1;i>0;i--)

    {

    if(n[i][j]==0)

    {

    n[i][j]=n[i-1][j];

    n[i-1][j]=0;

    }

    }

    }

    }

    for(j=SIZE-1;j>=0;j--)

    {

    for(a=SIZE-1,i=SIZE-1;i>=0;i--)

    {

    if(n[i][j]!=n[i-1][j]&&n[i][j]!=0||n[i][j]==2048)

    {

    m[a--]=n[i][j];

    n[i][j]=0;

    }

    else if(n[i][j]==n[i-1][j])

    {

    m[a--]=n[i][j]+n[i-1][j];

    score+=m[a+1];

    n[i][j]=0,n[i-1][j]=0;

    }

    }

    for(i=SIZE-1;i>=0;i--)

    {

    n[i][j]=m[i];

    m[i]=0;

    }

    }

    }

    void tod(int n[][SIZE])

    {

    int i,j,a;

    int m[SIZE];

    for(a=0;a<SIZE;a++)

    m[a]=0;

    for(i=SIZE-1;i>=0;i--)

    {

    for(a=SIZE-1;a>=0;a--)

    {

    for(j=SIZE-1;j>0;j--)

    {

    if(n[i][j]==0)

    {

    n[i][j]=n[i][j-1];

    n[i][j-1]=0;

    }

    }

    }

    }

    for(i=SIZE-1;i>=0;i--)

    {

    for(a=SIZE-1,j=SIZE-1;j>=0;j--)

    {

    if(n[i][j]!=n[i][j-1]&&n[i][j]!=0||n[i][j]==2048)

    {

    m[a--]=n[i][j];

    n[i][j]=0;

    }

    else if(n[i][j]==n[i][j-1])

    {

    m[a--]=n[i][j]+n[i][j-1];

    score+=m[a+1];

    n[i][j]=0,n[i][j-1]=0;

    }

    }

    for(j=SIZE-1;j>=0;j--)

    {

    n[i][j]=m[j];

    m[j]=0;

    }

    }

    }

『貳』 使用C語言編寫小游戲的方法是什麼

//聲明
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<conio.h>
#include<windows.h>
#define SIZE 4
static int score=0;

void putn(int n[][SIZE]);
void getn(int n[][SIZE]);
int isempty(int n[][SIZE]);
int isfull(int n[][SIZE]);
void math(int n[][SIZE],char c);
void tow(int n[][SIZE]);
void toa(int n[][SIZE]);
void tos(int n[][SIZE]);
void tod(int n[][SIZE]);
//主函數
int main()
{
int i,j;
int n[SIZE][SIZE];
char c=' ';
for(i=0;i<SIZE;i++)
{
for(j=0;j<SIZE;j++)
{
n[i][j]=0;
}
}

printf( "*********************** "
" 2048(%dX%d) "
" control:W/A/S/D "
"press any key to begin "
"*********************** ",SIZE,SIZE);
getch();
system("cls");
//n[0][1]=2048;
//n[0][3]=2048;
while(1)
{
if(isempty(n))
getn(n);
putn(n);
if(!isempty(n)&&isfull(n))
break;
sleep(200);
c=getch();
while(c!='w'&&c!='a'&&c!='s'&&c!='d')
c=getch();
math(n,c);
system("cls");
}
printf(" Game Over! ",score);
return 0;
}
//函數
void putn(int n[][SIZE])
{
int i,j;
for(i=0;i<SIZE;i++)
{
for(j=0;j<SIZE;j++)
printf("| ");
printf("| ");
for(j=0;j<SIZE;j++)
{
if(n[i][j]==0)
printf("| ");
else
printf("|%4d ",n[i][j]);
}
printf("| ");
for(j=0;j<SIZE;j++)
printf("|_____");
printf("| ");
}
printf("score: %d",score);
}

void getn(int n[][SIZE])
{
int a,b;
a=rand()%SIZE;
b=rand()%SIZE;
while(n[a][b]!=0)
{
a=rand()%SIZE;
b=rand()%SIZE;
}
n[a][b]=2;

}

int isempty(int n[][SIZE])
{
int i,j,count=0;
for(i=0;i<SIZE;i++)
for(j=0;j<SIZE;j++)
if(n[i][j]==0)
count++;
return count;
}

int isfull(int n[][SIZE])
{
int i,j,count=0;
for(i=0;i<SIZE;i++)
{
for(j=1;j<SIZE-1;j++)
{
if(n[i][j]==n[i][j+1]||n[i][j]==n[i][j-1])
count++;
}
}
for(j=0;j<SIZE;j++)
{
for(i=1;i<SIZE-1;i++)
{
if(n[i][j]==n[i+1][j]||n[i][j]==n[i-1][j])
count++;
}
}
return count>0?0:1;
}

void math(int n[][SIZE],char c)
{
switch(c)
{
case 'w':tow(n);break;
case 'a':toa(n);break;
case 's':tos(n);break;
case 'd':tod(n);break;
default :;
}
}
void tow(int n[][SIZE])
{
int i,j,a;
int m[SIZE];
for(a=0;a<SIZE;a++)
m[a]=0;
for(j=0;j<SIZE;j++)
{
for(a=0;a<SIZE;a++)
{
for(i=0;i<SIZE-1;i++)
{
if(n[i][j]==0)
{
n[i][j]=n[i+1][j];
n[i+1][j]=0;
}
}
}
}
for(j=0;j<SIZE;j++)
{
for(a=0,i=0;i<SIZE;i++)
{
if(n[i][j]!=n[i+1][j]&&n[i][j]!=0||n[i][j]==2048)
{
m[a++]=n[i][j];
n[i][j]=0;
}
else if(n[i][j]==n[i+1][j])
{
m[a++]=n[i][j]+n[i+1][j];
score+=m[a-1];
n[i][j]=0,n[i+1][j]=0;
}
}
for(i=0;i<SIZE;i++)
{
n[i][j]=m[i];
m[i]=0;
}
}

}

void toa(int n[][SIZE])
{
int i,j,a;
int m[SIZE];
for(a=0;a<SIZE;a++)
m[a]=0;
for(i=0;i<SIZE;i++)
{
for(a=0;a<SIZE;a++)
{
for(j=0;j<SIZE-1;j++)
{
if(n[i][j]==0)
{
n[i][j]=n[i][j+1];
n[i][j+1]=0;
}
}
}
}
for(i=0;i<SIZE;i++)
{
for(a=0,j=0;j<SIZE;j++)
{
if(n[i][j]!=n[i][j+1]&&n[i][j]!=0||n[i][j]==2048)
{
m[a++]=n[i][j];
n[i][j]=0;
}
else if(n[i][j]==n[i][j+1])
{
m[a++]=n[i][j]+n[i][j+1];
score+=m[a-1];
n[i][j]=0,n[i][j+1]=0;
}
}
for(j=0;j<SIZE;j++)
{
n[i][j]=m[j];
m[j]=0;
}
}

}
void tos(int n[][SIZE])
{
int i,j,a;
int m[SIZE];
for(a=0;a<SIZE;a++)
m[a]=0;
for(j=SIZE-1;j>=0;j--)
{
for(a=SIZE-1;a>=0;a--)
{
for(i=SIZE-1;i>0;i--)
{
if(n[i][j]==0)
{
n[i][j]=n[i-1][j];
n[i-1][j]=0;
}
}
}
}
for(j=SIZE-1;j>=0;j--)
{
for(a=SIZE-1,i=SIZE-1;i>=0;i--)
{
if(n[i][j]!=n[i-1][j]&&n[i][j]!=0||n[i][j]==2048)
{
m[a--]=n[i][j];
n[i][j]=0;
}
else if(n[i][j]==n[i-1][j])
{
m[a--]=n[i][j]+n[i-1][j];
score+=m[a+1];
n[i][j]=0,n[i-1][j]=0;
}
}
for(i=SIZE-1;i>=0;i--)
{
n[i][j]=m[i];
m[i]=0;
}
}

}
void tod(int n[][SIZE])
{
int i,j,a;
int m[SIZE];
for(a=0;a<SIZE;a++)
m[a]=0;
for(i=SIZE-1;i>=0;i--)
{
for(a=SIZE-1;a>=0;a--)
{
for(j=SIZE-1;j>0;j--)
{
if(n[i][j]==0)
{
n[i][j]=n[i][j-1];
n[i][j-1]=0;
}
}
}
}
for(i=SIZE-1;i>=0;i--)
{
for(a=SIZE-1,j=SIZE-1;j>=0;j--)
{
if(n[i][j]!=n[i][j-1]&&n[i][j]!=0||n[i][j]==2048)
{
m[a--]=n[i][j];
n[i][j]=0;
}
else if(n[i][j]==n[i][j-1])
{
m[a--]=n[i][j]+n[i][j-1];
score+=m[a+1];
n[i][j]=0,n[i][j-1]=0;
}
}
for(j=SIZE-1;j>=0;j--)
{
n[i][j]=m[j];
m[j]=0;
}
}
}
需要注意的是:

srand((unsigned) time(0);rand();是固定形式,不要更改任何一個字元!
如果不能編譯,請把sleep(200);注釋掉,如果提示不能找到system("cls");請把system("cls")更換為clrscr()。

c語言中沒有類,只有結構,也可以像類一樣編寫,用結構,但其成員都是公開訪問的,C++才有真正的類。

『叄』 C語言編寫小游戲

//相當精簡的貪吃蛇程序,在vc完全可以運行
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<Windows.h>
#include<conio.h>
#define width 25
#define height 60
#define w '-'
#define h '|'
#define SNAKE 's'
#define FOOD 'o'
#define UP 'w'
#define DOWN 's'
#define LEFT 'a'
#define RIGHT 'd'
char wall[width][height] = { 0 };
//定義位置結構體,變數僅兩個
typedef struct _spos
{
int x;
int y;
}Spos;
//定義節點,用於產生蛇身子節點變數。蛇一般有三個節點,每個節點可以指向前後身子,用於來調整蛇的前進與後退
typedef struct _node
{
Spos pos;
struct _node *next;
struct _node *head;
}Node;
//定義食物變數,在特定位置產生食物符號
typedef struct _food
{
int x;
int y;
}Food;
//定義初始化節點函數,用於動態創建初始節點所需的空間。
Node *CreateNode()
{
Node *phead = NULL;
phead = (Node *)malloc(sizeof(Node));
return phead;
}
//聲明全局變數,蛇頭;以供初始化及銷毀特定位置節點
extern Node *snake=NULL;
//定義動作函數吃食物,當蛇遇到食物時,食物消失。
BOOL EatFood(Spos *snake )
{
if (wall[snake->x][snake->y] == FOOD)
return TRUE;
else
return FALSE;
}
//定義貪吃蛇游戲結束函數,當違反游戲規則(即就是蛇頭撞牆)時退出。
BOOL GameOver(Spos *snake)
{
if (wall[snake->x][snake->y] == w || wall[snake->x][snake->y] == h)
return TRUE;
else
return FALSE;
}
//定義刪除蛇尾函數
void Delsnake()
{
Node *pNew = NULL;
Node *snake1 = snake;
Node *p;
p=pNew = snake1;/*->head*/
while (pNew->next != NULL)
{
p = pNew;
pNew = pNew->next;
}
wall[pNew->pos.x][pNew->pos.y] = ' ';
free(pNew);
p->next = NULL;
}
//定義食物產生(即就是舊的食物消失)動作函數
void Getfood()
{
Food foods;
int x, y;
do{
x = rand() % (width -1) + 1;
y = rand() % (height-1 ) + 1;
} while (wall[x][y] != ' ');
foods.x = x;
foods.y = y;
wall[x][y] = FOOD;
}
void initsanke()
{
Node *pNew = NULL;
Node *head = (Node *)malloc(sizeof(Node));
int snake_len = 3;
int x = 10;
int y = 20;
int i;
pNew =head;
pNew->pos.x = x;
pNew->pos.y = y;
wall[x][y] = SNAKE;
//關鍵的一句,頭結點賦值給蛇頭
snake = pNew;
//循環產生蛇身,蛇尾並列印圖像s
for (i = 1; i < snake_len; i++)
{
y = pNew->pos.y;
pNew->next = CreateNode();
pNew = pNew->next;
pNew->pos.x = x;
pNew->pos.y = y + 1;
pNew->next = NULL;
wall[x][y + 1] = SNAKE;
}

}
void showwall()
{
int i, j;
for (i=0; i<width; i++)
{
for (j = 0; j < height; j++)
{
printf("%c", wall[i][j]);
}
if(i!= width-1) printf("\n");
}

}
void initwall()
{
int i, j;
for (i = 0; i < width; i++)
{
wall[i][0] = h;
wall[i][height-1] =h;
for (j = 1; j < height - 1; j++)
wall[i][j] = ' ';
}
for (i = 0; i < height; i++)
{
wall[0][i] = w;
wall[width-1][i] =w;
}
}
BOOL MoveToup()
{
//Node *snake = NULL;
Node *pnew = NULL;
Food *foods = NULL;
BOOL eat;
Spos spos;

spos.x = snake->pos.x - 1;
spos.y = snake->pos.y;
eat = EatFood(&spos);
if (GameOver(&spos))
return FALSE;
pnew = CreateNode();
pnew->pos.x = spos.x;
pnew->pos.y = spos.y;
pnew->next = snake;
snake = pnew;
wall[spos.x][spos.y] = SNAKE;
if (eat)
{
Getfood();
}
else
{
Delsnake();
}
return TRUE;
}
BOOL MoveToright()
{
//Node *snake = NULL;
Node *pnew = NULL;
Food *foods = NULL;
BOOL eat;
Spos spos;

spos.x = snake->pos.x;
spos.y = snake->pos.y + 1;
eat = EatFood(&spos);
if (GameOver(&spos))
return FALSE;
pnew = CreateNode();
pnew->pos.x = spos.x;
pnew->pos.y = spos.y;
pnew->next = snake;
snake = pnew;
wall[spos.x][spos.y] = SNAKE;
if (eat)
{
Getfood();
}
else
{
Delsnake();
}

return TRUE;
}

BOOL MoveTodown()
{
//Node *snake = NULL;
Node *pnew = NULL;
Food *foods = NULL;
BOOL eat;
Spos spos;

spos.x = snake->pos.x + 1;
spos.y = snake->pos.y;
eat = EatFood(&spos);
if (GameOver(&spos))
return FALSE;
pnew = CreateNode();
pnew->pos.x = spos.x;
pnew->pos.y = spos.y;
pnew->next = snake;
snake = pnew;
wall[spos.x][spos.y] = SNAKE;
if (eat)
{
Getfood();
}
else
{
Delsnake();
}

return TRUE;
}
BOOL MoveToleft()
{
//Node *snake = NULL;
Node *pnew = NULL;
Food *foods = NULL;
BOOL eat;
Spos spos;

spos.x = snake->pos.x;
spos.y = snake->pos.y - 1;
eat = EatFood(&spos);
if (GameOver(&spos))
return FALSE;
pnew = CreateNode();
pnew->pos.x = spos.x;
pnew->pos.y = spos.y;
pnew->next = snake;
snake = pnew;
wall[spos.x][spos.y] = SNAKE;
if (eat)
{
Getfood();
}
else
{
Delsnake();
}
return TRUE;
}
void Menu()
{
BOOL move=FALSE;
char temp;
char ch=LEFT;
initwall();
initsanke();
srand((unsigned int)time(0));;
Getfood();
showwall();

while (1)
{
Sleep(100);
temp = ch;
if (_kbhit())//檢查是否有鍵盤輸入
ch = _getch();
if (ch != UP && ch != DOWN && ch != RIGHT && ch != LEFT)
ch = temp;
/*方向相反則無效化操作*/
if ((temp == UP && ch == DOWN) || (temp == DOWN && ch == UP))
ch = temp;
if ((temp == LEFT && ch == RIGHT) || (temp == RIGHT && ch == LEFT))
ch = temp;
switch (ch)
{
case 'a': move =MoveToleft(); break;
case 'w': move =MoveToup(); break;
case 's': move =MoveTodown(); break;
case 'd': move =MoveToright(); break;
default:
break;
}
if (move)
{
system("cls");
showwall();
}
else
break;
}
}
int main()
{
Menu();
printf("\nSorry!Game over!\n");
system("pause");
return 0;
}

『肆』 僅用c語言能編出哪些小游戲

可以編寫狼追兔子游戲,擲骰子游戲,24點游戲,井字棋游戲,農夫過河游戲,掃雷小游戲,人機猜數游戲,三色球游戲, 推箱子游戲,坦克大戰游戲,貪吃蛇游戲等。

『伍』 教你如何使用C語言編寫簡單小游戲

編寫程序,實現如下表所示的5-魔方陣。
17

24

1

8

15

23

5

7

14

16

4

6

13

20

22

10

12

19

21

3

11

18

25

2

9

5-魔方陣
問題分析
所謂「n-魔方陣」,指的是使用1〜n2共n2個自然數排列成一個n×n的方陣,其中n為奇數;該方陣的每行、每列及對角線元素之和都相等,並為一個只與n有關的常數,該常數為n×(n2+1)/2。
例如5-魔方陣,其第一行、第一列及主對角線上各元素之和如下:
第一行元素之和:17+24+1+8+15=65
第一列元素之和:17+23+4+10+11=65
主對角線上元素之和:17+5+13+21+9=65

n×(n2+1)/2=5×(52+1)/2=65
可以驗證,5-魔方陣中其餘各行、各列及副對角線上的元素之和也都為65。
假定陣列的行列下標都從0開始,則魔方陣的生成方法為:在第0行中間置1,對從2開始的其餘n2-1個數依次按下列規則存放:
(1)
假定當前數的下標為(i,j),則下一個數的放置位置為當前位置的右上方,即下標為(i-1,j+1)的位置。
(2)
如果當前數在第0行,即i-1小於0,則將下一個數放在最後一行的下一列上,即下標為(n-1,j+1)的位置。
(3)
如果當前數在最後一列上,即j+1大於n-1,則將下一個數放在上一行的第一列上,即下標為(i-1,0)的位置。
(4)
如果當前數是n的倍數,則將下一個數直接放在當前位置的正下方,即下標為(i+1,j)的位置。
演算法設計
在設計演算法時釆用了下面一些方法:
定義array()函數,array()函數的根據輸入的n值,生成並顯示一個魔方陣,當發現n不是奇數時,就加1使之成為奇數。
使用動態內存分配與釋放函數malloc()與free(),在程序執行過程中動態分配與釋放內存,這樣做的好處是使代碼具有通用性,同時提高內存的使用率。
在分配內存時還要注意,由於一個整型數要佔用兩個內存,因此,如果魔方陣中要存放的數有max個,則分配內存時要分配2*max個單元,從而有malloc(max+max)。在malloc()函數中使用max+max而不是2*max是考慮了程序運行的性能。
顯然應該使用二維數組來表示魔方陣,但雖然數組是二維形式的,而由於內存是一維線性的,因此在存取數組元素時,要將雙下標轉換為單個索引編號。在程序中直接定義了指針變數來指向數組空間,即使用malloc()函數分配的內存。

『陸』 如何用C++編寫一個小游戲

一個用C++編程的小游戲,可以實現的功能如下:

1、隨機生成數字;

2、數字消除合並;

3、判定游戲結束;

一、游戲主體:

因為用C++寫的,所以用了類,棋盤用了一個二維數組,m是棋盤規格,取了4。

class game

{

public:

int i, j;

game() {

count1 = 0;

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

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

chessboard[i][j] = 0;

srand((unsigned)time(NULL));

x = rand() % m;

y = rand() % m;

if (count1 == 1 || count1 == 0)

chessboard[x][y] = 2;

else

chessboard[x][y] = 4;

showchessboard();

}//構造初始棋盤

void add(int count1);//新增數字

void showchessboard();//顯示棋盤

void up();

void down();

void left();

void right();

bool gameover();//游戲失敗

private:

int chessboard[m][m];

int x, y, count1, count2, temp1, temp2, k;//c1-連消,c2-空位標記,t1-判連消,t2,k-臨時變數

bool flag;//判消

};

二、隨機生成數字

void game::add(int count1)

{

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

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

{

if (chessboard[i][j] == 0)

goto loop;

}

showchessboard();

return;

loop:srand((unsigned)time(NULL));

do {

x = rand() % m;

y = rand() % m;

} while (chessboard[x][y] != 0);

if (count1 < 2)

chessboard[x][y] = 2;

else

chessboard[x][y] = 4;

showchessboard();

}

三、數字消除合並

void game::up()

{

temp1 = count1;

flag = false;

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

for (i = 0; i < m;)

{

for (; i < 4 && chessboard[i][j] == 0; i++); // 找非零值

if (i == 4)

break;

else

{

for (k = i + 1; k < 4 && chessboard[k][j] == 0; k++);//找下一個非零值

if (k == 4)

break;

else if (chessboard[i][j] == chessboard[k][j])//匹配

{

chessboard[i][j] *= 2;

chessboard[k][j] = 0;

i = k + 1;

flag = true;

}

else if (chessboard[i][j] != chessboard[k][j] && k < 4)//不匹配

{

i = k;

}

}

}

for (j = 0; j < m; j++)//排列棋盤

for (i = 0, count2 = 0; i < m; i++)

{

if (chessboard[i][j] != 0)

{

temp2 = chessboard[i][j];

chessboard[i][j] = 0;

chessboard[count2][j] = temp2;

count2++;

}

}

}

四、判斷游戲結束

bool game::gameover()

{

if (flag)

count1++;//判連消

if (temp1 == count1)

count1 = 0;//未消除,連消歸零

add(count1);

for (i = m - 1, j = 0; j < m; j++)//最後一行

{

if (j == m - 1)//右下角

{

if (chessboard[i][j] == 0)

return false;

else if (chessboard[i][j] == 2048)

{

cout << "You Win~ ";

return true;

}

}

else

{

if (chessboard[i][j] == 0 || chessboard[i][j] == chessboard[i][j + 1])

return false;

else if (chessboard[i][j] == 2048)

{

cout << "You Win~ ";

return true;

}

}

}

for (i = 0, j = m - 1; i < m; i++)//最後一列

{

if (i == m - 1)//右下角

{

if (chessboard[i][j] == 0)

return false;

else if (chessboard[i][j] == 2048)

{

cout << "You Win~ ";

return true;

}

}

else

{

if (chessboard[i][j] == 0 || chessboard[i][j] == chessboard[i + 1][j])

return false;

else if (chessboard[i][j] == 2048)

{

cout << "You Win~ ";

return true;

}

}

}

for (i = 0; i < m - 1; i++)

for (j = 0; j < m - 1; j++)

{

if (chessboard[i][j] == 2048)

{

cout << "You Win! ";

return true;

}

else if (chessboard[i][j] == chessboard[i][j + 1] || chessboard[i][j] == chessboard[i + 1][j] || chessboard[i][j] == 0)

return false;

}

cout << "Game over. ";

return true;

}

(6)用c編寫小游戲擴展閱讀:

C++語言的程序因為要體現高性能,所以都是編譯型的。但其開發環境,為了方便測試,將調試環境做成解釋型的。

生成程序是指將源碼(C++語句)轉換成一個可以運行的應用程序的過程。如果程序的編寫是正確的,那麼通常只需按一個功能鍵,即可搞定這個過程。但是該過程實際上分成兩個步驟。

第一步是對程序進行編譯,這需要用到編譯器(compiler)。編譯器將C++語句轉換成機器碼(也稱為目標碼);

第二步就是對程序進行鏈接,這需要用到鏈接器(linker)。鏈接器將編譯獲得機器碼與C++庫中的代碼進行合並。C++庫包含了執行某些常見任務的函數(「函數」是子程序的另一種稱呼)。

參考資料來源:

網路-C++

『柒』 C語言可以寫哪些小游戲

C語言可以編手機游戲. 你叫他去死 不過我這有 貪吃蛇的代碼,你倒可以看看 (用TC 編譯一定過)

#include
#include
#include
#include
#include
#define Enter 7181
#define ESC 283
#define UP 18432
#define DOWN 20480
#define LEFT 19200
#define RIGHT 19712
#ifdef __cplusplus
#define __CPPARGS ...
#else
#define __CPPARGS
#endif
void interrupt (*oldhandler)(__CPPARGS);
void interrupt newhandler(__CPPARGS);
void SetTimer(void interrupt (*IntProc)(__CPPARGS));
void KillTimer(void);
void Initgra(void);
void TheFirstBlock(void);
void DrawMap(void);
void Initsnake(void);
void Initfood(void);
void Snake_Headmv(void);
void Flag(int,int,int,int);
void GameOver(void);
void Snake_Bodymv(void);
void Snake_Bodyadd(void);
void PrntScore(void);
void Timer(void);
void Win(void);
void TheSecondBlock(void);
void Food(void);
void Dsnkorfd(int,int,int);
void Delay(int);
struct Snake
{int x;int y;int color;}Snk[12];
struct Food
{int x;int y;int color;}Fd;
int flag1=1,flag2=0,flag3=0,flag4=0,flag5=0,flag6=0,
checkx,checky,num,key=0,Times,Score,Hscore,Snkspeed,TimerCounter,TureorFalse;
char Sco[2],Time[6];
void main()
{ Initgra();
SetTimer(newhandler);
TheFirstBlock();
while(1)
{DrawMap();
Snake_Headmv();
GameOver();
Snake_Bodymv();
Snake_Bodyadd();
PrntScore();
Timer();
Win();
if(key==ESC)
break;
if(key==Enter)
{cleardevice();
TheFirstBlock();
}
TheSecondBlock();
Food();
Delay(Snkspeed);
}
closegraph();
KillTimer();
}
void interrupt newhandler(__CPPARGS)
{
TimerCounter++;
oldhandler();
}
void SetTimer(void interrupt (*IntProc)(__CPPARGS))
{
oldhandler=getvect(0x1c);
disable();
setvect(0x1c,IntProc);
enable();
}

void KillTimer()
{
disable();
setvect(0x1c,oldhandler);
enable();
}
void Initgra()
{int gd=DETECT,gm;
initgraph(&gd,&gm,"d:\\tc");
}
void TheFirstBlock()
{setcolor(11);
settextstyle(0,0,4);
outtextxy(100,220,"The First Block");
loop:key=bioskey(0);
if(key==Enter)
{cleardevice();
Initsnake();
Initfood();
Score=0;
Hscore=1;
Snkspeed=10;
num=2;
Times=0;
key=0;
TureorFalse=1;
TimerCounter=0;
Time[0]='0';Time[1]='0';Time[2]=':';Time[3]='1';Time[4]='0';Time[5]='\0';
}
else if(key==ESC) cleardevice();
else goto loop;
}
void DrawMap()
{line(10,10,470,10);
line(470,10,470,470);
line(470,470,10,470);
line(10,470,10,10);
line(480,20,620,20);
line(620,20,620,460);
line(620,460,480,460);
line(480,460,480,20);
}
void Initsnake()
{randomize();
num=2;
Snk[0].x=random(440);
Snk[0].x=Snk[0].x-Snk[0].x%20+50;
Snk[0].y=random(440);
Snk[0].y=Snk[0].y-Snk[0].y%20+50;
Snk[0].color=4;
Snk[1].x=Snk[0].x;
Snk[1].y=Snk[0].y+20;
Snk[1].color=4;
}
void Initfood()
{randomize();
Fd.x=random(440);
Fd.x=Fd.x-Fd.x%20+30;
Fd.y=random(440);
Fd.y=Fd.y-Fd.y%20+30;
Fd.color=random(14)+1;
}
void Snake_Headmv()
{if(bioskey(1))
{key=bioskey(0);
switch(key)
{case UP:Flag(1,0,0,0);break;
case DOWN:Flag(0,1,0,0);break;
case LEFT:Flag(0,0,1,0);break;
case RIGHT:Flag(0,0,0,1);break;

default:break;
}
}
if(flag1)
{checkx=Snk[0].x;
checky=Snk[0].y;
Dsnkorfd(Snk[0].x,Snk[0].y,0);
Snk[0].y-=20;
Dsnkorfd(Snk[0].x,Snk[0].y,Snk[0].color);
}
if(flag2)
{checkx=Snk[0].x;
checky=Snk[0].y;
Dsnkorfd(Snk[0].x,Snk[0].y,0);
Snk[0].y+=20;
Dsnkorfd(Snk[0].x,Snk[0].y,Snk[0].color);
}
if(flag3)
{checkx=Snk[0].x;
checky=Snk[0].y;
Dsnkorfd(Snk[0].x,Snk[0].y,0);
Snk[0].x-=20;
Dsnkorfd(Snk[0].x,Snk[0].y,Snk[0].color);
}
if(flag4)
{checkx=Snk[0].x;
checky=Snk[0].y;
Dsnkorfd(Snk[0].x,Snk[0].y,0);
Snk[0].x+=20;
Dsnkorfd(Snk[0].x,Snk[0].y,Snk[0].color);
}
}
void Flag(int a,int b,int c,int d)
{flag1=a;flag2=b;flag3=c;flag4=d;}
void GameOver()
{int i;
if(Snk[0].x460||Snk[0].y460)
{cleardevice();
setcolor(11);
settextstyle(0,0,4);
outtextxy(160,220,"Game Over");
loop1:key=bioskey(0);
if(key==Enter)
{cleardevice();
TheFirstBlock();
}
else
if(key==ESC)
cleardevice();
else
goto loop1;
}
for(i=3;i<num;i++)
{if(Snk[0].x==Snk[i].x&&Snk[0].y==Snk[i].y)
{cleardevice();
setcolor(11);
settextstyle(0,0,4);
outtextxy(160,220,"Game Over");
loop2:key=bioskey(0);
if(key==Enter)
{cleardevice();
TheFirstBlock();
}
else
if(key==ESC)
cleardevice();
else goto loop2;
}
}
}
void Snake_Bodymv()
{int i,s,t;
for(i=1;i<num;i++)
{Dsnkorfd(checkx,checky,Snk[i].color);
Dsnkorfd(Snk[i].x,Snk[i].y,0);
s=Snk[i].x;
t=Snk[i].y;
Snk[i].x=checkx;
Snk[i].y=checky;
checkx=s;
checky=t;
}
}
void Food()
{if(flag5)
{randomize();
Fd.x=random(440);
Fd.x=Fd.x-Fd.x%20+30;
Fd.y=random(440);
Fd.y=Fd.y-Fd.y%20+30;
Fd.color=random(14)+1;
flag5=0;
}
Dsnkorfd(Fd.x,Fd.y,Fd.color);
}
void Snake_Bodyadd()
{if(Snk[0].x==Fd.x&&Snk[0].y==Fd.y)
{if(Snk[num-1].x>Snk[num-2].x)
{num++;
Snk[num-1].x=Snk[num-2].x+20;
Snk[num-1].y=Snk[num-2].y;
Snk[num-1].color=Fd.color;
}
else
if(Snk[num-1].x<Snk[num-2].x)
{num++;
Snk[num-1].x=Snk[num-2].x-20;
Snk[num-1].y=Snk[num-2].y;
Snk[num-1].color=Fd.color;
}
else
if(Snk[num-1].y>Snk[num-2].y)
{num++;
Snk[num-1].x=Snk[num-2].x;
Snk[num-1].y=Snk[num-2].y+20;
Snk[num-1].color=Fd.color;
}
else
if(Snk[num-1].y<Snk[num-2].y)
{num++;
Snk[num-1].x=Snk[num-2].x;
Snk[num-1].y=Snk[num-2].y-20;
Snk[num-1].color=Fd.color;
}
flag5=1;
Score++;
}
}
void PrntScore()
{if(Hscore!=Score)
{setcolor(11);
settextstyle(0,0,3);
outtextxy(490,100,"SCORE");
setcolor(2);
setfillstyle(1,0);
rectangle(520,140,580,180);
floodfill(530,145,2);
Sco[0]=(char)(Score+48);
Sco[1]='\0';
Hscore=Score;
setcolor(4);
settextstyle(0,0,3);
outtextxy(540,150,Sco);
}
}
void Timer()
{if(TimerCounter>18)
{Time[4]=(char)(Time[4]-1);
if(Time[4]<'0')
{Time[4]='9';
Time[3]=(char)(Time[3]-1);
}
if(Time[3]<'0')
{Time[3]='5';
Time[1]=(char)(Time[1]-1);
}
if(TureorFalse)
{setcolor(11);
settextstyle(0,0,3);
outtextxy(490,240,"TIMER");
setcolor(2);
setfillstyle(1,0);
rectangle(490,280,610,320);
floodfill(530,300,2);
setcolor(11);
settextstyle(0,0,3);
outtextxy(495,290,Time);
TureorFalse=0;
}
if(Time[1]=='0'&&Time[3]=='0'&&Time[4]=='0')
{setcolor(11);
settextstyle(0,0,4);
outtextxy(160,220,"Game Over");
loop:key=bioskey(0);
if(key==Enter)
{cleardevice();
TheFirstBlock();
}
else if(key==ESC) cleardevice();
else goto loop;
}
TimerCounter=0;
TureorFalse=1;
}
}
void Win()
{if(Score==3)
Times++;
if(Times==2)
{cleardevice();
setcolor(11);
settextstyle(0,0,4);
outtextxy(160,220,"You Win");
loop:key=bioskey(0);
if(key==Enter)
{cleardevice();
TheFirstBlock();
key=0;
}
else if(key==ESC) cleardevice();
else goto loop;
}
}
void TheSecondBlock()
{if(Score==3)
{cleardevice();
setcolor(11);
settextstyle(0,0,4);
outtextxy(100,220,"The Second Block");
loop:key=bioskey(0);
if(key==Enter)
{cleardevice();
Initsnake();
Initfood();
Score=0;
Hscore=1;
Snkspeed=8;
num=2;
key=0;
}
else if(key==ESC) cleardevice();
else goto loop;
}
}
void Dsnkorfd(int x,int y,int color)
{setcolor(color);
setfillstyle(1,color);
circle(x,y,10);
floodfill(x,y,color);
}
void Delay(int times)
{int i;
for(i=1;i<=times;i++)
delay(15000);
}

『捌』 小游戲C語言程序

下落的小鳥

#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include<time.h>
#include<Windows.h>
int Grade = 1, Score = 0, Max_blank = 9, Distance = 18;
struct Birds{int x; int y;}; //定義一種Birds數據類型(含3個成員)
Birds *Bird = (Birds*)malloc(sizeof(Birds)); //定義Birds類型 指針變數Bird並賦初值
struct Bg{int x, y; int l_blank; Bg *pri; Bg *next;}; //定義一種Bg數據類型(含5個成員)
Bg *Bg1 = (Bg*)malloc(sizeof(Bg)); //定義Bg類型 指針變數Bg1並賦初值

void Position(int x, int y) //游標定位函數(用於指定位置輸出)
{COORD pos = { x - 1, y - 1 };
HANDLE Out = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(Out, pos);
}

void Csh( ) //初始化界面

{

printf("══════════════════════════════════════ ");

printf(" ■■ ■■ C語言版 Flappy Bird ");

printf(" ■■ ■■ ");

printf(" ■■ ■■ ");

printf(" ■■ ■■ 瞎搞人:yyposs原創 ");

printf(" ■■ ■■ 瞎搞日期:2014.2 ");

printf(" ■■ ■■ ");

printf(" ■■ ■■ 改編:鳴蟬百2021.7 ");

printf(" ■■ ■■ 操作:按向上方向鍵讓小鳥起飛 ");

printf(" ■■ ");

printf(" ■■ ");

printf(" ■■ ■■ ");

printf(" ■■ ■■ ");

printf(" ■■ ■■ ");

printf(" ■■ ■■ ");

printf(" ■■ ■■ DEVc++運行通過 ");

printf("══════════════════════════════════════ ");

printf(" 按鍵繼續…");

getch( );

system("cls");

}

void PrFK( ) //輸出方框(游戲范圍區)

{int i;

Position(1, 1); printf("╔"); Position(79, 1); printf("╗");

Position(1, 24); printf("╚"); Position(79, 24); printf("╝");

for (i = 3; i <= 78; i += 2){Position(i, 1); printf("═"); Position(i, 24); printf("═");}

for(i=2;i<=23;i++)

{ Position(1,i); printf("║");if(i<11)printf("0%d",i-1);else printf("%d",i-1);

Position(79,i); printf("║");

}

Position(4, 25); printf("小鳥即將出現,請准備按鍵起飛… ");

getch( );

Position(4, 25); printf(" ");

}

void CreatBg( ) //創建障礙物坐標(便於列印輸出)
{Bg *Bg2 = (Bg*)malloc(sizeof(Bg));
Bg1->x = 90; Bg1->y = 8; //確定障礙物的一對基本坐標(此時值是在游戲框之外)
Bg2->x = Bg1->x + Distance; Bg2->y = 9; //下一障礙物的基本坐標x、y
Bg1->l_blank = Max_blank - Grade; //障礙物上下兩部分之間的空白距離l_blank
Bg2->l_blank = Max_blank - Grade;
Bg1->next = Bg2; Bg1->pri = Bg2;
Bg2->next = Bg1; Bg2->pri = Bg1;
}


void InsertBg(Bg *p) //隨機改變障礙物的y坐標,讓空白通道有上下變化
{int temp;
Bg *Bgs = (Bg*)malloc(sizeof(Bg));
Bgs->x = p->pri->x + Distance;
Bgs->l_blank = Max_blank - Grade;
srand((int)time(0)); //啟動隨機數發生器
temp = rand( ); //產生一個隨機數並賦值給temp
if (temp % 2 == 0)
{if ((temp % 4 + p->pri->y + Max_blank - Grade)<21)
Bgs->y = p->pri->y + temp % 4;
else Bgs->y = p->pri->y;
}
else
{if ((p->pri->y - temp % 4)>2)Bgs->y = p->pri->y - temp % 4;
else Bgs->y = p->pri->y;
}
Bgs->pri = p->pri; Bgs->next = p;
p->pri->next = Bgs; p->pri = Bgs;
}

void CreatBird( ) //建立小鳥的坐標(初始列印輸出小鳥的位置)
{Bird->x = 41; Bird->y = 10;}

int CheckYN(Bg *q) //判斷游戲結束與否(值為0是要結束,為1沒有要結束)
{Bg *p = q; int i = 0;
while (++i <= 5)
{if (Bird->y>23)return 0;
if (Bird->x == p->x&&Bird->y <= p->y)return 0;
if ((Bird->x == p->x || Bird->x == p->x + 1 || Bird->x == p->x + 2) && Bird->y == p->y)return 0;
if (Bird->x == p->x&&Bird->y>p->y + p->l_blank)return 0;
if ((Bird->x == p->x || Bird->x == p->x + 1 || Bird->x == p->x + 2) && Bird->y == p->y + p->l_blank)
return 0;
p = p->next;
}
return 1;
}


void Check_Bg(Bg *q) //核查開頭的障礙物坐標是否在游戲區內
{Bg *p = q; int i = 0, temp;
while (++i <= 5)
{if (p->x>-4)p = p->next;
else
{srand((int)time(0)); temp = rand();
if (temp % 2 == 0)
{if ((temp % 4 + p->y + Max_blank - Grade)<21)p->y = p->y + temp % 4;
else p->y = p->y; p->x = p->pri->x + Distance;
p->l_blank = Max_blank - Grade;
}
else
{if ((p->y - temp % 4)>2)p->y = p->y - temp % 4;
else p->y = p->y; p->x = p->pri->x + Distance;
p->l_blank = Max_blank - Grade;
}
}
}
}

void Prt_Bg(Bg *q) //列印輸出障礙物(依據其x、y坐標進行相應輸出)
{Bg *p = q; int i = 0, k, j;
while (++i <= 5)
{if (p->x>0 && p->x <= 78)
{for (k = 2; k<p->y; k++){Position(p->x + 1, k); printf("■"); printf("■"); printf(" ");}
Position(p->x, p->y);
printf("■"); printf("■"); printf("■"); printf(" ");
Position(p->x, p->y + p->l_blank);
printf("■"); printf("■"); printf("■"); printf(" ");
k = k + p->l_blank + 1;
for (k; k <= 23; k++){Position(p->x + 1, k); printf("■"); printf("■"); printf(" ");}
}
p = p->next;
if (p->x == 0)
{for (j = 2; j<p->y; j++){Position(p->x + 1, j); printf(" "); printf(" ");}
Position(p->x + 1, p->y);
printf(" "); printf(" "); printf(" ");
Position(p->x + 1, p->y + Max_blank - Grade);
printf(" "); printf(" "); printf(" ");
j = j + Max_blank - Grade + 1;
for (j; j <= 22; j++){Position(p->x + 1, j); printf(" "); printf(" ");}
}
}
}

void PrtBird( ) //列印輸出小鳥
{Position(Bird->x, Bird->y - 1); printf(" ");
Position(Bird->x, Bird->y); printf("Ю");
Position(38, 2); printf("Score:%d", Score);
}
void Loop_Bg(Bg *q) //障礙物x坐標左移,並記錄成績
{Bg *p = q; int i = 0;
while (++i <= 5)
{p->x = p->x - 1; p = p->next;
if (Bird->x == p->x)
{Score += 1;
if (Score % 4 == 0 && Grade<4)Grade++;
}
}
}

int main( )
{int i = 0; int t;

while (1)

{
Csh( );PrFK( );CreatBg( );
InsertBg(Bg1);InsertBg(Bg1);InsertBg(Bg1);
CreatBird( );
while (1)
{if (!CheckYN(Bg1))break;
Check_Bg(Bg1);Prt_Bg(Bg1);
PrtBird( );Loop_Bg(Bg1);
Bird->y = Bird->y + 1;
if (GetAsyncKeyState(VK_UP)) //按下了向上方向鍵
{Position(Bird->x, Bird->y - 1);printf(" ");
Bird->y = Bird->y - 4;
}
Sleep(200); //程序延時200毫秒(數值大小決定游戲速度快慢)
i = 0;
}
Position(6, 25);
printf("游戲結束! 請輸入:0.退出 1.重玩");

scanf("%d",&t);

if (t==0)break;

system("cls"); Score = 0;

}
return 0;
}

『玖』 使用C語言編寫小游戲的方法是什麼

#include
#include
#include
#include "windows.h"
void gotoxy(int x,int y) /*定義gotoxy函數*/
{
COORD c;
c.X=x-1;
c.Y=y-1;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),c);
}
int main()
{
struct point
{
int x, y;/*該點的位置,包括x坐標和y坐標*/
int xv, yv;/*該點在x軸,y軸的速度*/
}man;
long p;
man.x=man.y=20;
man.xv=man.yv=1;
system("cls");
p=1000000000000000;
while(p--)
{
if(p%50000)
continue;
gotoxy(man.x, man.y);/*把游標移到指定的坐標*/
printf(" ");/*輸出一個空格,把先前的字元擦去*/
man.x += man.xv;/*水平方向按x軸的速度運動*/
man.y += man.yv;/*垂直方向按y軸的速度運動*/
if(man.x==0||man.x==80)
man.xv*=-1;
if(man.y==0||man.y==80)
man.yv*=-1;
gotoxy(man.x, man.y);
printf("%c\b", 2); /*輸出ASCII碼值為2的"笑臉"字元*/
}
getchar ();
return 0;
}

這個是一個會動的笑臉,你可以從最簡單開始

熱點內容
絕地求生未來之役比賽為什麼進不去 發布:2023-08-31 22:07:08 瀏覽:1263
dota2位置什麼意思 發布:2023-08-31 22:00:04 瀏覽:708
lol電競是什麼樣子 發布:2023-08-31 21:58:40 瀏覽:1161
絕地求生八倍鏡的那個圓圈怎麼弄 發布:2023-08-31 21:58:31 瀏覽:1225
lol龍龜一個多少金幣 發布:2023-08-31 21:55:07 瀏覽:613
王者如何改游戲內名稱 發布:2023-08-31 21:55:06 瀏覽:903
游戲主播打廣告是什麼意思 發布:2023-08-31 21:55:06 瀏覽:1557
絕地求生如何免費拿到ss7賽季手冊 發布:2023-08-31 21:52:13 瀏覽:779
pgg是哪個國家的戰隊lol 發布:2023-08-31 21:52:07 瀏覽:660
一個人的時候才發現游戲很沒意思 發布:2023-08-31 21:49:24 瀏覽:1258