"Java Input" console input

Source: Internet
Author: User

Accidentally do a very water ACM C kneel and try Java

is to write a binary number variable decimal number, multiple sets of data (Khan. Although later Rejudge. )

Review the Java console input and output

ImportJava.util.Scanner; Public classMain { Public Static voidMain (String args[])throwsException {intCAs; Scanner SC=NewScanner (system.in); CAS=Sc.nextint ();  for(inti=0;i<cas;i++)          {                 while(Sc.hasnext ()) {LongAns=0;                    String s; Charch[]=New Char[34];  for(intk=0;k<=33;k++) ch[i]= ' 0 '; S=sc.next ();//take a continuous value from the result set! The API is interpreted as: Finds and returns the next complete tag from this scanner.                      for(intj = 0; J < S.length (); J + +) {Ch[j]=S.charat (j); Ans=ans*2+ (int) (S.charat (j)-' 0 ');//charAt Usage} System.out.println (ans); }     }}                                                                    

Results:

2
1111
15

11

3

"Java Input" console input

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.