Tyr's blog

By Tyr, 9 years ago, In English

Hi !

Can any of java coders provide me a good template for submitting solutions in different online judges ? I always have trouble with StringTokenizer and so on..., maybe you say so forget java ! and code in C++ but I say java is Cool and java coders are different so I want to be different to (despite the fact that language is nothing but a tool and algorithm and problem solving is important as we see in Knuth TAOCP that he uses Assembly !)

 
 
 
 
  • Vote: I like it
  • -8
  • Vote: I do not like it

»
9 years ago, # |
  Vote: I like it 0 Vote: I do not like it

You can just look at some Java coders' solutions, such as Petr's or mine :)

  • »
    »
    9 years ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    Thank you man, how can you write things like while(cin >> n) with your fast scanner (how can you read until end of file)?

    • »
      »
      »
      9 years ago, # ^ |
      Rev. 4   Vote: I like it 0 Vote: I do not like it

      If you use StringTokenizer's template try:

      public boolean hasNext() {
      	while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      		try {
      			String line = reader.readLine();
      			if (line == null) {
      				return false;
      			}
      			tokenizer = new StringTokenizer(line);
      		} catch (IOException e) {
      			throw new RuntimeException(e);
      		}
      	}	
      	return true;
      }
      
    • »
      »
      »
      9 years ago, # ^ |
      Rev. 2   Vote: I like it 0 Vote: I do not like it

      I do it such way:

      String s = in.readLine();
      while(s != null)
      {
      // Do smth with s here(trim, split, parse, etc.)
      s = in.readLine();
      }
      
    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      try{ // any input code here } catch(Exception e) { // if no input }

»
9 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Thanks every body !

»
8 years ago, # |
  Vote: I like it -17 Vote: I do not like it

Great Information admin thanks For Your Information and Any body wants learn JAVA through Online for Details Please go through the Link Online JAVATraining with free Demo class in USA | UK | INDIA | SINGAPORE This Will Helps you allot.

»
8 years ago, # |
  Vote: I like it -25 Vote: I do not like it

Great Information admin thanks For Your Information and Any body wants learn Core JAVA through Online for Details Please go through the Link Online Core JAVA Training with free Demo class in USA | UK | INDIA | SINGAPORE This Will Helps you allot.

»
8 years ago, # |
  Vote: I like it -27 Vote: I do not like it

Great Information admin thanks For Your Information and Any body wants learn Core java through Online for Details Please go through the Link Online Core java Training with free Demo class in USA | UK | INDIA | SINGAPORE This Will Helps you allot.

  • »
    »
    8 years ago, # ^ |
      Vote: I like it +8 Vote: I do not like it

    • »
      »
      »
      8 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      13 months have(has?) passed!!! and I am still in the middle of nowhere!!! but a lot of things happened to me in these months, falling in love, going to masters, failing in love and life goes on ....

»
7 years ago, # |
  Vote: I like it -28 Vote: I do not like it

We are announcing greatly that we are presenting Teksonit Online Institute all over the world for all courses.So Our teaching techniques are very unique when compare to the other.Great Information admin thanks For Your Information and Any body wants learn Core Java through Online for Details Please go through the Link Online Core Java Training with free Demo class in USA | UK | INDIA | SINGAPORE This Will Helps you allot.

  • »
    »
    7 years ago, # ^ |
    Rev. 3   Vote: I like it 0 Vote: I do not like it

    Codeforces is not for Advertising. so please stop writing these kind of spam comments . .

»
6 years ago, # |
  Vote: I like it -8 Vote: I do not like it

Great Information admin thanks For codeforces.com and Any body wants learn JAVA through Online for Details Please go through the Link Online JAVATraining , python , tableau , qlikview , business analyst , sql , linux , shell scripting , salesforce , san , sas with free Demo class in USA | UK | INDIA | SINGAPORE.

»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it