编写程序,程序运行时输出以下图形。(20分) **** **** **** ****
时间: 2024-01-17 19:19:05 浏览: 31
以下是两种编程语言的代码示例,分别用于输出所需的图形:
1. Python代码示例:
```python
print("**** ****")
print(" **** ")
print(" **** ")
print(" **** ")
```
2. C代码示例:
```c
#include <stdio.h>
int main() {
printf("**** ****\n");
printf(" **** \n");
printf(" **** \n");
printf(" **** \n");
return 0;
}
```
相关问题
编写一个C程序,运行时 输出以下图形****
以下是一个简单的程序,可以输出图形:
```c
#include <stdio.h>
int main() {
printf("****\n");
return 0;
}
```
如果需要输出多行图形,可以使用循环语句:
```c
#include <stdio.h>
int main() {
int i;
for (i = 0; i < 4; i++) {
printf("****\n");
}
return 0;
}
```
这个程序会输出四行星号图形。
5) 编写程序,程序运行时输出以下图形。**** **** **** ****
这个程序可以通过使用循环和条件语句来实现。以下是一个示例的C++代码:
```cpp
#include <iostream>
int main() {
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
std::cout << "*";
}
std::cout << " ";
}
std::cout << std::endl;
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
std::cout << " ";
}
std::cout << "*";
}
std::cout << std::endl;
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
std::cout << "*";
}
std::cout << " ";
}
std::cout << std::endl;
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
std::cout << " ";
}
std::cout << "*";
}
std::cout << std::endl;
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)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)