import java.util.Arrays;
import java.util.Scanner;
public class Main38 {
public static void main(String[] args){
int[] goadcount = new int[100];
Arrays.fill(goadcount, 0);
Scanner sc = new Scanner(System.in);
int countren = sc.nextInt();
for(int i = 0;i<countren;i++){
int grade = sc.nextInt();
goadcount[grade-1]++;
}
int scan = sc.nextInt();
for(int i = 0;i<scan-1;i++){
int grade = sc.nextInt();
System.out.print(goadcount[grade-1]+" ");
}
System.out.print(goadcount[sc.nextInt()-1]);
}
}

pat乙级题目,10038Java,运行有两个有错,看不出是哪有错,考虑不全吗?
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
3条回答 默认 最新
- CSDN专家-sinJack 2021-10-28 20:11关注
import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { int[] score = new int[101]; Scanner in=new Scanner(System.in); int n =in.nextInt(); String[] input = in.nextLine().split(" "); for (int i = 0; i < n; i++) { score[Integer.parseInt(input[i])]++; } String[] s = in.nextLine().split(" "); int k = Integer.parseInt(s[0]); for (int i = 0; i < k - 1; i++) { System.out.print(score[Integer.parseInt(s[i + 1])] + " "); } System.out.print(score[Integer.parseInt(s[s.length - 1])]); } }
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决评论 打赏 举报无用 1
悬赏问题
- ¥15 PCL注册的选点等函数如何取消注册
- ¥15 问一下各位,为什么我用蓝牙直接发送模拟输入的数据,接收端显示乱码呢,米思齐软件上usb串口显示正常的字符串呢?
- ¥15 Python爬虫程序
- ¥15 crypto 这种的应该怎么找flag?
- ¥15 代码已写好,求帮我指出错误,有偿!
- ¥15 matlab+波形匹配算法
- ¥15 转录组分析做聚类树图时癌旁组被分到了癌组
- ¥15 大一Python字典
- ¥15 multisim电路设计(相关搜索:设计报告)
- ¥15 PC-lint Plus