从1乘到10编程怎么写

时间:2025-01-27 12:07:34 网络游戏

Python

```python

for i in range(1, 11):

print(i)

```

Java

```java

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

System.out.println(i);

}

```

C++

```cpp

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

std::cout<< i << std::endl;

}

```

C

```csharp

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

Console.WriteLine(i);

}

```

JavaScript

```javascript

for (let i = 1; i <= 10; i++) {

console.log(i);

}

```

Ruby

```ruby

(1..10).each do |i|

puts i

end

```

PHP

```php

for ($i = 1; $i <= 10; $i++) {

echo $i . "\n";

}

```

Swift

```swift

for i in 1...10 {

print(i)

}

```

Go

```go

package main

import "fmt"

func main() {

for i := 1; i <= 10; i++ {

fmt.Println(i)

}

}

```

这些代码示例展示了如何在不同的编程语言中实现从1乘到10的功能。你可以选择适合你的编程语言进行尝试。