Блог пользователя affix

Автор affix, 14 лет назад, По-английски
Hi everyone.
i was accepting some easy problems and reading peoples code in solution size order.
and in most problems C++ was not best language and vice versa when i was reading solutions in harder problems C++ was  better than other languages in solution size.
what do you think about this?
which language is winner?
  • Проголосовать: нравится
  • -9
  • Проголосовать: не нравится

14 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

IMHO, the language does not matter much (if this language does not require you to implement hashmaps, lists, qsorts, priority queues etc manually). If you know C++ libraries well - use it, if not - you may optionally learn java.

I've started training in TC and later CF with the only goal - to practice java. Before that I was programming mainly in C, for about 10 years. My knowledge of C++ stl was extremely weak, but java API provide a great comfort to me.

For TC any problem could be solved in java, since problemsetters write reference solutions in it. I do not know how about CF, but it seems that the only case to prefer C++ is when you are trying some inefficient solution and want to run it as fast as possible. In other cases you find that C++ and java provide very similar abilities, but with C++ you need to be more accurate and attentive. (However if you have great experience with C++, the idea of changing language to java would not be adequate)

For simplest problems also you may want to use perl or python, which allow you some economy of time (if you do not use code templates).

Also java/python/perl is preferable for those rare problems when you may want to use regexps.

  • 14 лет назад, скрыть # ^ |
    Rev. 2  
    Проголосовать: нравится +8 Проголосовать: не нравится

    a thousand of imps, please, rewrite this code in Java using notepad as IDE:

    #include <iostream>
    int main()
    {
        long long sum = 0, x = 0;
        while (cin>>x, x)
            sum += x;
        cout<<sum;
    }

    • 14 лет назад, скрыть # ^ |
      Rev. 2  
      Проголосовать: нравится +5 Проголосовать: не нравится

      By the way your code yields compile errors: "cin, cout were not declared in this scope" I shall use comment-editing field right here "as an IDE":


      public class AnonimousTest {
      public static void main(String... args) {
      java.util.Scanner in = new java.util.Scanner(System.in);
      long sum = 0, x = 0;
      while ((x = in.nextInt()) != 0) {
      sum += x;
      } // while
      System.out.println(sum);
      } // main
      } // class AnonimousTest
      Well, I've made idiotic mistake too - see the previous edition.
14 лет назад, скрыть # |
 
Проголосовать: нравится +10 Проголосовать: не нравится
Solution size is a bad metric to be honest.