#include <stdio.h> #include <stdlib.h> #include <string.h>

#define MAXN 1005 #define MAXK 15

int n, cnt[MAXN]; int *p[MAXN][MAXK];

int cmp(const void *a, const void *b) { return *(int *)a - *(int *)b; }

int main() { scanf("%d", &n); for (int i = 0; i < n; ++i) { int k; scanf("%d", &k); for (int j = 0; j < k; ++j) { p[i][j] = (int *)malloc(sizeof(int)); scanf("%d", p[i][j]); } qsort(p[i], k, sizeof(int *), cmp); }

int max = -1, maxIndex = -1;
for (int i = 0; i < n; ++i)
    for (int j = 0; j < MAXK; ++j)
        if (p[i][j] != NULL)
        {
            int k = *p[i][j];
            ++cnt[k];
            if (cnt[k] > max || (cnt[k] == max && k > maxIndex))
            {
                max = cnt[k];
                maxIndex = k;
            }
            free(p[i][j]);
        }

printf("%d %d\n", maxIndex, max);

return 0;
编写一个C语言代码通过统计一个人点赞的纪录分析这个人的特性。输入格式:输入在第一行给出一个正整数N≤1000是该用户点赞的博文数量。随后N行每行给出一篇被其点赞的博文的特性描述格式为K F 1 ⋯F K 其中1≤K≤10F i i=1⋯K是特性标签的编号我们将所有特性标签从1到1000编号。数字间以空格分隔。输出格式:统计所有被点赞的博文中最常出现的那个特性标签在一行中输出它的编号和出现次数

原文地址: http://www.cveoy.top/t/topic/hpmT 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录