笔试处理输入模板

// 使用 BufferedReader
// 接受一行作为字符数组,再将字符数组中每个字符转换为整型
import java.io.*;
import java.util.*;
public class Main{

public static void main(String[] args)throws IOException{
BufferedReader b = new BufferedReader(new InputStreamReader(System.in));
String [] a = b.readLine().trim().split(" ");
int n = Integer.parseInt(a[0]);
long w = Integer.parseInt(a[1]);
}

}
// 使用 BufferedReader
// 接收第一行一个 long 作为数组大小,然后接收后面一行作为字符数组,再将字符数组转换为整型数组
import java.util.*;
import java.io.*;
public class Main{

public static void main(String[]args)throws IOException{
BufferedReader b = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(b.readLine());
long[] arr = new long[n];
String[] strs = b.readLine().trim().split(" ");

for(int i= 0; i < n;i++){
arr[i] = Integer.parseInt(strs[i]);
}
b.close();
}

}
// 使用 Scanner
// 先接收一个 int 作为数组大小,随后接受数组中的数
import java.util.Scanner;
import java.util.PriorityQueue;

public class Main {

public static void main(String[] args) {
// 接收数组 nums ,数组长度 nums_len
Scanner scanner = new Scanner(System.in);
int nums_len = scanner.nextInt();
int[] nums = new int[nums_len];
for (int i = 0; i < nums.length; i++) {
nums[i] = scanner.nextInt();
}
scanner.close();
}

}
// 数组转换为链表
// n 为链表长度,返回链表头节点
private static Node createNode(String[] str,int n){
Node head = new Node(Integer.parseInt(str[0]));
Node node = head;
for(int i=1;i<n;i++){
Node newNode = new Node(Integer.parseInt(str[i]));
node.next = newNode;
node = newNode;
}
return head;
}
//链表节点结构
class Node{
int val;
Node head;
Node next;
Node(int val){
this.val = val;
}
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值