DataGridView Binding Data sources

Source: Internet
Author: User

Reading time limit for the number of basic exercises: 1.0s memory Limit: 512.0MB problem description Tom is teaching a graduate student a course on genetics, one thing that makes him quite a headache: there are thousands of base pairs on a chromosome, numbered from 0 onwards, to millions of, tens of millions of, or even billions.
For example, when explaining to a student the base of position 1,234,567,009th, it is difficult to read the numbers accurately.
So, he desperately needed a system, and then when he entered 12 3456 7009, he would give the corresponding reading method:
1,234,567,009
Expressed in Hanyu Pinyin as
Shi er yi san qian si bai wu shi Liu Wan qi Qian Ling Jiu
So he just needs to read it.
Your task is to help him design such a system: given a string of Arabic numerals, you help him to read and write in accordance with the norms of Chinese pinyin string, the adjacent two syllables with a space character lattice open.
Attention must be strictly in accordance with the specifications, such as "10010" read as "Yi Wan Ling yi shi" instead of "Yi Wan Ling Shi", "100000" read as "Shi Wan" instead of "Yi Shi Wan", "2000" read as "ER qian" instead of "l Iang Qian ". The input format has a number string, and the value size does not exceed 2,000,000,000. The output format is a string of lowercase English letters, commas, and spaces that represent the English reading of the number. Sample input 1234567009 sample output Shi er yi san qian si bai wu shi Liu Wan qi Qian Ling JiuAnalysis: The basic idea is to sample input as an example: String str = "1234567009"

1, the Str from right to left split into a group of 4, is the "1,234,567,009" such form. "Thousands of hundreds of a few more than 10" such a form of 4-bit a good reading, after reading plus units "million" can be, considering the general situation, the leftmost group may be less than 4 bits, less than 4 need to deal with alone

2, because this problem needs to judge the place too much, the detailed problem-solving ideas I do not elaborate, we can take a few examples of their own, and then refer to the following procedures slowly combing ideas

(a little grumble): In response to this problem, I found that the Blue Bridge Cup evaluation data is not comprehensive enough, I just started to write a not enough to consider a comprehensive algorithm program submitted up is 100 points, for which I am very silent. Moreover, through the recent period of time to do these questions, I found that the Blue Bridge Cup on the output data display format requirements are not very strict, especially at the end of the processing of white space characters, more than one less does not seem to have much of a relationship. To synthesize these, I can only say Blue Bridge Cup compared with ACM, there is still a gap!

Import Java.util.scanner;public class Main {static string[] unit = {"", "" "Wan", "Yi"};static string[] digit = {"", "", "Shi", "Bai", "Qian"};p ublic static void Main (string[] args) {Scanner Scanner = new Scanner (system.in); while (SCA Nner.hasnext ()) {String str = scanner.nextline (); char[] CHS = Str.tochararray (); int len = Chs.length;int index = 0;//Record ch s array subscript int group = (len-1)/4 + 1;//4 bit a set of int rest = len% 4;//leftmost may be less than four bits, need to handle string spell separately; StringBuffer result = new StringBuffer (), if (rest! = 0) {if (rest = = 2) {if (chs[index] = = ' 1 ') {result.append ("Shi");} else {spell = getspelling (Chs[index]) result.append (spell + "Shi");} Index++;if (Chs[index]! = ' 0 ') {result.append (getspelling (Chs[index]));} index++;} else {Boolean flag = true;for (int i = rest; i > 0; i--) {Char ch = chs[index++];if (ch! = ' 0 ') {spell = getspelling (ch ), if (flag) {result.append (spell + digit[i]),} else {result.append ("ling" + Spell + digit[i]);}} else {flag = false;}}} Result.append (unit[group--]);} for (int i = group; i > 0; i--) {Boolean flag = true;for (int j = 4; j > 0; j--) {Char ch = chs[index++];if (ch! = ') 0 ') {spell = getspelling (CH), if (flag) {result.append (spell + digit[j]),} else {result.append ("ling" + Spell + digit[j]); Flag = True;}} else {flag = false;}} Result.append (unit[group--]);} Result.deletecharat (Result.length ()-1); SYSTEM.OUT.PRINTLN (result);}}  private static String getspelling (char c) {string spell = Null;switch (c) {case ' 0 ': spell = "Ling"; Break;case ' 1 ': spell = "Yi"; break;case ' 2 ': Spell = "ER"; break;case ' 3 ': spell = "san"; Break;case ' 4 ': spell = "Si"; break;case ' 5 ': spell = "Wu "; Break;case ' 6 ': Spell =" Liu "; break;case ' 7 ': spell =" QI "; Break;case ' 8 ': spell =" ba "; Break;case ' 9 ': spell =" JIU "; BR Eak;} return spell;}}

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.