Topic 1003:a+b

Source: Internet
Author: User

Title Description:
Given two integers a and b, the representation is: start with a single digit and each three digits separated by a comma ",".
Now calculate the results of the a+b and output in the normal form.
Input:
The
input contains multiple sets of data, one row for each group of data, consisting of two integers a and B ( -10^9 < b < 10^9).
Output:
Please calculate the results of the a+b and output in normal form, one row per group of data.
Sample input:
-234,567,890 123,456,7891,234 2,345,678
Sample output:
-1111111012346912
Can be thought of as a string processing
1 ImportJava.util.Scanner;2  3  Public classmain{4      Public Static voidMain (string[] args) {5Scanner in=NewScanner (system.in);6          while(In.hasnext ()) {7String line=in.nextline ();8String[] Num=line.split ("");9             intAns=0;Ten              for(inti=0;i<2;i++){ OneString[] T=num[i].split (","); AString ans_str= ""; -                 intLen=t.length;//calculated separately so that it does not have to be calculated once for each time in the for loop -                  for(intj=0;j<len;j++){ theans_str+=T[j]; -                 } -ans+=Integer.parseint (ANS_STR); -             } + System.out.println (ans); -         } +     } A } at /************************************************************** - problem:1003 - user:0000h - Language:java - result:accepted - time:80 Ms in memory:15488 KB - ****************************************************************/

Topic 1003:a+b

Related Article

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.