输出以下图形(使用循环) /\ /**\ /*/\*\ /*/**\*\ \*\**/*/ \*\/*/ \**/ \/
时间: 2023-11-18 09:57:21 浏览: 38
以下是Java语言的代码实现:
```
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
for (int i = 1; i <= n; i++) {
for (int j = 0; j < n - i; j++) {
System.out.print(" ");
}
for (int k = 0; k < i * 2 - 1; k++) {
if (k % 2 == 0) {
System.out.print("/");
} else {
System.out.print("*");
}
}
System.out.println();
for (int j = 0; j < n - i; j++) {
System.out.print(" ");
}
for (int k = 0; k < i * 2 - 1; k++) {
if (k % 2 == 0) {
System.out.print("*");
} else {
System.out.print("\\");
}
}
System.out.println();
}
```
以下是C语言的代码实现:
```
#include <stdio.h>
int main() {
char x;
scanf("%c", &x);
for (int i = 1; i <= 4; i++) {
for (int j = 0; j < 4 - i; j++) {
printf(" ");
}
for (int k = 0; k < i * 2 - 1; k++) {
if (k % 2 == 0) {
printf("/");
} else {
printf("*");
}
}
printf("\n");
for (int j = 0; j < 4 - i; j++) {
printf(" ");
}
for (int k = 0; k < i * 2 - 1; k++) {
if (k % 2 == 0) {
printf("*");
} else {
printf("\\");
}
}
printf("\n");
}
printf(" /\\ \n");
printf(" /**\\ \n");
printf("/*/%c\\*\n", x);
printf("\\*\\*/\n");
printf(" \\/ \n");
return 0;
}
```
相关推荐
![](https://img-home.csdnimg.cn/images/20210720083646.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.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)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)