编写程序输出如下*号组成的图形,*号的行数由键盘输入。 * * * * * * * * * * * * * * * * * * * * *
时间: 2023-11-24 18:06:25 浏览: 56
以下是C语言的代码实现,可以输出由*号组成的图形,*号的行数由键盘输入:
```c
#include <stdio.h>
int main() {
int n,i,j;
printf("请输入一个整数:");
scanf("%d",&n);
for(i = 1; i <= n; i++) {
for(j = 1; j <= n-i; j++)
printf(" ");
for(j = 1; j <= i; j++)
printf("* ");
printf("\n");
}
return 0;
}
```
相关问题
用循环控制语句编写程序输出如下*号组成的图形,*号的行数由键盘输入. * * * * * * * * * * * * * * * * * * * * *
以下是用循环控制语句编写程序输出如下*号组成的图形的代码:
```
#include <stdio.h>
#include <stdlib.h>
int main() {
int n;
printf("请输入行数:");
scanf("%d", &n);
for (int i = n; i >= 1; i--) {
for (int j = 1; j <= i; j++) {
printf("* ");
}
printf("\n");
}
return 0;
}
```
编写程序输出如下*号组成的图形,*号的行数由键盘输入。 * * * * * * * * * * * * * * * * * * * * * 的C语言程序代码:
下面是一个可以实现该功能的C语言程序代码:
```
#include <stdio.h>
#include <stdlib.h>
int main() {
int n, i, j;
printf("请输入行数:");
scanf("%d", &n);
for (i = n; i >= 1; i--) {
for (j = 1; j <= i; j++) {
printf("* ");
}
printf("\n");
}
return 0;
}
```
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)