When submitting a solution in C++, please select either C++14 (GCC 6-32) or C++17 (GCC 7-32) as your compiler. ×

Tyr's blog

By Tyr, 11 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

| Write comment?
»
11 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 :)

  • »
    »
    11 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)?

    • »
      »
      »
      11 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;
      }
      
    • »
      »
      »
      11 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();
      }
      
»
10 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.

»
10 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.

»
10 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.

  • »
    »
    10 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 . .