Spell checker(串)
http://poj.org/problem?id=1035
题意:给定一个单词判断其是否在字典中,若存在输出"%s is correct",否则判断该单词删掉一个字母,或增加一个字母,或替换一个字母后是否存在于字典中。
#include<stdio.h>
#include<string.h>
int deal(char *s1,char *s2)
{
int i = ;
int len1 = strlen(s1);
int len2 = strlen(s2);
if(len1==len2)//替换
{
while(i < len1 && s1[i]==s2[i])
i++;
while(++i < len1)
{
if (s1[i]!=s2[i])
return ;
}
}
else if (len2-==len1)//添加
{
while(i < len1 && s1[i]==s2[i])
i++;
while(++i < len2)
{
if (s1[i-]!=s2[i])
return ;
}
}
else if (len2+==len1)//删除
{
while(i < len2 && s1[i]==s2[i])
i++;
while(++i < len1)
{
if (s1[i]!=s2[i-])
return ; }
}
else
return ;
return ;
}
int main()
{
char s1[][],s2[];
int i;
for (i = ;; i ++)
{
scanf("%s",s1[i]);
if (s1[i][]=='#')
break;
}
int n = i;
for (;;)
{
scanf("%s",s2);
if (s2[]=='#')
break;
for (i = ; i < n; i ++)
{
if (!strcmp(s1[i],s2))
{
printf("%s is correct\n",s2);
break;
}
}
if (i < n)
continue;
printf("%s:",s2);
for (i = ; i < n; i ++)
{
if(deal(s1[i],s2))
printf(" %s",s1[i]);
}
printf("\n");
}
return ;
}
Spell checker(串)的更多相关文章
- POJ 1035 Spell checker(串)
题目网址:http://poj.org/problem?id=1035 思路: 看到题目第一反应是用LCS ——最长公共子序列 来求解.因为给的字典比较多,最多有1w个,而LCS的算法时间复杂度是O( ...
- poj 1035 Spell checker
Spell checker Time Limit: 2000 MS Memory Limit: 65536 KB 64-bit integer IO format: %I64d , %I64u J ...
- Spell checker
Spell checker Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Subm ...
- Spell checker(暴力)
Spell checker Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 20188 Accepted: 7404 De ...
- POJ1035——Spell checker(字符串处理)
Spell checker DescriptionYou, as a member of a development team for a new spell checking program, ar ...
- poj 1035 Spell checker ( 字符串处理 )
Spell checker Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 16675 Accepted: 6087 De ...
- [ACM] POJ 1035 Spell checker (单词查找,删除替换添加不论什么一个字母)
Spell checker Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 18693 Accepted: 6844 De ...
- POJ训练计划1035_Spell checker(串处理/暴力)
Spell checker Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 18418 Accepted: 6759 De ...
- Spell checker POJ 1035 字符串
Spell checker Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 25426 Accepted: 9300 De ...
- POJ 1035:Spell checker
Spell checker Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 22574 Accepted: 8231 De ...
随机推荐
- 更改计算机名后DB2不能启动的解决方法
1.找到以下位置目录下相应的文件db2nodes.cfg C:\Documents and Settings\All Users\Application Data\IBM\DB2\DB2COPY1\D ...
- 用shell编写dhcp自动获取脚本
#!/bin/bash#net=$(ifconfig ens33 | awk -F'[ .]+' '/inet\>/{print $3"."$4"."$5 ...
- Quartz.NET 定时任务使用
class Program { static void Main(string[] args) { StartJob(); Console.ReadKey(); } static void Start ...
- 6.shell脚本
6.1 shell基础语法 6.1.1 shell的概述 shell的基本概念 1.什么是shell shell是用户和Linux操作系统之间的接口,它提供了与操作系统之间的通讯方式 shell是一个 ...
- uva 1585 Score(Uva-1585)
vj:https://vjudge.net/problem/UVA-1585 不多说水题一个o一直加x就加的变为0 我的代码 #include <iostream> #include &l ...
- socket 网络编程笔记 一
初始socket模块 Serve端代码 import socket sk = socket.socket() #默认为TCP连接 """socket 里面两个方法 fam ...
- 微信小程序·前端-锦囊
========================== flex[盒子] display: flex; flex-direction: column; [从上到下排列]↓ justify-conte ...
- nagios新增监控集群、卸载监控集群批量操作
1.一定要找应用侧确认每台节点上需要监控的进程,不要盲目以为所有hadoop集群的zk.journal啥的都一样,切记! 2.被监控节点只需要安装nagios-plugin和nrpe,依赖需要安装xi ...
- 【ACM】hdu_zs3_1007_Rails_201308100802
Rails Time Limit : 2000/1000ms (Java/Other) Memory Limit : 20000/10000K (Java/Other)Total Submissi ...
- 贪心算法 Heidi and Library (easy)
A. Heidi and Library (easy) time limit per test 2 seconds memory limit per test 256 megabytes input ...