アットウィキロゴ

Print a Frame

10013 : Print a Frame




解説

条件分岐に気をつけて

プログラム

C


C++

+ ...
#include<iostream>
using namespace std;

int main(){

	int H,W;
	
	while(cin >> H >> W, H||W){
	
		for(int j = 0; j < W; j++){
			cout << "#" ;
		}
		
		cout << endl;
	
		for(int i = 1; i < H - 1; i++){
			for(int j = 0; j < W; j++){
				if(j == 0 || j == W - 1)	cout << "#" ;
				else				cout << "." ;
			}
			cout << endl;
		}
		 
		for(int j = 0; j < W; j++){
			cout << "#" ;
		}	
		cout << endl << endl;
	}

	return 0;
}

Java

最終更新:2012年12月21日 17:48