循环强化
| 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,分三段打印就行,留给你们自己练习用