Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

感谢大神,让我又学到一种新方法,贴上刚完成的C代码

Posted by 201501060326 at 2016-02-19 21:33:22 on Problem 1102
#include <stdio.h>
#include <string.h>
char ss[3][15]= {"- -- -----","  ----- --","- -- -- --"};
char st[4][15]= {"|   ||| ||","|||||  |||","| |   | | ","|| |||||||"};
int line(char arr[10],int s,int p)
{
    int i,j;
    for(i=0; i<strlen(arr); i++)
    {
        printf(" ");
        for(j=0; j<s; j++)
        {
            printf("%c",ss[p][arr[i]-'0']);
        }
        printf("  ");
    }
}
int vertical(char arr[10],int s,int q)
{
    int i,j;
    for(i=0; i<strlen(arr); i++)
    {
        printf("%c",st[q][arr[i]-'0']);
        for(j=0; j<s; j++)
        {
            printf(" ");
        }
        printf("%c",st[q+1][arr[i]-'0']);
        printf(" ");
    }
}
int main()
{
    int s,i;
    char arr[10],temp;
    while(scanf("%d",&s))
    {
        getchar();
        gets(arr);
        temp=0;
        for(i=0; i<strlen(arr); i++)
        {
            if(arr[i]!='0')
            {
                temp=1;
                break;
            }
        }
        if(s==0&&temp==0)
        {
            break;
        }
        for(i=0; i<2*s+3; i++)
        {

            if(i>0&&i<s+1)
            {
                vertical(arr,s,0);
            }
            else if(i>s+1&&i<2*s+2)
            {
                vertical(arr,s,2);
            }
            else if(i==0)
            {
                line(arr,s,0);
            }
            else if(i==s+1)
            {
                line(arr,s,1);
            }
            else if(i==2*s+2)
            {
                line(arr,s,2);
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator