• ACM常用的Java代码


     1 import java.util.*;
     2 import java.io.*;
     3 
     4 public class Main {
     5     public static void main(String[] args) throws IOException{
     6         // 计算程序运行时间 
     7         // Arrays
     8         long st = System.currentTimeMillis();
     9         if ("abc" == "abc") System.out.println("Yes1");
    10         String str1 = new String("abc");
    11         String str2 = new String("abc");
    12         if (str1 == str2) System.out.println("Yes2");
    13         if (str1.equals(str2)) System.out.println("Yes3");
    14         
    15         //
    16         int[] t = {5, 1, 3, 2, 9};
    17         Arrays.sort(t);
    18         System.out.println(Arrays.toString(t));
    19         int[] s = new int[10];
    20         Arrays.fill(s, 33);
    21         System.out.println(Arrays.toString(s));
    22         // returns ((-insertion point) - 1) if key not exists.
    23         System.out.println(Arrays.binarySearch(t, 4));
    24         int cnt = 0;
    25         for (int i = 1; i < 100000000; i++) {cnt++;}
    26         long ed = System.currentTimeMillis();
    27         System.out.println("time: " + (ed - st));
    28         
    29         // 字符串hash
    30         String str = new String("hello world");
    31         System.out.println("hash Code: " + str.hashCode());
    32         
    33         // BufferReader缓冲与换行读取功能
    34         BufferedReader cin = new BufferedReader(new InputStreamReader(System.in));
    35         int sum = 0;
    36         String ss = null;
    37         while ((ss = cin.readLine()) != null) {
    38             sum += Integer.parseInt(ss);
    39         }
    40         System.out.println("the sum is: " + sum);
    41         
    42         //
    43         
    44     }
    45 }
  • 相关阅读:
    将HTML格式的String转化为HTMLElement
    程序执行效率
    Oracle之sql追踪
    单行bash、shell、perl命令
    主机安装
    时间序列分析
    R统计图
    需求分析
    oracle数据导入导出
    linux权限问题
  • 原文地址:https://www.cnblogs.com/Stomach-ache/p/4024713.html
Copyright © 2020-2023  润新知