xxxx18一60岁hd中国/日韩女同互慰一区二区/西西人体扒开双腿无遮挡/日韩欧美黄色一级片 - 色护士精品影院www

資源簡介

此貪吃蛇小游戲用c語言編寫,鏈表實(shí)現(xiàn),圖形界面基于curses庫實(shí)現(xiàn),界面有計(jì)時器,還可以實(shí)時記錄分?jǐn)?shù),顯示當(dāng)前分?jǐn)?shù),上一次游戲分?jǐn)?shù),歷史游戲最高分?jǐn)?shù)。

資源截圖

代碼片段和文件信息


#include“main.h“
#include
#define?LAST_SCORE_FILE?“./last_score.txt“
#define?HIGHEST_SCORE_FILE?“./highest_score.txt“




void?Write_data(int?scoreint?write_file)
{

if(write_file==1)
{
FILE?*fpWrite1=fopen(LAST_SCORE_FILE“w“);
fprintf(fpWrite1“%d\n“score);
fclose(fpWrite1);
}
if(write_file==2)
{
FILE?*fpWrite2=fopen(HIGHEST_SCORE_FILE“w“);
fprintf(fpWrite2“%d\n“score);
fclose(fpWrite2);
}

}

int?Read_data(int?read_file)
{
if?(read_file==1)
{
int?last_score;
FILE?*fpRead=fopen(LAST_SCORE_FILE“r“);
fscanf(fpRead“%d“&last_score);
fclose(fpRead);
return?last_score;
}
if?(read_file==2)
{
int?highest_score;
FILE?*fpRead=fopen(HIGHEST_SCORE_FILE“r“);
fscanf(fpRead“%d“&highest_score);
fclose(fpRead);
return?highest_score;
}

}




int?Compare(int?current_score)
{
highest_score=Read_data(2);
if(highest_score<=current_score)
{
highest_score=current_score;
Write_data(highest_score2);
}
return?highest_score;
}



評論

共有 條評論

相關(guān)資源