ACM常用的Java代码
2024-09-06 11:41:12
import java.util.*;
import java.io.*; public class Main {
public static void main(String[] args) throws IOException{
// 计算程序运行时间
// Arrays
long st = System.currentTimeMillis();
if ("abc" == "abc") System.out.println("Yes1");
String str1 = new String("abc");
String str2 = new String("abc");
if (str1 == str2) System.out.println("Yes2");
if (str1.equals(str2)) System.out.println("Yes3"); //
int[] t = {5, 1, 3, 2, 9};
Arrays.sort(t);
System.out.println(Arrays.toString(t));
int[] s = new int[10];
Arrays.fill(s, 33);
System.out.println(Arrays.toString(s));
// returns ((-insertion point) - 1) if key not exists.
System.out.println(Arrays.binarySearch(t, 4));
int cnt = 0;
for (int i = 1; i < 100000000; i++) {cnt++;}
long ed = System.currentTimeMillis();
System.out.println("time: " + (ed - st)); // 字符串hash
String str = new String("hello world");
System.out.println("hash Code: " + str.hashCode()); // BufferReader缓冲与换行读取功能
BufferedReader cin = new BufferedReader(new InputStreamReader(System.in));
int sum = 0;
String ss = null;
while ((ss = cin.readLine()) != null) {
sum += Integer.parseInt(ss);
}
System.out.println("the sum is: " + sum); // }
}
最新文章
- InnoDB还是MyISAM 再谈MySQL存储引擎的选择
- Web3DGame之路,Babylonjs 和TypeScript学习笔记(一)
- php解析.csv文件
- C++ 中超类化和子类化
- [转]开发Visual Studio风格的用户界面--MagicLibrary使用指南
- maya2105 - windows8 - numpy/scipy
- C++ 语法规则
- C#关闭显示屏,使显示屏处于待机状态
- project euler 12 Highly divisible triangular number
- hdu_5890_Eighty seven(bitset优化DP)
- 南天PR2、PR2E驱动下载,xp,win7,win8,win8.1,win10 32位64位驱动下载安装教程
- LVS-DR模式(原理图详解)
- 0109 ubuntu nginx ssl
- Facebook主页照片和封面照片的尺寸要求
- ARM开发板挂载虚拟机 nfs目录
- 【mybatis】使用mybatis框架中踩过的坑
- yzh的神仙题
- linux下(Window当然也可以)解决idea创建maven项目导入过慢问题
- 与前端对接 jsonp
- 葡萄城报表介绍:矩表(Tablix)