[Swust OJ 552]--Pinyin Teaching (law-seeking)

Source: Internet
Author: User

Title Link: http://acm.swust.edu.cn/problem/0552/

Time limit (ms): $ Memory Limit (KB): 65535 Description

Count the Money ~ ~ ~ Enter a number, less than 999999999999, we need to convert them to pinyin, we stipulate for example 1234000567 of the read as "1,234,000,567" specifically see the input and output

Input

A number n

Output

Numbers plus pinyin, see sample OUTPUT

Sample Input

9999999999991234560001234000567

Sample Output
9qian9bai9shi9yi9qian9bai9shi9wan9qian9bai9shi91yi2qian3bai4shi5wan6qian1shi2yi3qian4baiwanling5bai6shi7

scpc--しιしιπ problem-solving ideas: This is all done tonight (the brain is completely chaotic), that is, the number is entered as a string, and then reversed, with this character array string p[] = {"", "Shi", "Bai", "Qian", "wan", "Shi", "Bai", "Qian", "Yi", "Shi", "Bai", "Qian"}; match, the focus is to pay attention to the processing of multiple zeros , watch the Code ~ ~The code is as follows:
1#include <iostream>2#include <string>3 using namespacestd;4 intar[ the], Len;5 Long LongN;6 stringS,p[] = {"","Shi","Bai","Qian","Wan","Shi","Bai","Qian","Yi","Shi","Bai","Qian" };7 voidChange () {8 Reverse (S.begin (), S.end ());9     intI, flag =0;Ten      for(i = s.size ()-1; I >=0;){ One         if(s[i]-'0'){ AFlag =0; -cout << S[i] <<P[i]; -i--; the         } -         Else{ -             //two conditions cannot swap position if it is 6000, the last i=-1,s[-1] Unreachable (Runtime error once) -              while(i>=0&&! (s[i]-'0')){ +                 if(! I4) &&!flag) { -Flag =1; +cout <<P[i]; A                 } ati--; -             } -             if(I >=0) cout <<"Ling"; -         } -     } -cout <<Endl; in } -  to intMain () { +      while(cin>>s) - Change (); the     return 0; *}
View Code

[Swust OJ 552]--Pinyin Teaching (law-seeking)

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.