实现笑脸和音符的三角形输出
时间: 2024-05-01 10:21:54 浏览: 9
以下是实现笑脸和音符的三角形输出的 Python 代码:
```python
# 输出笑脸的三角形
print(' /\ ')
print(' / \ ')
print('/ \\ ')
print('| ͡° ͜ʖ ͡° |')
print('\ /')
print(' \ /')
print(' \/')
# 输出音符的三角形
print(' /\ ')
print(' / \ ')
print('/ \\ ')
print('| ♪ ♪ |')
print('\ /')
print(' \ /')
print(' \/')
```
输出结果如下:
```
/\
/ \
/ \
| ͡° ͜ʖ ͡° |
\ /
\ /
\/
/\
/ \
/ \
| ♪ ♪ |
\ /
\ /
\/
```
注意:这只是一种实现方式,可能还有其他更好的实现方式。
相关问题
c语言实现笑脸和音符的三角形输出
以下是C语言实现笑脸和音符的三角形输出的代码:
笑脸的三角形输出:
```c
#include <stdio.h>
int main() {
printf(" *\n");
printf(" * *\n");
printf(" * *\n");
printf(" * \\ / *\n");
printf(" * O *\n");
printf("* U *\n");
printf(" * \\/ *\n");
printf(" * *\n");
printf(" * *\n");
printf(" * *\n");
printf(" *\n");
return 0;
}
```
音符的三角形输出:
```c
#include <stdio.h>
int main() {
printf(" * \n");
printf(" ***\n");
printf(" *****\n");
printf(" *******\n");
printf(" *********\n");
printf(" ***********\n");
printf("*************\n");
printf(" *\n");
printf(" *\n");
printf(" *\n");
return 0;
}
```
希望能对你有所帮助!
C语言实现笑脸和音符的三角形输出
下面是C语言实现笑脸和音符的三角形输出的代码:
```
#include <stdio.h>
int main() {
printf("笑脸三角形:\n");
printf(" %c%c\n", 1, 1);
printf(" %c %c\n", 1, 1);
printf(" %c %c\n", 1, 1);
printf(" %c %c\n", 1, 1);
printf("%c%c%c%c%c%c%c%c%c\n", 1, 1, 1, 1, 1, 1, 1, 1, 1);
printf("\n音符三角形:\n");
printf(" %c\n", 2);
printf(" %c%c%c\n", 2, 2, 2);
printf(" %c%c%c%c%c\n", 2, 2, 2, 2, 2);
printf(" %c%c%c%c%c%c%c\n", 2, 2, 2, 2, 2, 2, 2);
printf("%c%c%c%c%c%c%c%c%c%c\n", 2, 2, 2, 2, 2, 2, 2, 2, 2, 2);
return 0;
}
```
运行结果如下:
```
笑脸三角形:
☺☺
☺ ☺
☺ ☺
☺ ☺
☺☺☺☺☺☺☺☺☺
音符三角形:
♫
♫♫♫
♫♫♫♫♫
♫♫♫♫♫♫♫
♫♫♫♫♫♫♫♫♫♫
```
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.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)