当前位置: 首页 > news >正文

CCF20240302——相似度计算

CCF20240302——相似度计算

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
代码如下:

#include <stdio.h>
#include <string.h>
#include <ctype.h>#define MAX_WORD_LEN 100
#define MAX_WORDS 10000int main() {int n, m;scanf("%d %d", &n, &m);char words1[MAX_WORDS][MAX_WORD_LEN];char words2[MAX_WORDS][MAX_WORD_LEN];char temp_word[MAX_WORD_LEN];int size1 = 0, size2 = 0;// 读取第一篇文章的单词for (int i = 0; i < n; i++) {scanf("%s", temp_word);// 转换为小写for (int j = 0; temp_word[j]; j++) {if (temp_word[j] >= 'A' && temp_word[j] <= 'Z') {temp_word[j] += 'a' - 'A';}}// 检查是否已经在words1中int found = 0;for (int j = 0; j < size1; j++) {if (strcmp(temp_word, words1[j]) == 0) {found = 1;break;}}if (!found) {strcpy(words1[size1++], temp_word);}}// 读取第二篇文章的单词for (int i = 0; i < m; i++) {scanf("%s", temp_word);// 转换为小写for (int j = 0; temp_word[j]; j++) {if (temp_word[j] >= 'A' && temp_word[j] <= 'Z') {temp_word[j] += 'a' - 'A';}}// 检查是否已经在words2中int found = 0;for (int j = 0; j < size2; j++) {if (strcmp(temp_word, words2[j]) == 0) {found = 1;break;}}if (!found) {strcpy(words2[size2++], temp_word);}}int intersection_count = 0;int union_count = size1;// 计算交集for (int i = 0; i < size2; i++) {int found = 0;for (int j = 0; j < size1; j++) {if (strcmp(words2[i], words1[j]) == 0) {found = 1;break;}}if (found) {intersection_count++;} else {union_count++;}}printf("%d\n", intersection_count);printf("%d\n", union_count);return 0;
}

在这里插入图片描述

http://www.lryc.cn/news/356081.html

相关文章:

  • C++的第一道门坎:类与对象(二)
  • C语言与内存息息相关的重要概念有哪些?
  • 【chagpt】广泛使用API之前:考虑成本和数据隐私
  • 六月后考研如何备考看这一篇就够了
  • Linux主机连接腾讯云服务器详细配置
  • 数字化工厂怎么收集,处理数据?
  • OOM不会导致JVM退出
  • C++学习日记 | LAB 6 static library 静态库
  • 他用AI,抄袭了我的AI作品
  • 力扣刷题--2956. 找到两个数组中的公共元素【简单】
  • 海信集团携纷享销客启动LTC数字化落地 推动ToB业务再升级
  • 【Go语言入门学习笔记】Part5.函数
  • 磁珠笔记汇总
  • 【css3】02-css3新特性之选择器篇
  • 修正错误的插入排序
  • Unity 权限 之 Android 【权限 动态申请】功能的简单封装
  • 跟进2年弄丢1.8亿,你的大客管理错在哪里?
  • 浅说线性DP(上)
  • leetcode题目18
  • 后端企业级开发之yaml数据序列化格式文件详解2024
  • 智能界面设计:数字孪生与大数据结合的美学典范
  • 听说部门来了个00后测试开发,一顿操作给我整麻了
  • Linux shell命令
  • 【Linux】Linux基本指令1
  • 重学java 49 增强for
  • BUUCTF靶场[Web] [极客大挑战 2019]Havefun1、[HCTF 2018]WarmUp1、[ACTF2020 新生赛]Include
  • 现代信号处理11_Spectral Analysis谱分析(CSDN_20240526)
  • C#开发上位机应用:基础与实践
  • 话术巧妙分隔沟通效果更佳看看这个小技巧
  • 【Spring】设计模式(GOF)