P1538 digital dance and p1538 Spring Dance
Background
Students of HNSDFZ are preparing to rehearse a dance to celebrate the Spring Festival.
Description
In the era of more and more cooperation, what people pay attention to is not the dance of individual figures, but the collective arrangement.
In order to cope with the annual countdown, the students decided to "Digital Dance ". As the name implies, everyone is lined up with several numbers-___-| what's more innovative is that everyone is on the ground to ensure that they are in the vertical and horizontal directions.
Now let's show you the numbers and their requirements. Please program them to simulate the beautiful posture of the students.
Input/Output Format
Input Format:
The first behavior k. K indicates the size of a number.
The second act is a string composed of numbers, that is, the numbers to be displayed.
Output Format:
Output as required by the question.
Input and Output sample input sample #1:
21234567890
Output sample #1:
-- -- -- -- -- -- -- -- | | | | | | | | | | | | | | | | | | | | | | | | | | | | -- -- -- -- -- -- -- | | | | | | | | | | | | | | | | | | | | | | | | | | -- -- -- -- -- -- --
Description
Each number has one space before it, and all numbers are aligned.
K <= 30, the length of s cannot exceed 255
We recommend that you do not save the output directly.
If you have any questions about the size and k, please understand.
Find the rule...
Simulation... ,
1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<cmath> 5 using namespace std; 6 char a[438]; 7 void read(int & n) 8 { 9 char c='+';int x=0; 10 while(c<'0'||c>'9') 11 c=getchar(); 12 while(c>='0'&&c<='9') 13 { 14 x=x*10+(c-48); 15 c=getchar(); 16 } 17 n=x; 18 } 19 void kong() 20 {printf(" ");} 21 void heng() 22 {printf("-");} 23 void shu() 24 {printf("|");} 25 int main() 26 { 27 int n; 28 read(n); 29 scanf("%s",a); 30 int la=strlen(a); 31 for(int i=0;i<strlen(a);i++) 32 { 33 kong(); 34 if(a[i]=='1'||a[i]=='4') 35 { 36 for(int k=1;k<=n;k++) 37 kong(); 38 } 39 else 40 { 41 for(int k=1;k<=n;k++) 42 heng(); 43 } 44 kong(); 45 kong(); 46 } 47 printf("\n"); 48 for(int l=1;l<=n;l++) 49 { 50 for(int i=0;i<la;i++) 51 { 52 if(a[i]=='1'||a[i]=='2'||a[i]=='3'||a[i]=='7') 53 { 54 for(int k=1;k<=n+1;k++) 55 kong(); 56 shu(); 57 } 58 59 else if(a[i]=='5'||a[i]=='6') 60 { 61 shu(); 62 for(int k=1;k<=n+1;k++) 63 kong(); 64 } 65 else 66 { 67 shu(); 68 for(int k=1;k<=n;k++) 69 kong(); 70 shu(); 71 } 72 kong(); 73 } 74 printf("\n"); 75 } 76 for(int i=0;i<strlen(a);i++) 77 { 78 kong(); 79 if(a[i]=='1'||a[i]=='7'||a[i]=='0') 80 { 81 for(int k=1;k<=n;k++) 82 kong(); 83 } 84 else 85 { 86 for(int k=1;k<=n;k++) 87 heng(); 88 } 89 kong(); 90 kong(); 91 } 92 printf("\n"); 93 for(int l=1;l<=n;l++) 94 { 95 for(int i=0;i<la;i++) 96 { 97 if(a[i]=='1'||a[i]=='3'||a[i]=='4'||a[i]=='5'||a[i]=='7'||a[i]=='9') 98 { 99 for(int k=1;k<=n+1;k++)100 kong();101 shu();102 }103 104 else if(a[i]=='6'||a[i]=='8'||a[i]=='0')105 {106 107 shu();108 for(int k=1;k<=n;k++)109 kong();110 shu();111 }112 else113 {114 shu();115 for(int k=1;k<=n+1;k++)116 kong();117 }118 kong();119 }120 printf("\n");121 }122 for(int i=0;i<strlen(a);i++)123 {124 kong();125 if(a[i]=='1'||a[i]=='7'||a[i]=='4')126 {127 for(int k=1;k<=n;k++)128 kong();129 }130 else131 {132 for(int k=1;k<=n;k++)133 heng();134 }135 kong();136 kong();137 }138 return 0;139 }