Python
```python
def print_rectangle(width, height):
for i in range(height):
for j in range(width):
print("*", end=" ")
print()
调用函数,打印一个宽度为5,高度为3的长方形
print_rectangle(5, 3)
```
Java
```java
public class PrintRectangle {
public static void main(String[] args) {
int height = 5;
int width = 10;
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
System.out.print("*");
}
System.out.println();
}
}
}
```
C++
```cpp
include using namespace std; void printRectangle(int width, int height) { for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { cout << "* "; } cout << endl; } } int main() { int width = 5; int height = 3; printRectangle(width, height); return 0; } ``` JavaScript (HTML5 Canvas) ```html