全部评论
java的可以用sc.next()按行读,再用split划分
我是用正则提取的 (\\d+),(\\d+);?
读取3,4 scanf("%d,%d", &x, &y);
读取 3,4;5,6;7,8 scanf("%d,%d", &x, &y);
// 一些处理逻辑
while(scanf(";%d,%d", &x, &y)) {
//一些处理逻辑
}
Scanner in = new Scanner(System.in);
int m = Integer.parseInt(in.nextLine());
ArrayList<Interval> input = new ArrayList<>();
for(int i = 0; i < m; i++){
String[] errorsClassifiedByEditors = in.nextLine().split(";");
for(int j = 0; j < errorsClassifiedByEditors.length; j++){
String[] errors = errorsClassifiedByEditors[j].split(",");
input.add(new Interval(Integer.parseInt(errors[0]), Integer.parseInt(errors[1])));
}
}
in.close();
初次看这题,好像leetcode有类似的题?
按照string类型读,stringstream处理
按例题输入就行!
scanf("%*d"); while (scanf("%d,%d%*c", &x, &y) > 0) ……
相关推荐
02-24 19:45
西南大学 后端工程师
程序员小白条:简历写的有点太多了,一般两页是实习经历比较多的情况下,要么自己有一些有影响力的开源项目,如果你走软件,硬件没必要实习,学校安排总是没区分度的,央国企最好有中大厂实习,另外学历比较重要,不是都要求硕士的,技术会比互联网要求低一些 点赞 评论 收藏
分享
03-12 11:56
广西艺术学院 项目助理 点赞 评论 收藏
分享
