编程序,输出以下图形 ******* ***** *** * *** ************用c语言
时间: 2023-11-09 16:00:47 浏览: 69
以下是输出图形的C语言代码:
```
#include <stdio.h>
int main() {
printf(" *******\n");
printf(" *****\n");
printf(" ***\n");
printf(" *\n");
printf(" ***\n");
printf(" ************\n");
return 0;
}
```
相关问题
用c++编程序输出下列图形 * *** ***** ******* ***** *** *
要用C++编写程序输出该图形,可以使用循环和条件语句来实现。以下是一种可能的实现方式:
```cpp
#include <iostream>
int main() {
int rows = 7; // 总行数
int midRow = (rows + 1) / 2; // 中间行
// 输出上半部分
for (int i = 1; i <= midRow; i++) {
// 输出空格
for (int j = 1; j <= midRow - i; j++) {
std::cout << " ";
}
// 输出星号
for (int k = 1; k <= 2 * i - 1; k++) {
std::cout << "*";
}
std::cout << std::endl;
}
// 输出下半部分
for (int i = midRow - 1; i >= 1; i--) {
// 输出空格
for (int j = 1; j <= midRow - i; j++) {
std::cout << " ";
}
// 输出星号
for (int k = 1; k <= 2 * i - 1; k++) {
std::cout << "*";
}
std::cout << std::endl;
}
return 0;
}
```
运行该程序,即可输出所需的图形。
用c语言编程序:编写程序:输出以下图形: * *** *****
以下是使用 C 语言编写的程序,可以输出相应的图形:
```c
#include <stdio.h>
int main() {
printf(" *\n");
printf(" ***\n");
printf("*****\n");
return 0;
}
```
输出结果为:
```
*
***
*****
```
相关推荐
![](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)