import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t-->0){
int n = sc.nextInt();
int m = sc.nextInt();
int count = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
int x = sc.nextInt();
if (x==1) {
count++;
}
}
}
System.out.println(count);
}
sc.close();
}
}
HDOJ 2560 Buildings (水题)
最新推荐文章于 2021-05-16 21:25:15 发布
本文介绍了一个使用Java编写的简单程序,该程序通过读取输入来计算特定元素出现的次数。程序利用了Scanner类从标准输入获取数据,并采用双重循环遍历所有元素进行计数。

94

被折叠的 条评论
为什么被折叠?



