---
# System prepended metadata

title: 小恐龍

---

# 小恐龍
將原程式碼加上開頭及重新開始之功能
## 開頭
印出小恐龍圖案，表示此遊戲為小恐龍。
```c=
void initGame()
{
    printf("                      GGGGGGGGGGGGGGGG\n");
    printf("                      GGGGGGGGGGGGGGGG\n");
    printf("                    GGGG  GGGGGGGGGGGGGGj\n");
    printf("                    GGGG  GGGGGGGGGGGGGGj\n");
    printf("                    GGGGGGGGGGGGGGGGGGGGj\n");
    printf("                    GGGGGGGGGGGGGGGGGGGGj\n");
    printf("                    GGGGGGGGGGGGGGGGGGGGj\n");
    printf("                    GGGGGGGGGGGGGGGGGGGGj\n");
    printf("                    GGGGGGGGGG\n");
    printf("                    GGGGGGGGGG\n");
    printf("                    GGGGGGGGGGffffff\n");
    printf("Gj                DGGGGGGGGG\n");
    printf("Gj                GGGGGGGGGG\n");
    printf("Gj             GGGGGGGGGGGGG\n");
    printf("Gj             GGGGGGGGGGGGG\n");
    printf("GDGG           GGGGGGGGGGGGG\n");
    printf("GGGG        GGGGGGGGGGGGGGGGGGGG\n");
    printf("GGGDff      GGGGGGGGGGGGGGGG  GG\n");
    printf("GGGGGG    GGGGGGGGGGGGGGGGGG  GG\n");
    printf("GGGGGD    GGGGGGGGGGGGGGGGGG\n");
    printf("GGGGGGGGGGGGGGGGGGGGGGGGGGGG\n");
    printf("GGGGGGGGGGGGGGGGGGGGGGGGGGGG\n");
    printf("fLGGGGGGGGGGGGGGGGGGGGGGGGGG\n");
    printf(" GGGGGGGGGGGGGGGGGGGGGGGGGjj\n");
    printf("    GGGGGGGGGGGGGGGGGGGGGG\n");
    printf("    GGGGGGGGGGGGGGGGGGGGGG\n");
    printf("        GGGGGGGGGGGGGGGG\n");
    printf("        GGGGGGGGGGGGGGGG\n");
    printf("        GGGGGGGGGGGGGj\n");
    printf("        GDGGGGGGGGGGGf\n");
    printf("          GGGGGG  GGGj\n");
    printf("          GGGG      Gf\n");
    printf("          GG        Gf\n");
    printf("          GG        Gf\n");
    printf("          GGGG      GGGG\n");
    printf("          GGGG      GGGG\n");
	
    printf("Press Blank Key to Start.\n");
    system("pause");
}
```
## 重新開始（Restart）
加入重新開始功能，即可不關閉程式再次遊玩
```c=
while(1)//將主程式用while(1)包起
{
    int i;
    int playerPos = 6;
    int sleeptime = 500;
    char floor1[CANVAS], floor2[CANVAS];
    int curFloor = 1;
    int runtime = 0;
	int score = 0;
	srand(time(0));
	    
	for(i = 0; i < CANVAS; i++)
	{
	    floor1[i]='_';
	    floor2[i]=' ';
    }
	floor1[CANVAS-1]='X';
		
    while(1)
    {
	if(isDead(curFloor, playerPos, floor1) == 1)
	{
            break;
	}
        剩餘主程式
    }

}
```