通过本篇文章,我们可以学到python,javascript, go, rust, java,c 六种编程语言的循环语句,实现打印输出Hello, Spaceack!的方式。还能学到编译运行的套路,练习编程手感,挺不错的。
python 实现def hello10():
print("Hello, Spaceack!n"*5, end='')
for _ in range(5):
print("Hello, Spaceack!")
if __name__ == '__main__':
hello10()
# 解释运行 python3 hello10.py
- 解释运行 python3 hello10.py
function hello10(){
console.log("Hello, Spaceack!n".repeat(2))
for (let i = 0; i < 3; i++) {
console.log("Hello, Spaceack!");
}
[...Array(2)].forEach(() => console.log('Hello, Spaceack!'))
let count = 0;
while (count < 3) {
count++;
console.log('Hello, Spaceack!');
};
}
hello10()
// 解释运行 node hello10.js
- 解释运行 node hello10.js
fn main(){
print!("{}","Hello, Spaceack!n".repeat(5));
for _ in 0..5 {
println!("Hello, Spaceack!");
}
}
// 编译 rustc hello10.rs -o hello10_rs
// 运行 ./hello10_rs
- 编译 rustc hello10.rs -o hello10_rs
- 运行 ./hello10_rs
package main
import (
"fmt"
"strings"
)
func main() {
fmt.Printf(strings.Repeat("Hello, Spaceack!n", 5))
for i := 0; i < 5; i++ {
fmt.Printf("Hello, Spaceack!n")
}
}
// 运行 go run hello10.go
// 编译 go build -o hello10_go hello10.go
- 解释运行 go run hello10.go
- 编译构建 go build -o hello10_go hello10.go
- 运行./hello10_go
public class hello10{
public static void main(String[] args){
System.out.print("Hello, Spaceack!n".repeat(5));
for (int i = 0; i <5;i++){
System.out.print("Hello, Spaceack!n");
}
}
}
// 编译 javac hello10.java
// 运行 java hello10
- 编译 javac hello10.java
- 运行 java hello10
#includeint main(){ for(int i=0;i<10;i++){ printf("Hello, Spaceack!n"); } } // 编译链接 gcc hello10.c -o hello10_c // 运行 ./hello10_c
- 编译 gcc hello10.c -o hello10_c
- 运行 ./hello10_c



