[ _ (: З ) ∠ ) _ salty _ (: з ) ∠ ) _ fish _ (: з ) ∠ ) _ This _ (: з ) ∠ ) _ fish _ (: з ) ∠ )]
[] Sort of knowledge
[Example] analysis Code
【first question】
Title: Special output pattern, run the c environment, take a look, Very Beautiful!
Ideas: emmmmmmmmm principle probably like character ASCII code corresponding output.
1 #include<stdio.h> 2 3 int main() 4 { 5 char a = 2, b = 12; 6 printf("%c%c%c%c%c\n", b, a, a, a, b); 7 printf("%c%c%c%c%c\n", a, b, a, b, a); 8 printf("%c%c%c%c%c\n", a, a, b, a, a); 9 printf("%c%c%c%c%c\n", a, b, a, b, a); 10 printf("%c%c%c%c%c\n", b, a, a, a, b); 11 12 system("pause>nul"); 13 return 0; 14 }
operation result:
I do question the experience: a little understanding of what the Chinese character coding table GB2312-1980, is divided into 94 zones, each 94 characters. Representation roughly "area code - character digit number." Different default code page represents a different result this knowledge to be further understood.
[Second question]
Title: Output 9 * 9 formulas.
Ideas: The key point of this problem is that the output lower triangular matrix.
To ensure that the i-th row of the column j = i and cut out of the loop.
1 #include <stdio.h> 2 3 int main() 4 { 5 //变量初始化 6 int i = 0; 7 int j = 0; 8 9 //遍历9*9矩阵 10 for (i = 1; i <= 9; i++) 11 { 12 //在矩阵对角线处截断 13 for (j = 1; j <= i; j++) 14 { 15 printf("\t%d×%d=%d", j, i, i*j); 16 } 17 //截断后换行 18 printf("\n"); 19 } 20 21 system("pause>nul"); 22 return 0; 23 }
运行结果:
做题心得:因为口诀的原理其实就是“列行得几”,所以输出的时候先输出列j再输出行i,否则口诀就毁了。
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
今晚装了宿舍路由器,还和爸妈视频了一下,另外刷题效率确实不高,思维过于发散。之后会尽量收敛思路,先完成题目再发散思维。国庆我会补上后四题的_(:з)∠)_
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
【第九题】
题目:要求输出国际象棋棋盘。
思路:此题和第七题相似之处就是输出字符。
不同之处在于我们可以通过循环来输出。
运行结果:
做题心得:
【第十题】
题目:
思路:
运行结果:
做题心得:
【第十一题】
题目:
思路:
运行结果:
做题心得:
【第十二题】
题目:
思路:
运行结果:
做题心得: