按照输出格式都是对的,就是全红,恳求指正

P5730 【深基5.例10】显示屏

a2024110244 @ 2024-11-22 17:17:47

#include<stdio.h>
#include<stdlib.h>
void print1(char x);
void print2(char x);
void print3(char x);
void print4(char x);
void print5(char x);
int main()
{
    int n;
    scanf("%d",&n);
    getchar();
    char a[n];
    int i;
    for(i=0;i<n;i++)
    {
        scanf("%c",&a[i]);
    }

    int counter=1,counter2=0;
    int j;
        if(counter==1)
        {
            for(j=0;j<n;j++)
            {
                char t=a[j];
                print1(t);
                counter2++;
                if(counter2<n)
                    printf(".");
                if(counter2==n)
                    printf("\n");
            }counter++;
        }
        if(counter==2)
        {
            counter2=0;
            for(j=0;j<n;j++)
            {
                char t=a[j];
                print2(t);
                counter2++;
                if(counter2<n)
                    printf(".");
                if(counter2==n)
                    printf("\n");
            }counter++;
        }
        if(counter==3)
        {
            counter2=0;
            for(j=0;j<n;j++)
            {
                char t=a[j];
                print3(t);
                counter2++;
                if(counter2<n)
                    printf(".");
                if(counter2==n)
                    printf("\n");
            }counter++;
        }
        if(counter==4)
        {
            counter2=0;
            for(j=0;j<n;j++)
            {
                char t=a[j];
                print4(t);
                counter2++;
                if(counter2<n)
                    printf(".");
                if(counter2==n)
                    printf("\n");
            }counter++;
        }
        if(counter==5)
        {
            counter2=0;
            for(j=0;j<n;j++)
            {
                char t=a[j];
                print5(t);
                counter2++;
                if(counter2<n)
                    printf(".");
                if(counter2==n)
                    printf("\n");
            }
        }

    return 0;

}
void print1(char x)
{
    switch(x)
    {
        case '0':printf("XXX");break;
        case '1':printf("..X");break;
        case '2':printf("XXX");break;
        case '3':printf("XXX");break;
        case '4':printf("X.X");break;
        case '5':printf("XXX");break;
        case '6':printf("XXX");break;
        case '7':printf("XXX");break;
        case '8':printf("XXX");break;
        case '9':printf("XXX");break;

    }return;
}
void print2(char x)
{
    switch(x)
    {
        case '0':printf("X.X");break;
        case '1':printf("..X");break;
        case '2':printf("..X");break;
        case '3':printf("..X");break;
        case '4':printf("X.X");break;
        case '5':printf("X..");break;
        case '6':printf("X..");break;
        case '7':printf("..X");break;
        case '8':printf("X.X");break;
        case '9':printf("X.X");break;
    }return;
}
void print3(char x)
{
    switch(x)
    {
        case '0':printf("X.X");break;
        case '1':printf("..X");break;
        case '2':printf("XXX");break;
        case '3':printf("XXX");break;
        case '4':printf("XXX");break;
        case '5':printf("XXX");break;
        case '6':printf("XXX");break;
        case '7':printf("..X");break;
        case '8':printf("XXX");break;
        case '9':printf("XXX");break;
    }return;
}
void print4(char x)
{
        switch(x)
    {
        case '0':printf("X.X");break;
        case '1':printf("..X");break;
        case '2':printf("X..");break;
        case '3':printf("..X");break;
        case '4':printf("..X");break;
        case '5':printf("..X");break;
        case '6':printf("X.X");break;
        case '7':printf("..X");break;
        case '8':printf("X.X");break;
        case '9':printf("..X");break;
    }return;
}
void print5(char x)
{
      switch(x)
    {
        case '0':printf("XXX");break;
        case '1':printf("..X");break;
        case '2':printf("XXX");break;
        case '3':printf("XXX");break;
        case '4':printf("..X");break;
        case '5':printf("XXX");break;
        case '6':printf("XXX");break;
        case '7':printf("..X");break;
        case '8':printf("XXX");break;
        case '9':printf("XXX");break;
    }return;
}

by M_C_Yyyds @ 2024-11-25 21:11:51

@a2024110244 [捂脸笑],哥!你要不把void()函数放在主函数main()的前面吧!


|