编程代码四行怎么输入的

时间:2025-01-28 08:38:50 网络游戏

Python:

```python

name = input("请输入你的名字:")

print("你好," + name + "!")

```

Java:

```java

import java.util.Scanner;

public class Main {

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

System.out.println("请输入一个数字");

int n = sc.nextInt();

for (int i = 1; i <= n; i++) {

for (int j = 1; j <= n - i; j++) {

System.out.print(" ");

}

for (int j = 1; j <= 2 * i - 1; j++) {

System.out.print("*");

}

System.out.println();

}

}

}

```

C语言:

```c

include

int main() {

int i, j, rows = 4;

for (i = 1; i <= rows; ++i) {

for (j = 1; j <= i; ++j) {

printf(" ");

}

for (j = 1; j <= 2 * i - 1; j++) {

printf("*");

}

printf("\n");

}

return 0;

}

```

这些示例分别展示了如何在Python、Java和C语言中输入四行代码,并执行相应的操作。你可以根据需要选择合适的编程语言和示例。