用C语言写出 * *** ***** ******* HHOHH ZZZZZ
时间: 2024-03-11 12:42:20 浏览: 19
你可以使用循环和条件语句来实现这个图案。以下是用C语言编写的代码示例:
```c
#include <stdio.h>
int main() {
int rows = 5;
int i, j;
for (i = 1; i <= rows; i++) {
// 打印空格
for (j = 1; j <= rows - i; j++) {
printf(" ");
}
// 打印星号
for (j = 1; j <= 2 * i - 1; j++) {
printf("*");
}
// 打印空格
for (j = 1; j <= rows - i; j++) {
printf(" ");
}
printf("\n");
}
printf("HHOHH\n");
printf("ZZZZZ\n");
return 0;
}
```
运行以上代码,将会输出以下图案:
```
*
***
*****
*******
*********
HHOHH
ZZZZZ
```
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![dll](https://img-home.csdnimg.cn/images/20210720083646.png)
![md](https://img-home.csdnimg.cn/images/20210720083646.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)