"蔚来杯"2022牛客暑期多校训练营6 G-Icon Design

问题描述

What's the feeling of designing an icon for a school as a programmer? Now you have a chance doing it!

The icon of Nanjing Foreign Language School (NFLS for short) is not complicated, it can be represented as an ASCII art.

 

Since the icon might be used in different places, you need to print the icon in different size.

Given size n, print the icon of size n.

Detailed format is shown below, you can also look at the sample output to confirm it.

 

Like which is shown in the picture, '*' is used on the boundary, and '@' is used for the letters.

(n+1) '.'s are used to seperate letters and the boundary horizontally, and n '.'s are used vertically.
Each letter is (2n+3) characters wide and (2n+3) characters in height.
The icon's size is (4n+5)×(13n+19).

输入格式

The first line contains a positive integer n(1≤n≤5), representing the size of the icon.

输出格式

Print the icon of size n.

样例1输入

1

样例1输出

********************************
*..............................*
*..@...@..@@@@@..@......@@@@@..*
*..@@..@..@......@......@......*
*..@.@.@..@@@@@..@......@@@@@..*
*..@..@@..@......@..........@..*
*..@...@..@......@@@@@..@@@@@..*
*..............................*
********************************

样例2输入

3

样例2输出

**********************************************************
*........................................................*
*........................................................*
*........................................................*
*....@.......@....@@@@@@@@@....@............@@@@@@@@@....*
*....@@......@....@............@............@............*
*....@.@.....@....@............@............@............*
*....@..@....@....@............@............@............*
*....@...@...@....@@@@@@@@@....@............@@@@@@@@@....*
*....@....@..@....@............@....................@....*
*....@.....@.@....@............@....................@....*
*....@......@@....@............@....................@....*
*....@.......@....@............@@@@@@@@@....@@@@@@@@@....*
*........................................................*
*........................................................*
*........................................................*
**********************************************************

题解

第一行是13n+19个“*”直接输出

接下来n行,每行除了第一个和最后一个是“*”,其它的都是“.”

接下来2n+3行是字母的输出,除了第一个和最后一个是“*”,每个字母两边都有n+1个“.”,每个字母占的宽度为2n+3,对于“N”,除了第一列和最后一列全是“@”,其它的只有当行数和列数相等时为“@”,对于“F”,第一列全是“@”,第1行和第n+2行是“@”,对于“L”,第一列和最后一行是“@”,对于“S”,第1,n+2,2n+3行都是“@”,以n+2为分界,n+2之前第一列是“@”,n+2之后最后一列是“@”

 

 

 1 #include <cstdio>
 2 int n;
 3 int main()
 4 {
 5     int i,j;
 6     scanf("%d",&n);
 7     for (i=1;i<=13*n+19;i++)
 8       printf("*");
 9     printf("\n");
10     for (i=1;i<=n;i++)
11     {
12         printf("*");
13         for (j=2;j<13*n+19;j++)
14           printf(".");
15         printf("*\n");
16     }
17     for (i=1;i<=2*n+3;i++)
18     {
19         printf("*");
20         for (j=1;j<=n+1;j++)
21           printf(".");
22         printf("@");
23         for (j=2;j<2*n+3;j++)
24         {
25             if (j==i) printf("@");
26             else printf(".");
27         }
28         printf("@");
29         for (j=1;j<=n+1;j++)
30           printf(".");
31         printf("@");
32         for (j=2;j<=2*n+3;j++)
33         {
34             if (i==1 || i==n+2) 
35               printf("@");
36             else printf(".");
37         }
38         for (j=1;j<=n+1;j++)
39           printf(".");
40         printf("@");
41         for (j=2;j<=2*n+3;j++)
42         {
43             if (i==2*n+3) printf("@");
44             else printf(".");
45         }
46         for (j=1;j<=n+1;j++)
47           printf(".");
48         for (j=1;j<=2*n+3;j++)
49         {
50             if (i==1 || i==n+2 || i==2*n+3)
51               printf("@");
52             else if (j==1 && i<n+2) 
53               printf("@");
54             else if (j==2*n+3 && i>n+2)
55               printf("@");
56             else printf("."); 
57         }
58         for (j=1;j<=n+1;j++)
59           printf(".");
60         printf("*\n");
61     }
62     for (i=1;i<=n;i++)
63     {
64         printf("*");
65         for (j=2;j<13*n+19;j++)
66           printf(".");
67         printf("*\n");
68     } 
69     for (i=1;i<=13*n+19;i++)
70       printf("*");
71     return 0;
72 } 

 

posted @ 2022-08-20 20:16  SAKURA12  阅读(25)  评论(0编辑  收藏  举报