Structured Program I – Print a Rectangle

605 词

题目描述

Print a Rectangle Draw a rectangle which has a height of H cm and a width of W cm. Draw a 1-cm square by single ‘#’.

输入

The input consists of multiple datasets. Each dataset consists of two integers H and W separated by a single space. The input ends with two 0 (when both H and W are zero).

输出

For each dataset, print the rectangle made of H × W ‘#’. Print a blank line after each dataset.

#include<bits/stdc++.h>
using namespace std;
int main(){
int h,w,i,j;
while(scanf(“%d %d”,&h,&w)!=EOF)
{
if(h==0&&w==0){
return 0;
}
else {
for(i=0;i<h;i=i+1){
for(j=0;j<w;j=j+1){
cout<<”#”;
}
cout<<endl;
}
printf(“\n”);}
}
}