6.16.3 使用嵌套循环,按下面格式打印字母:
F
FE
FED
FEDC
FEDCB
FEDCBA
1 #include <stdio.h> 2 3 int main() 4 { 5 const int ROWS = 6; 6 7 for (int row(0); row != ROWS; ++row) 8 { 9 for (char ch(‘F‘); ch >= ‘F‘ - row; --ch) 10 printf("%c",ch); 11 12 printf("\n"); 13 } 14 15 return 0; 16 }
6.16.4 使用嵌套循环,按下面格式打印字母:
A
BC
DEF
GHIJ
KLMNO
PQRSTU
1 #include <stdio.h> 2 3 int main() 4 { 5 const int ROWS = 6; 6 const int COLS = 6; 7 char ch = ‘A‘; 8 9 for (int row(0); row != ROWS; ++row) 10 { 11 for (int col(0); col <= row; ++col, ++ch) 12 printf("%c", ch); 13 14 printf("\n"); 15 } 16 17 return 0; 18 }
原文:https://www.cnblogs.com/web1013/p/9074514.html