Thread: Hey, my programmer "LC-display".

  1. #1
    Registered User
    Join Date
    Oct 2011
    Location
    China
    Posts
    9

    Hey, my programmer "LC-display".

    this problem is from 1102 -- LC-Display

    maybe, you have better code...

    this is my code:

    Code:
    /**********************************
     *     Name:        LC-display
     *    Author:        thlgood(www.yucoat.com)
     *    Problem:    http://poj.org/problem?id=1102
     **********************************
    #include <stdio.h>
    int Map[10] = {    013031, 001010, 012111, 011111, 001130, 
                    011121, 013121, 001011, 013131, 011131};
    
    
    void Show(int bit, int value, int count)
    {
        int temp;
        if (bit % 2)
        {
            char i = value==0?' ':'-';
            putchar(' ');
            for (temp = 0; temp < count; temp++)
                putchar(i);
            putchar(' ');
        }
        else
        {
            char i[2];
            i[0] = (value / 2) == 0? ' ' : '|';
            i[1] = (value % 2) == 0? ' ' : '|';
            putchar(i[0]);
            for (temp = 0; temp < count; temp++)
                putchar(' ');
            putchar(i[1]);
            
        }
    }
    
    
    int main()
    {
        int s, duan, temp, getv;
        char n[9];
        while (scanf("%d%s", &s, n) && s != 0)
        {
            for (duan = 1, getv = 1; duan <= 5; duan++, getv *= 8)
            {
                int times = ((duan % 2) == 0 ? s : 1);
                for (; times != 0; times--, putchar('\n'))
                {
                    for (temp = 0; n[temp] != '\0'; temp++)
                    {
                        Show(duan, (Map[(n[temp] - '0')]/ getv) % 8, s);
                        if (n[temp + 1] != '\0')
                            putchar(' ');
                    }
                }
            }
            putchar('\n');
        }
        return 0;
    }

  2. #2
    Registered User
    Join Date
    Oct 2011
    Location
    China
    Posts
    9
    Hey, my programmer &quot;LC-display&quot;.-screenshot-2011-12-01-19-39-34-png

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Open/display/write transparent .png win32 api in "C"
    By vmars316 in forum Windows Programming
    Replies: 6
    Last Post: 04-13-2011, 11:51 AM
  2. Open/display/write transparent .png win32 api in "C"
    By vmars316 in forum Windows Programming
    Replies: 3
    Last Post: 04-12-2011, 11:52 PM
  3. Replies: 1
    Last Post: 11-17-2010, 03:38 AM
  4. "itoa"-"_itoa" , "inp"-"_inp", Why some functions have "
    By L.O.K. in forum Windows Programming
    Replies: 5
    Last Post: 12-08-2002, 08:25 AM
  5. "CWnd"-"HWnd","CBitmap"-"HBitmap"...., What is mean by "
    By L.O.K. in forum Windows Programming
    Replies: 2
    Last Post: 12-04-2002, 07:59 AM