qkzzfd @ 2023-04-03 16:27:17
#include <stdio.h>
#include <string.h>
int main()
{
int n;
scanf("%d", &n);
getchar();
int i, j;
char str[105];
fgets(str, n + 1, stdin);
for(i = 0;i < 5;i++){
// 输出形状,每一行分别处理
if(i == 0){
for(j = 0;j < n;j++){
switch(str[j]){
case '1':
printf("..X");
break;
case '4':
printf("X.X");
break;
default:
printf("XXX");
}
if(j != (n - 1) ){
printf(".");
}
}
printf("\n");
}else if(i == 1){
for(j = 0;j < n;j++){
switch(str[j]){
case '1':
case '2':
case '3':
case '7':
printf("..X");
break;
case '5':
case '6':
printf("X..");
break;
default:
printf("X.X");
}
if(j != (n - 1) ){
printf(".");
}
}
printf("\n");
}else if(i == 2){
for(j = 0;j < n;j++){
switch(str[j]){
case '0':
printf("X.X");
break;
case '1':
case '7':
printf("..X");
break;
default:
printf("XXX");
}
if(j != (n - 1) ){
printf(".");
}
}
printf("\n");
}else if(i == 3){
for(j = 0;j < n;j++){
switch(str[j]){
case '0':
case '6':
case '8':
printf("X.X");
break;
case '2':
printf("X..");
break;
default:
printf("..X");
}
if(j != (n - 1) ){
printf(".");
}
}
printf("\n");
}else{
for(j = 0;j < n;j++){
switch(str[j]){
case '1':
case '4':
case '7':
printf("..X");
break;
default:
printf("XXX");
}
if(j != (n - 1) ){
printf(".");
}
}
}
}
return 0;
}
by fattership @ 2023-04-04 21:40:12
玄学, 挑不出来, 程序结构有待改良(我是帮不到忙还指责别人的屑
by aaa_kk @ 2023-05-02 18:57:31
我也是
#include<bits/stdc++.h>
using namespace std;
int main(){
long long int n,sum[50000];
string a;
cin>>n>>a;
int b=a.size();
for(long long int i=0;i<b;i++){
sum[i]=a[i]-'0';
}
string c[500];
c[0]="xxx";
c[1]="x.x";
c[2]="x.x";
c[3]="x.x";
c[4]="xxx";
c[5]="..x";
c[6]="..x";
c[7]="..x";
c[8]="..x";
c[9]="..x";
c[10]="xxx";
c[11]="..x";
c[12]="xxx";
c[13]="x..";
c[14]="xxx";
c[15]="xxx";
c[16]="..x";
c[17]="xxx";
c[18]="..x";
c[19]="xxx";
c[20]="x.x";
c[21]="x.x";
c[22]="xxx";
c[23]="..x";
c[24]="..x";
c[25]="xxx";
c[26]="x..";
c[27]="xxx";
c[28]="..x";
c[29]="xxx";
c[30]="xxx";
c[31]="x..";
c[32]="xxx";
c[33]="x.x";
c[34]="xxx";
c[35]="xxx";
c[36]="..x";
c[37]="..x";
c[38]="..x";
c[39]="..x";
c[40]="xxx";
c[41]="x.x";
c[42]="xxx";
c[43]="x.x";
c[44]="xxx";
c[45]="xxx";
c[46]="x.x";
c[47]="xxx";
c[48]="..x";
c[49]="xxx";
for(int i=0;i<5;i++){
for(int j=0;j<n;j++){
if(sum[j]==0&&j!=n-1)cout<<c[0+i]<<'.';
else if(sum[j]==1&&j!=n-1)cout<<c[5+i]<<'.';
else if(sum[j]==2&&j!=n-1)cout<<c[10+i]<<'.';
else if(sum[j]==3&&j!=n-1)cout<<c[15+i]<<'.';
else if(sum[j]==4&&j!=n-1)cout<<c[20+i]<<'.';
else if(sum[j]==5&&j!=n-1)cout<<c[25+i]<<'.';
else if(sum[j]==6&&j!=n-1)cout<<c[30+i]<<'.';
else if(sum[j]==7&&j!=n-1)cout<<c[35+i]<<'.';
else if(sum[j]==8&&j!=n-1)cout<<c[40+i]<<'.';
else if(sum[j]==9&&j!=n-1)cout<<c[45+i]<<'.';
else if(sum[j]==0&&j==n-1)cout<<c[0+i];
else if(sum[j]==1&&j==n-1)cout<<c[5+i];
else if(sum[j]==2&&j==n-1)cout<<c[10+i];
else if(sum[j]==3&&j==n-1)cout<<c[15+i];
else if(sum[j]==4&&j==n-1)cout<<c[20+i];
else if(sum[j]==5&&j==n-1)cout<<c[25+i];
else if(sum[j]==6&&j==n-1)cout<<c[30+i];
else if(sum[j]==7&&j==n-1)cout<<c[35+i];
else if(sum[j]==8&&j==n-1)cout<<c[40+i];
else if(sum[j]==9&&j==n-1)cout<<c[45+i];
}
if(i!=4)cout<<'\n';
}
return 0;
}
by blsya23a2 @ 2023-06-02 18:56:56
我也是
a=int(input())
b=list(input())
c=[[],[],[],[],[]]
for e in b:
if e in ('0','2','3','5','6','7','8','9'):
for i in range(1,4):
c[0].append('X')
elif e=='1':
c[0].append('.')
c[0].append('.')
c[0].append('X')
else:
c[0].append('X')
c[0].append('.')
c[0].append('X')
c[0].append('.')
del c[0][-1]
for f in b:
if f in ('1','2','3','7'):
c[1].append('.')
c[1].append('.')
c[1].append('X')
elif f in ('0','4','8','9'):
c[1].append('X')
c[1].append('.')
c[1].append('X')
else:
c[1].append('X')
c[1].append('.')
c[1].append('.')
c[1].append('.')
del c[1][-1]
for g in b:
if g in ('2','3','4','5','6','8','9'):
for i in range(1,4):
c[2].append('X')
elif g in ('1','7'):
c[2].append('.')
c[2].append('.')
c[2].append('X')
else:
c[2].append('X')
c[2].append('.')
c[2].append('X')
c[2].append('.')
del c[2][-1]
for h in b:
if h in ('0','6','8'):
c[3].append('X')
c[3].append('.')
c[3].append('X')
elif h in ('1','7','3','4','5','9'):
c[3].append('.')
c[3].append('.')
c[3].append('X')
else:
c[3].append('X')
c[3].append('.')
c[3].append('.')
c[3].append('.')
del c[3][-1]
for j in b:
if j in ('0','2','3','5','6','8','9'):
for i in range(1,4):
c[4].append('X')
else:
c[4].append('.')
c[4].append('.')
c[4].append('X')
c[4].append('.')
del c[4][-1]
for k in c:
for l in k:
print(l,end='')
print()
by blsya23a2 @ 2023-06-02 19:05:20
我的问题是因为洛谷有些题目输入的数据有不明原因的空格,这题就是输入的第二行有空格。用strip()(python)把空格去掉就可以了
by A_R_O_N_A @ 2023-06-03 14:27:23
@qkzzfd 分行处理可以参照我的代码
#include<bits/stdc++.h>
using namespace std;
void print(char num,int l);
string num;
int main(){
int s,l;
cin>>s;
cin>>num;
for(l=1;l<=5;l++){
for(int j=0;j<num.size();j++){
print(num[j],l);
if(j<num.size()-1)cout<<".";
}
cout<<endl;
}
return 0;
}
void print(char num,int l){
if(num=='0'){
switch(l){
case 1:cout<<"XXX";break;
case 2:cout<<"X.X";break;
case 3:cout<<"X.X";break;
case 4:cout<<"X.X";break;
case 5:cout<<"XXX";break;
}
}
if(num=='1'){
switch(l){
case 1:cout<<"..X";break;
case 2:cout<<"..X";break;
case 3:cout<<"..X";break;
case 4:cout<<"..X";break;
case 5:cout<<"..X";break;
}
}
if(num=='2'){
switch(l){
case 1:cout<<"XXX";break;
case 2:cout<<"..X";break;
case 3:cout<<"XXX";break;
case 4:cout<<"X..";break;
case 5:cout<<"XXX";break;
}
}
if(num=='3'){
switch(l){
case 1:cout<<"XXX";break;
case 2:cout<<"..X";break;
case 3:cout<<"XXX";break;
case 4:cout<<"..X";break;
case 5:cout<<"XXX";break;
}
}
if(num=='4'){
switch(l){
case 1:cout<<"X.X";break;
case 2:cout<<"X.X";break;
case 3:cout<<"XXX";break;
case 4:cout<<"..X";break;
case 5:cout<<"..X";break;
}
}
if(num=='5'){
switch(l){
case 1:cout<<"XXX";break;
case 2:cout<<"X..";break;
case 3:cout<<"XXX";break;
case 4:cout<<"..X";break;
case 5:cout<<"XXX";break;
}
}
if(num=='6'){
switch(l){
case 1:cout<<"XXX";break;
case 2:cout<<"X..";break;
case 3:cout<<"XXX";break;
case 4:cout<<"X.X";break;
case 5:cout<<"XXX";break;
}
}
if(num=='7'){
switch(l){
case 1:cout<<"XXX";break;
case 2:cout<<"..X";break;
case 3:cout<<"..X";break;
case 4:cout<<"..X";break;
case 5:cout<<"..X";break;
}
}
if(num=='8'){
switch(l){
case 1:cout<<"XXX";break;
case 2:cout<<"X.X";break;
case 3:cout<<"XXX";break;
case 4:cout<<"X.X";break;
case 5:cout<<"XXX";break;
}
}
if(num=='9'){
switch(l){
case 1:cout<<"XXX";break;
case 2:cout<<"X.X";break;
case 3:cout<<"XXX";break;
case 4:cout<<"..X";break;
case 5:cout<<"XXX";break;
}
}
}
by Error_303 @ 2023-06-03 17:02:20
#include <bits/stdc++.h>
using namespace std;
char ch[100];
char sum[5][400];
int i;
int main()
{
int n;
scanf("%d", &n);
scanf("%s", ch);
char* s = ch;
while(*s != '\0')
{
switch(*s)
{
case '0':
sum[0][i]='X';sum[0][i+1]='X';sum[0][i+2]='X';
sum[1][i]='X';sum[1][i+1]='.';sum[1][i+2]='X';
sum[2][i]='X';sum[2][i+1]='.';sum[2][i+2]='X';
sum[3][i]='X';sum[3][i+1]='.';sum[3][i+2]='X';
sum[4][i]='X';sum[4][i+1]='X';sum[4][i+2]='X';
break;
case '1':
sum[0][i]='.';sum[0][i+1]='.';sum[0][i+2]='X';
sum[1][i]='.';sum[1][i+1]='.';sum[1][i+2]='X';
sum[2][i]='.';sum[2][i+1]='.';sum[2][i+2]='X';
sum[3][i]='.';sum[3][i+1]='.';sum[3][i+2]='X';
sum[4][i]='.';sum[4][i+1]='.';sum[4][i+2]='X';
break;
case '2':
sum[0][i]='X';sum[0][i+1]='X';sum[0][i+2]='X';
sum[1][i]='.';sum[1][i+1]='.';sum[1][i+2]='X';
sum[2][i]='X';sum[2][i+1]='X';sum[2][i+2]='X';
sum[3][i]='X';sum[3][i+1]='.';sum[3][i+2]='.';
sum[4][i]='X';sum[4][i+1]='X';sum[4][i+2]='X';
break;
case '3':
sum[0][i]='X';sum[0][i+1]='X';sum[0][i+2]='X';
sum[1][i]='.';sum[1][i+1]='.';sum[1][i+2]='X';
sum[2][i]='X';sum[2][i+1]='X';sum[2][i+2]='X';
sum[3][i]='.';sum[3][i+1]='.';sum[3][i+2]='X';
sum[4][i]='X';sum[4][i+1]='X';sum[4][i+2]='X';
break;
case '4':
sum[0][i]='X';sum[0][i+1]='.';sum[0][i+2]='X';
sum[1][i]='X';sum[1][i+1]='.';sum[1][i+2]='X';
sum[2][i]='X';sum[2][i+1]='X';sum[2][i+2]='X';
sum[3][i]='.';sum[3][i+1]='.';sum[3][i+2]='X';
sum[4][i]='.';sum[4][i+1]='.';sum[4][i+2]='X';
break;
case '5':
sum[0][i]='X';sum[0][i+1]='X';sum[0][i+2]='X';
sum[1][i]='X';sum[1][i+1]='.';sum[1][i+2]='.';
sum[2][i]='X';sum[2][i+1]='X';sum[2][i+2]='X';
sum[3][i]='.';sum[3][i+1]='.';sum[3][i+2]='X';
sum[4][i]='X';sum[4][i+1]='X';sum[4][i+2]='X';
break;
case '6':
sum[0][i]='X';sum[0][i+1]='X';sum[0][i+2]='X';
sum[1][i]='X';sum[1][i+1]='.';sum[1][i+2]='.';
sum[2][i]='X';sum[2][i+1]='X';sum[2][i+2]='X';
sum[3][i]='X';sum[3][i+1]='.';sum[3][i+2]='X';
sum[4][i]='X';sum[4][i+1]='X';sum[4][i+2]='X';
break;
case '7':
sum[0][i]='X';sum[0][i+1]='X';sum[0][i+2]='X';
sum[1][i]='.';sum[1][i+1]='.';sum[1][i+2]='X';
sum[2][i]='.';sum[2][i+1]='.';sum[2][i+2]='X';
sum[3][i]='.';sum[3][i+1]='.';sum[3][i+2]='X';
sum[4][i]='.';sum[4][i+1]='.';sum[4][i+2]='X';
break;
case '8':
sum[0][i]='X';sum[0][i+1]='X';sum[0][i+2]='X';
sum[1][i]='X';sum[1][i+1]='.';sum[1][i+2]='X';
sum[2][i]='X';sum[2][i+1]='X';sum[2][i+2]='X';
sum[3][i]='X';sum[3][i+1]='.';sum[3][i+2]='X';
sum[4][i]='X';sum[4][i+1]='X';sum[4][i+2]='X';
break;
case '9':
sum[0][i]='X';sum[0][i+1]='X';sum[0][i+2]='X';
sum[1][i]='X';sum[1][i+1]='.';sum[1][i+2]='X';
sum[2][i]='X';sum[2][i+1]='X';sum[2][i+2]='X';
sum[3][i]='.';sum[3][i+1]='.';sum[3][i+2]='X';
sum[4][i]='X';sum[4][i+1]='X';sum[4][i+2]='X';
break;
}
if(*(s+1)!='\0')sum[0][i+3]=sum[1][i+3]=sum[2][i+3]=sum[3][i+3]=sum[4][i+3]='.';
i += 4;
s++;
}
for(int j = 0; j < 5; j++)
{
for(int k = 0; k < 4*n-1; k++)
cout << sum[j][k];
cout << endl;
}
return 0;
}
看我肝得如此辛苦,给我一个关注吧··· 球球你了······
by qkzzfd @ 2023-11-16 13:19:38
@Error_303 哈哈哈,一会就看,时隔五个月,忘记完了