首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

课后练习4.4

2012-12-28 
课后习题4.4#includestdio.hint main(){??? int height 0 ??? int width 0 ??? int i 0 ??? in

课后习题4.4

#include<stdio.h>
int main(){

??? int height = 0 ;
??? int width = 0 ;
??? int i = 0 ;
??? int j = 0 ;

??? printf("Please input the length and width of the room cosnt by * ! \n ");
??? scanf(" %d %d",&height,&width);

??? for (; i < height ; i++){
??? ??? printf("*");
??? ??? if( i == 0 || i == height - 1){
??? ??? ??? for(j = 0 ; j < width - 2 ; j++){
??? ??? ??? ??? printf("*");
??? ??? ??? }
??? ??? }else{
??? ???
??? ??? for( j = 0; j < width - 2 ; j++){
??? ??? ??? printf(" ") ;
??? ??? ??? }
??? ???
??? ??? }

??? ??? printf("*\n") ;
??? }
??? return 0;
}

热点排行