zoukankan      html  css  js  c++  java
  • 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 }
  • 相关阅读:
    对万网主机全部使用独立Ip的猜疑
    对windows8在PC上的前景不看好
    漂浮广告代码3
    <!DOCTYPE> 标签一点点问题
    wordpress模板中用到的条件判断语句例1
    不错的漂浮广告代码2
    autoRST Automated TCP RST Exploit
    菜单项说明以提示弹出
    JIRA安装和破解
    谈组装对象以及对象生存期管理
  • 原文地址:https://www.cnblogs.com/Stomach-ache/p/4024713.html
Copyright © 2011-2022 走看看