Give you the width and height of the rectangle,darw it. Input Input contains a number of test cases.For each case ,there are two numbers n and m (0 < n,m < 75)indicate the width and height of the rectangle.Iuput ends of EOF. Output For each case,you should draw a rectangle with the width and height giving in the input. after each case, you should a blank line. Sample Input 3 2 Sample Output +---+ | | | | +---+
#includeint main() { int wid,hei,i,j; while(scanf("%d %d",&wid,&hei)!=EOF) { for(i=0;i<=hei+1;i++) { for(j=0;j<=wid+1;j++) { if(i>=1&&i<=hei) { if(j==0||j==wid+1) { printf("|"); } else printf(" "); } if(i==0||i==hei+1) { if(j==0||j==wid+1) { printf("+"); } else { printf("-"); } } } printf("n"); } printf("n"); } return 0; }
好久没有做英文题了,这道题也是相对比较简单,按照题目意思输出即可
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)