PAT答案(跟奥巴马一起编程)

题目链接

https://www.nowcoder.com/pat/6/problem/4062

代码

#include
#include
using namespace std;

int main() {
    int n;
    char c;
    cin >> n >> c;
    int row = (n+1) / 2;
    for(int i=0; ifor(int j=0; jif(i == 0 || i == row-1 || j== 0 || j == n-1)
                printf("%c", c);
            else
                printf(" ");
        }
        printf("\n");
    }
}

你可能感兴趣的:(算法)