Pattern Printing in C language [closed]

2019-09-22 05:37发布

How do we print the following pattern in c language? There is a square inside another square, which is again inside another square. So, there are three squares in total.

标签: c
1条回答
【Aperson】
2楼-- · 2019-09-22 06:20

Here you go:

Sample Code Listing


#include <stdio.h>

#define NUM_SQUARES  (5)

int main(void) {
   int i,j;

   printf("###########\n");
   printf("#         #\n");
   printf("# ####### #\n");
   printf("# #     # #\n");
   printf("# # ### # #\n");
   printf("# # # # # #\n");
   printf("# # ### # #\n");
   printf("# #     # #\n");
   printf("# ####### #\n");
   printf("#         #\n");
   printf("###########\n");

   return 0;
}

Sample Output


###########
#         #
# ####### #
# #     # #
# # ### # #
# # # # # #
# # ### # #
# #     # #
# ####### #
#         #
###########
查看更多
登录 后发表回答