import java.io.*;
import java.math.BigInteger;
import java.util.*;
public class Main{
static int n, m;
static int N = (int)1e5+10;
static int mod = (int)10000;
// static int[][] f = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}, {1, -1}, {1, 1}, {-1, 1}, {-1, -1}};
// static int[][] ff = {{0, -1, 0}, {0, 0, 1}, {0, 1, 0}, {0, 0, -1}, {1, 0, 0}, {-1, 0, 0}};
static StreamTokenizer stt = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
static int c;
static int[] o = new int[N];
static class AA implements Comparable<AA>{
int a, b;
@Override
public int compareTo(Main.AA o) { // 重写比较函数
/*
* 返回值 小于0不交换
* 返回值 等于0表示两对象相等
*/
return 0;
}
@Override
public int hashCode() { // 假如要用Map建立对象的映射需要重写hashcode方法
return Objects.hash(a, b, c); // 将所有参数放进去即可
}
@Override
public boolean equals(Object obj) { // 重写equals函数
// TODO Auto-generated method stub
AA o = (AA)obj;
return a==o.a && b==o.b;
}
}
static AA[] O = new AA[N];
static void sovle() throws Exception {
// 大数计算
while(true) {
String str = br.readLine(), str1 = br.readLine();
if("00000".equals(str)) break;
BigInteger a = new BigInteger(str), b = new BigInteger(str1);
// System.out.println(str + "\n" + str1);
System.out.println(a.add(b)); // +
System.out.println(a.subtract(b)); // -
System.out.println(a.multiply(b));// *
System.out.println(a.divide(b));// /
System.out.println(a.gcd(b));
}
// 队列
Queue<Integer> q = new LinkedList<Integer>();
for(int i = 1; i < 10; i ++) {
q.add(i);
}
while(q.size() > 0) {
bw.write(q.peek() + " "); // 返回队头
q.poll(); // 删除对头
}
// vector
Vector<Integer> v = new Vector<Integer>();
for(int i = 1; i < 11; i ++) {
v.add(i); // 尾插,如果是两个参数,第一个位置为插入位置的下标,第二天位置为插入的值
}
bw.write("Vector的遍历\n");
for(int i = 0; i < v.size(); i ++) {
bw.write(v.get(i) + " "); // 返回值
}
bw.write("\n");
v.remove(1); // 参数下标
// HashSet hash实现 插入删除o(1)
Set<Integer> s = new HashSet<>();
for(int i = 1; i < 11; i ++) {
s.add(i);
}
bw.write("HashSet集合遍历\n");
for(int i : s) {
bw.write(i + " ");
}bw.write("\n");
bw.write("5是否存在:" + s.contains(5) + "\n");
bw.write("31是否存在:" + s.contains(31) + "\n");
// 用来建立映射关系
Map<Integer, Integer> m = new HashMap<>();
// 没有HashMap快,但是内部有序,以key键排序
Set<Integer> s2 = new TreeSet<>(new Comparator<Integer>() {
@Override
public int compare(Integer o1, Integer o2) { // 排序规则重写
// TODO Auto-generated method stub
return o1-o2;
}
});
for(int i = 10; i > 0; i --) {
s2.add(i);
}
bw.write("TreeSet集合遍历:\n");
for(Integer i : s2) {
bw.write(i + " ");
}
bw.write("\n");
bw.write("5是否存在:" + s2.contains(5) + "\n");
bw.write("31是否存在:" + s2.contains(31) + "\n");
// 优先队列
PriorityQueue<Integer> pq = new PriorityQueue<>(new Comparator<Integer>(){
@Override
public int compare(Integer o1, Integer o2) { // 用来优先队列的排序函数
// TODO Auto-generated method stub
return 0;
}
});
// 用来得到一些数的hash值
int[] ars = new int[100];
int a = Objects.hash(1, 2, 3, 4);
bw.write(a + "\n");
while(pq.size() > 0) {
int a1 = pq.peek(); // 返回队头
pq.poll(); // 删除对头
}
// sort排序函数
Arrays.sort(O, new Comparator<AA>(){
@Override
public int compare(Main.AA o1, Main.AA o2) { // 用来重写比较函数
// TODO Auto-generated method stub
return 0;
}
});
}
public static void main(String args[]) throws Exception {
int t = 1;
// t = Integer.parseInt(br.readLine());
// t = readInt();
while((t --) > 0) {
// while((n = Integer.parseInt(br.readLine())) != 0) {
// while((in = br.readLine().split(" ")) != null) {
// if(in[0] == "0" && in[1] == "0") return ;
sovle();
}
bw.flush();
bw.close();
}
static int readInt() throws IOException {
stt.nextToken();
return (int) stt.nval;
}
}
12-31
645
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)