pat1036:跟奥巴马一起编程

https://www.patest.cn/contests/pat-b-practise/1036

#include "stdio.h"

int main()
{
	int n, N, k, i = 0;
	char c;
	scanf("%d %c", &n, &c);
	if(n%2)
		N = n/2 + 1;
	else
		N = n/2;
	while(i < N)
	{
		if((0 == i) || (N - 1 == i))
		{
			for(k = 0; k < n; ++k)
				printf("%c", c);
		}
		else
		{
			for(k = 0; k < n; ++k)
			{
				if((0 == k) || (n-1 == k))
					printf("%c", c);
				else
					printf(" ");
			}
		}
		printf("\n");
		++i;
	}

	return 0;
}


你可能感兴趣的:(c,pat)