View Code of Problem 18

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        while (scanner.hasNext()){
            int n=Integer.parseInt(scanner.nextLine());
            int m=n/2;
            int sum=((m-1)*m)/2;
            if(n%2!=0)   //奇数环
            {
                sum+=sum+m;
            } else {
                sum+=sum;
            }
            System.out.println(sum);
        }
    }
}

/*
Main.java:10: error: unmappable character for encoding ASCII
            if(n%2!=0)   //?????????
                           ^
Main.java:10: error: unmappable character for encoding ASCII
            if(n%2!=0)   //?????????
                            ^
Main.java:10: error: unmappable character for encoding ASCII
            if(n%2!=0)   //?????????
                             ^
Main.java:10: error: unmappable character for encoding ASCII
            if(n%2!=0)   //?????????
                              ^
Main.java:10: error: unmappable character for encoding ASCII
            if(n%2!=0)   //?????????
                               ^
Main.java:10: error: unmappable character for encoding ASCII
            if(n%2!=0)   //?????????
                                ^
Main.java:10: error: unmappable character for encoding ASCII
            if(n%2!=0)   //?????????
                                 ^
Main.java:10: error: unmappable character for encoding ASCII
            if(n%2!=0)   //?????????
                                  ^
Main.java:10: error: unmappable character for encoding ASCII
            if(n%2!=0)   //?????????
                                   ^
9 errors
*/

Double click to view unformatted code.


Back to problem 18