摘要: //5-1单纯记忆训练,记忆4位数 #include #include #include #define MAX_STAGE 10 //关卡数 int sleep(unsigned long x){ clock_t c1 = clock(), c2; do{ if((c2 = clock()) == (clock_t)-1) re... 阅读全文
posted @ 2018-01-26 22:31 LeoSirius 阅读(217) 评论(0) 推荐(0) 编辑
摘要: //4-3把读到的字符串形式的整数转换为数值显示 #include #include int main(){ char temp[20]; printf("请输入整数:"); scanf("%s", temp); printf("你输入了%d。\n", atoi(temp)); return 0; } //4-6珠玑妙算 #include #inclu... 阅读全文
posted @ 2018-01-25 21:50 LeoSirius 阅读(267) 评论(0) 推荐(0) 编辑
摘要: //3-1猜拳游戏, 其一 #include #include #include int main(){ int human; int comp; int judge; int retry; srand(time(NULL)); printf("猜拳游戏开始!!\n"); do{ comp = rand() % ... 阅读全文
posted @ 2018-01-25 20:23 LeoSirius 阅读(192) 评论(0) 推荐(0) 编辑
摘要: //2-1输出\a和\n #include int main(){ printf("你好。\n初次见面。\n"); printf("\a警告。\n\n"); printf("\a\a这次是第二次警告。\n"); return 0; } //2-2\b使用实例,每个1秒消去一个字符 #include #include int sleep(unsigned lo... 阅读全文
posted @ 2018-01-24 22:44 LeoSirius 阅读(159) 评论(0) 推荐(0) 编辑
摘要: //1-1通过if语句实现猜数游戏 #include int main(){ int no; int ans = 7; printf("请猜一个0~9的整数。\n\n"); printf("是多少呢:"); scanf("%d", &no); if (no > ans) printf("\a再小一点。\n"); ... 阅读全文
posted @ 2018-01-24 14:42 LeoSirius 阅读(144) 评论(0) 推荐(0) 编辑
摘要: 学完数组的概念后,有一个简单的小游戏特别适合上手 生命游戏,假设有int Cells[30][30],也即有30×30个小格子,每个小格子里面可以有细胞生命,或者细胞死亡。通过把这些状态输出出来,就可以显示出相应的图案。生命游戏演化的规则: 每个矩阵方格可以包含一个有机体,不在边上的有机体有8个相邻 阅读全文
posted @ 2018-01-23 21:26 LeoSirius 阅读(183) 评论(0) 推荐(0) 编辑
摘要: #include #include #include #include int high, width; //游戏画面大小 int bird_x, bird_y; //小鸟的坐标 int bar1_y, bar1_xDown, bar1_xTop; //障碍物 int score; //得分,经过障碍物的个数 void gotoxy(int x, int y... 阅读全文
posted @ 2018-01-23 18:29 LeoSirius 阅读(150) 评论(0) 推荐(0) 编辑
摘要: #include #include #include #include int position_x, position_y; //飞机位置 int bullet_x, bullet_y; //子弹位置 int enemy_x, enemy_y; //敌机位置 int high, width; //游戏画面尺寸 int score; ... 阅读全文
posted @ 2018-01-23 15:02 LeoSirius 阅读(164) 评论(0) 推荐(0) 编辑
摘要: #include #include #include void main(){ int i, j; int x = 5; int y = 10; char input; int isFire = 0; int ny = 5; int isKilled = 0; while(1){ system("... 阅读全文
posted @ 2018-01-22 22:36 LeoSirius 阅读(193) 评论(0) 推荐(0) 编辑
摘要: #include #include #include void main(){ int i, j; int x = 0; int y = 5; int velocity_x = 1; int velocity_y = 1; int left = 0; int right = 20; int top = 0; i... 阅读全文
posted @ 2018-01-22 22:30 LeoSirius 阅读(220) 评论(0) 推荐(0) 编辑