首页 > 试题广场 >

分组统计

[编程题]分组统计
  • 热度指数:5607 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32M,其他语言64M
  • 算法知识视频讲解
先输入一组数,然后输入其分组,按照分组统计出现次数并输出参见样例。

输入描述:
输入第一行表示样例数m,对于每个样例,第一行为数的个数n,接下来两行分别有n个数,第一行有n个数,第二行的n个数分别对应上一行每个数的分组,n不超过100。


输出描述:
输出m行,格式参见样例,按从小到大排。
示例1

输入

1
7
3 2 3 8 8 2 3
1 2 3 2 1 3 1

输出

1={2=0,3=2,8=1}
2={2=1,3=0,8=1}
3={2=1,3=1,8=0}
头像 wbc990512
发表于 2021-01-28 21:48:29
这题有的条件没给清楚。。数字范围应该是小于等于1000,组数是小于等于100(调bug调了俩小时发现是hash数组的列应该赋1001而我赋了1000!!!)思路:用一个二维数组来存储每一组中某一数字的个数。行标作为组号,列标为数字,值为次数。 #include<stdio.h> #inc 展开全文
头像 在考古的小鱼干很有气魄
发表于 2023-03-14 12:50:17
#include <bits/stdc++.h> #define MAX 1000 using namespace std; int main(){ int m,n; int v[MAX],index[MAX]; set<int> s1; //去重排序用 set&l 展开全文
头像 marlin818
发表于 2024-03-14 15:55:01
#include <iostream> #include <set> #include <cstring> using namespace std; int f[110][1010]; //i组j数 int a[1010], b[1010]; int main() 展开全文
头像 牛客475334106号
发表于 2024-03-18 12:34:18
#include <array> #include <iostream> #include <map> #include <vector> using namespace std; int main() { int m, n, t; 展开全文
头像 Brillianman
发表于 2023-02-06 19:30:08
#include<stdio.h> #define MaxSize 1900 void clear(int* A) { int i; for (i = 0; i < MaxSize; i++)A[i] = 0; } void recover(int* A) { 展开全文
头像 HENU彭于晏
发表于 2023-03-30 10:48:20
#include<cstdio> #include<map> #include<vector> #include<algorithm> using namespace std; struct FZ { int num; int organ; }; 展开全文
头像 华水计科26713
发表于 2023-03-17 10:25:55
#include <iostream> #include <set> #include <vector> #include "bits/stdc++.h" using namespace std; int count(vector<int> vec, 展开全文