Problem:
Flag

AHK Education, the educational program section of Aizu Broadcasting Cooperation, broadcasts a children’s workshop program called "Let's Play and Make." Today’s theme is "Make your own flag." A child writes his first initial in the center of their rectangular flag.

Given the flag size and the initial letter to be placed in the center of it, write a program to draw the flag as shown in the figure below.

+-------+
|.......|
|...A...|
|.......|
+-------+

The figure has "A" in the center of a flag with size 9 (horizontal) × 5 (vertical).

Input

The input is given in the following format.

W H c

The input line provides the flag dimensions W (width) and H (height) (3 ≤ W,H ≤ 21), and the initial letter c. Both W and H are odd numbers, and c is a capital letter.

Output

Draw the flag of specified size with the initial in its center using the following characters: "+" for the four corners of the flag, "-" for horizontal lines, "|" for vertical lines, and "." for the background (except for the initial in the center).

Sample Input 1

3 3 B

Sample Output 1

+-+
|B|
+-+

Sample Input 2

11 7 Z

Sample Output 2

+---------+
|.........|
|.........|
|....Z....|
|.........|
|.........|
+---------+

Solution in JAVA (judge verdict: Accepted)

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

 
public class Main {
    public static void main(String[] args) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try {
		String str=reader.readLine();
		String s[]=str.split(" ");
		int w=Integer.parseInt(s[0]);
		int h=Integer.parseInt(s[1]);
		String c=s[2];

		int x=(w/2);
		int y=(h/2);

		StringBuilder sb=new StringBuilder();

		for(int i=0;i<h;i++){
		    for(int j=0;j<w;j++){
			if(i==0||i==h-1){
			    if(j==0||j==w-1){
				sb.append("+");
			    }else {
				sb.append("-");
			    }
			}else{
			    if(j==0||j==w-1){
				sb.append("|");
			    }else if(i==y&&j==x){
				sb.append(c);
			    }else{
				sb.append(".");
			    }
			}
			if(j==w-1&&i!=h-1){
			    sb.append("\n");
			}
		    }
		}
		System.out.println(sb);
            reader.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    static int gcd (int a, int b){
	return b>0?gcd(b,a%b):a;
    }
    static int lcm (int a, int b) {
	return a*b/gcd(a,b);
    }
}