One
Each language has its own merits, and when it comes to ACM, if you use Java for beginners, you may want to note several things:
1, the Java code to commit to the main class name.
2, because the main method in the primary class is the public static void type, the methods and variables used inside are also static types, and in addition, they can be invoked by instantiating an object.
public class Main
{
...
void f (int a)
{
...
}
public static void Main (String args[])
{
...
Main m= new Main ();
M.F (1);
...
}
}
3, using structs in Java, you can define a different class instead, and you can add a few methods.
Class good
{
int price;
int weight;
...
}
However, it is important to note that the main class should be placed on the first of all classes at the time of submission, otherwise there may be some problems.
4, there are a number of functions in C/C + + and there are methods in Java that correspond to them.
memset,qsort/sort and bsearch:
Arrays.fill ();
Arrays.sort ();
Arrays.binarysearch ();
5, in Java, Boolean type is Boolean, only true and false two values, in the if (...)/while (...) statements such as the conditions must be The Boolean type.
So the if (n% 2) in C + + ... cannot be compiled in Java .
Two
It's easy to use Java in some places when you're doing a problem.
1, the scanner class in Java has a good support for doing the problem.
Scanner in=new Scanner (system.in);
2, the use of BigInteger and BigDecimal class is also very good in the large number of questions!
Using the Java language in ACM