用各类程序语言写99乘法表
时间: 2024-05-16 10:16:47 浏览: 56
Python:
```python
for i in range(1, 10):
for j in range(1, i+1):
print(f"{j}x{i}={i*j}", end="\t")
print()
```
Java:
```java
for (int i = 1; i <= 9; i++) {
for (int j = 1; j <= i; j++) {
System.out.print(j + "x" + i + "=" + (i*j) + "\t");
}
System.out.println();
}
```
C++:
```cpp
for (int i = 1; i <= 9; i++) {
for (int j = 1; j <= i; j++) {
cout << j << "x" << i << "=" << (i*j) << "\t";
}
cout << endl;
}
```
JavaScript:
```javascript
for (let i = 1; i <= 9; i++) {
for (let j = 1; j <= i; j++) {
console.log(`${j}x${i}=${i*j}\t`);
}
console.log("\n");
}
```
PHP:
```php
for ($i = 1; $i <= 9; $i++) {
for ($j = 1; $j <= $i; $j++) {
echo $j . "x" . $i . "=" . ($i*$j) . "\t";
}
echo "\n";
}
```
以上仅是简单的实现,还有其他语言的实现方式。
阅读全文