分类: 未分类
2020C教程大纲
环境搭建
环境搭建说明
1.基础操作
https://blog.hylstudio.cn/archives/686
2.循环增强训练
https://blog.hylstudio.cn/archives/688
3.井字棋的实现
https://blog.hylstudio.cn/archives/690
4.函数、指针、结构体重构井字棋
TODO
大纲
介绍程序框架
学习printf
打印固定字符/字符串
引入字符变量
打印变量
引入逻辑表达式、判断
根据条件打印字符/字符串
引入scanf
学习字符的输入
根据输入内容打印字符/字符串
引入for循环
学习打印固定次数/不固定次数
打印各种三角形
引入system(“cls”)
制作简易字符动画
井字棋棋盘/棋子打印
编写游戏操作逻辑
引入循环控制
制作游戏流程控制
引入数组
支持游戏状态内存判断,胜负判定
引入二维数组
简易数据结构struct
引入内存分配
面向对象的本质
劣质的人工智障程序
相关代码和题目
2019C语言题目2-循环强化
循环强化
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
1.打印下列图形 |***********| |***********| |***********| |***********| |* | |*** | |***** | |******* | |********* | |***********| |***********| |********* | |******* | |***** | |*** | |* | | *| | ***| | *****| | *******| | *********| |***********| |***********| | *********| | *******| | *****| | ***| | *| | * | | *** | | ***** | | ******* | | ********* | |***********| |
答案如下
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
#include <stdio.h> // http://blog.hylstudio.cn/archives/686 int main(int argc, char const *argv[]) { // 1.1 给你找规律的,主要强化循环 // printf("|***********|\n"); // printf("|***********|\n"); // printf("|***********|\n"); // printf("|***********|\n"); // 1.2 int columns = 11; int rows = 4; int i = 0; int j = 0; for (i = 0; i < rows; i++) { //打印每行 printf("|"); for (j = 0; j < columns; j++) { //打印每列 printf("*"); } printf("|\n"); } return 0; } |
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
#include <stdio.h> // http://blog.hylstudio.cn/archives/686 // |* | // |*** | // |***** | // |******* | // |********* | // |***********| int main(int argc, char const *argv[]) { int columns = 11; int rows = 6; int i = 0; int j = 0; int stars = 0; // 1 3 5 7 9 => i * 2 + 1 int space = 0; // columns - stars for (i = 0; i < rows; i++) { //打印每行 printf("|"); for (j = 0; j < i * 2 + 1; j++) { //打印* printf("*"); } for (j = 0; j < columns - (i * 2 + 1); j++) { printf(" "); } printf("|\n"); } printf("下面是骚操作,数学好的人可以看看\n"); for (i = 0; i < rows; i++) { //打印每行 printf("|"); for (j = 0; j < columns; j++) { if (i * 2 >= j) { printf("*"); } else { printf(" "); } } printf("|\n"); } return 0; } |
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
#include <stdio.h> // http://blog.hylstudio.cn/archives/686 // |***********| // |********* | // |******* | // |***** | // |*** | // |* | int main(int argc, char const *argv[]) { int columns = 11; int rows = 6; int i = 0; int j = 0; int stars = 0; // 1 3 5 7 9 => i * 2 + 1 int space = 0; // columns - stars //解法不唯一,能算对就行 for (i = rows - 1; i >= 0; i--) { //打印每行 printf("|"); for (j = i * 2 + 1 - 1; j >= 0; j--) { //打印* printf("*"); } for (j = columns - (i * 2 + 1) - 1; j >= 0; j--) { printf(" "); } printf("|\n"); } //一次方程求解同理,懒得写了,自己找找规律 return 0; } |
接下来的两个对每列的打印顺序反转下就行
最后一个把前面的空格数除2,分三段打印就行,留给你们自己练习用
记一次电脑无法联网的排查过程
本着多年修电脑使用电脑的经验,连不上网这种问题还是很常见的。目前为止,我碰到过没交网费的,没开Wifi开关的,记错账号密码的,Win8自带无线驱动有坑的等等等等各种问题。今天碰到一个神奇的电脑居然花了我将近半个小时才搞定,特此记录,复盘整个过程。
笔记本型号:Lenovo某型号,CPUi5,系统Win8.1中文版
现象:wifi可正常连接但显示无联网权限。无法上网。
路由器为极路由,网关地址为默认192.168.199.1。
其他台电脑和手机均可正常连接使用,可以排除wifi路由器配置错误,排除无网费的情况。
查看IP和DNS获取正常,所以排除DHCP服务器配置错误。
虽然IP和DNS获取正常,但尝试使用nslookup 无法解析网址,并且ping无法联通网关。
如果尝试更改IP会提示“为配置tcp/ip必须安装并启用网络适配卡”
尝试越过DNS直接访问百度的IP,页面无响应。
查看安装的协议,去掉leibao共享精灵重试,无效。排除这个协议的影响。
到此为止依然没有进展,经过百度提示需要重装驱动。
等等!驱动???这是Win8/Win8.1啊,瞬间反映过来无线可能是自带的驱动,在Win8/8.1下,自带的无线驱动可以正常连接网络,但PPPOE和无线网络都有可能出现连接成功但无法上网的BUG,也不知道现在软爹修了没=-=
但是重装系统太麻烦了,电脑又连不上网,所以考虑使用设备管理器更换同品牌其他型号驱动。
果然成功了=-=
一个好玩的C语言程序
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
/** * 作者:Kola * 链接:http://www.zhihu.com/question/22715390/answer/34294761 * 来源:知乎 * 著作权归作者所有,转载请联系作者获得授权。 */ #include"stdio.h" #include"windows.h" #include"string.h" #include"conio.h" #include"time.h" typedef struct pipe { int x; int y; struct pipe *next; }PIPE; char backGround[14][80]={0}; int Time=0; unsigned int Score=0; void HideCursor() { CONSOLE_CURSOR_INFO cursor_info={1,0}; SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE),&cursor_info); } void gotoxy(int x, int y) { COORD coord; coord.X=x; coord.Y=y; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),coord); } void Getready() { int i=0, j=0; for(i=0; i<11; i++) for(j=0;j<80;j++) backGround[i][j]=' '; for(i=0; i<8; i++) strcat(backGround," ┌┐ "); for(i=0; i<8; i++) strcat(backGround,"┌┤│ "); for(i=0; i<8; i++) strcat(backGround,"││├┐ "); puts(backGround); gotoxy(30, 3); printf("G e t R e a d y"); gotoxy(0, 14); for(i=0; i < 40; i++) printf("▁"); for(i=0; i < 11; i++) printf(" ╱╱ "); gotoxy(0, 16); for(i=0; i < 40; i++) printf("▔"); gotoxy(18, 3); printf("*@>"); getch(); gotoxy(30, 3); printf(" "); } PIPE *Pipefun(PIPE *h) { int i=0, j=0; PIPE *p; for(p=h,i=0;i<6; i++) { for(j=0; j<14; j++) { if( j==p->y-1 || j==p->y || j==p->y+1 ) continue; else { if(p->x >= 0 && p->x < 80) gotoxy(p->x, j),printf("■"); if(p->x+2>=0 && p->x+2<80) gotoxy(p->x+2, j),printf("■"); if(p->x+4>=0 && p->x+4<80) gotoxy(p->x+4, j), printf("%c%c",backGround[j][p->x+4],backGround[j][p->x+5]); } } p->x=p->x-2; p=p->next ; } if(h->x < -4) { h->x=78+12; h->y=rand()%9+3; h=h->next; } return h; } void Bird() { int i=0,bird=3,temp=0; char ch='0'; PIPE *h,*p,*q; p=h=q=(PIPE *)malloc(sizeof(PIPE)); for(i=0; i<5; i++) { p->x=78+16*i; p->y=rand()%9+3; q=(PIPE *)malloc(sizeof(PIPE)); p->next=q; q->next=NULL; p=q; } p->x=78+16*i; p->y=rand()%13+1; q->next=h; while(1) { Time++; temp = bird; if(kbhit()) ch=getch(); ch==' '?bird--:bird++; ch = '0'; if(bird<0 || bird>=14) break; gotoxy(18, temp); printf(" %c%c", backGround[temp][20], backGround[temp][21]); gotoxy(18, bird); printf("*@>"); if(Time%3==1) h=Pipefun(h); for(p=h,i=0; i<6; i++,p=p->next) if(p->x==18 && p->y-1!=bird && p->y!=bird && p->y+1!=bird) break; if(p->x==18 && p->y-1!=bird && p->y!=bird && p->y+1!=bird) break; Sleep(300); }//end of while }//end of Bird void Gameover() { Score=(Time-88)/24<0?0:(Time-88)/24; gotoxy(28, 5); printf("┌──────────┐"); gotoxy(28, 6); printf("│ G A M E O V E R │"); gotoxy(28, 7); printf("│ │"); gotoxy(28, 8); printf("│ %4d │",Score); gotoxy(28, 9); printf("└──────────┘"); }//end of Gameover int main() { HideCursor(); system("title Flappy Bird for c"); system("mode con cols=80 lines=20"); srand((unsigned)time(NULL)); Getready(); Bird(); Gameover(); getch(); } |
【资源导航】
欢迎来到我的博客。
预告:最近即将更新的内容=-=
Skykoma系列
云端开发环境 https://github.com/dev-assistant/skykoma-workspace
IDE自动化 https://github.com/dev-assistant/skykoma-plugin-idea
服务器搭建系列
录屏 https://space.bilibili.com/7757632/channel/collectiondetail?sid=3917759&ctype=0
文章 https://blog.hylstudio.cn/archives/category/fuwuqi
MDSE实践计划系列
尝试完成部分半自动化的开发流程,部分可投入生产
20211023.Web后端参数检查的通用代码生成设计与实现
其他已填flag
1.数据结构 https://github.com/956237586/DataStructure-C
2.从零实现Web服务器:包含从Socket层实现部分HTTP协议,手动实现模板引擎、路由等功能。视频已发布,仅作原理性说明,未做工程化重构 https://www.bilibili.com/video/BV18h41147b8/
3.C语言教程
C语言系列基础教程(传统讲法) http://blog.hylstudio.cn/archives/174
2020年版本(井字棋) https://blog.hylstudio.cn/archives/746