706-LCD-Display

Source: Internet
Author: User

Simple question simulation, design a good data structure to easily express the output mode of each number.

I am not the best. Later I saw the kaipeng Liu method, which is more convenient to write ;)

 

Returns the volume VII index.

Returns the total index.

 

Below is my code

 

//////////////////////////////////////// /// // <Br/> // 706-LCD-display <br/> // copyright (c) 2010 by Bo-Wen Feng <br/> // balonfan@gmail.com <br/> /////////////////////// //////////////////////////////////////// /// // </P> <p> # include <set> <br/> # include <map> <br/> # include <list> <br/> # include <queue> <br/> # include <stack> <br/> # include <vector> <br/> # include <string> <br/> # include <sstream> </P> <p> # include <cstdio> <br/> # include <cmath> <br/> # include <limits> <br/> # include <utility> </P> <p> # ifndef online_judge <br/> # include <fstream> <br/> STD:: ifstream CIN ("in.txt"); <br/> STD: ofstream cout ("out.txt"); <br/> // STD: ofstream cout (stdout ); <br/> # else <br/> # include <iostream> <br/> # endif </P> <p> typedef long llong; <br/> typedef unsigned long ullong; <br/> typedef long double ldouble; </P> <p> using namespace STD; </P> <p> # define max_digit 20 </P> <p> // 0 1 2 3 4 5 6 7 8 9 <br/> char Part1 [10] = {'-', '','-','-','','-','-','-','-','-'}; <br/> char Part2 [20] = {'|', '|', '', '|', ',' | ', '|', ',' | ', '|', '|'}; <br/> char Part3 [10] = {'','','-','-','-', '-', '-', '', '-', '-'}; <br/> char part4 [20] = {'|', '| ', '', '|', '|','', '', '|','', '|', '|', ',' | ',' | ', '|', '', '|', ',' | '}; <br/> char part5 [10] = {'-','','-','-','','-','-','', '-', '-'}; </P> <p> void printpart135 (char part [], int S, char * num, int ndigit) <br/>{< br/> char ch; <br/> int D; <br/> for (INT I = 0; I <ndigit; ++ I) <br/>{< br/> if (I> 0) <br/> cout <''; </P> <p> d = num [I]-'0'; </P> <p> cout <''; <br/> CH = part [d]; </P> <p> for (Int J = 0; j <s; ++ J) <br/>{< br/> cout <ch; <br/>}< br/> cout <''; <br/>}</P> <p> cout <'/N'; <br/>}</P> <p> void printpart24 (char part [], int S, char * num, int ndigit) <br/>{< br/> int D; <br/> for (int K = 0; k <s; ++ K) <br/>{< br/> for (INT I = 0; I <ndigit; ++ I) <br/>{< br/> if (I> 0) <br/> cout <''; </P> <p> d = (Num [I]-'0') <1); </P> <p> char parts = part [d]; <br/> char CH2 = part [d + 1]; </P> <p> cout <strong; </P> <p> for (Int J = 0; j <s; ++ J) <br/> cout <''; </P> <p> cout <CH2; <br/>}</P> <p> cout <'/N '; <br/>}</P> <p> int main (INT argc, char * argv []) <br/>{< br/> int s; <br/> char num [max_digit]; <br/> int ndigit; </P> <p> CIN> S> num; </P> <p> while (S> 0) <br/>{< br/> ndigit = strlen (Num); <br/> printpart135 (Part1, S, num, ndigit); <br/> printpart24 (Part2, s, num, ndigit); <br/> printpart135 (Part3, S, num, ndigit); <br/> printpart24 (part4, S, num, ndigit ); <br/> printpart135 (part5, S, num, ndigit); </P> <p> cout <'/N '; </P> <p> CIN> S> num; <br/>}</P> <p> return 0; <br/>}</P> <p>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.