bjfu1287字符串输出的大水题

不多说

/*
 * Author    : ben
 */
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <functional>
#include <numeric>
#include <cctype>
using namespace std;
const int MAXN = 90;
char graph[MAXN][MAXN];

int main() {
    int n;
    while (scanf("%d", &n) == 1) {
        memset(graph, ' ', sizeof(graph));
        int w = 2 * n + 1;
        int in = 2 * n - 3;
        for (int i = 0; i < w; i++) {
            graph[i][0] = '*';
            graph[i][w - 1] = '*';
            graph[i][w] = 0;
        }
        for (int j = 0; j < w; j++) {
            graph[0][j] = '*';
            graph[w - 1][j] = '*';
        }
        for (int j = 2; j < w - 2; j++) {
            graph[2][j] = '*';
            graph[w - 3][j] = '*';
        }
        for (int i = 2; i < w - 2; i++) {
            graph[i][2] = '*';
            graph[i][w - 3] = '*';
        }
        for (int i = 0; i < w; i++) {
            printf("%s\n", graph[i]);
        }
    }
    return 0;
}

 

posted @ 2015-02-08 01:23  moonbay  阅读(159)  评论(0编辑  收藏  举报