Spell checker(poj 1035)
题意:
#include<cstdio>
#include<iostream>
#include<cstring>
#define M 10010
#define N 15
using namespace std;
char ch[M][N],s[N];
int a[M];
int search(char *a,char *b)
{
int lena=strlen(a);
int lenb=strlen(b);
if(lena==lenb)
{
int flag=;
for(int i=;i<lena;i++)
if(a[i]!=b[i])
if(!flag) flag=;
else return ;
if(flag==)return ;
}
if(lena==lenb+)
{
int pa=,pb=,flag=;
while()
{
if(pa>=lena&&pb>=lenb)break;
if(a[pa]==b[pb])
{
pa++;
pb++;
}
else
if(!flag)
{
flag=;
pa++;
}
else return ;
}
if(flag==)return ;
}
if(lena==lenb-)
{
int pa=,pb=,flag=;
while()
{
if(pa>=lena&&pb>=lenb)break;
if(a[pa]==b[pb])
{
pa++;
pb++;
}
else
if(!flag)
{
flag=;
pb++;
}
else return ;
}
if(flag==)return ;
}
return ;
}
int main()
{
int n=;
while()
{
scanf("%s",ch[++n]);
if(ch[n][]=='#')
{
n--;
break;
}
}
while()
{
int flag=,cnt=;
scanf("%s",s);
if(s[]=='#')break;
printf("%s",s);
for(int i=;i<=n;i++)
{
if(strcmp(s,ch[i])==)
{
printf(" is correct\n");
flag=;
break;
}
else if(search(s,ch[i]))
a[++cnt]=i;
}
if(!flag)
{
printf(":");
for(int i=;i<=cnt;i++)
printf(" %s",ch[a[i]]);
printf("\n");
}
}
return ;
}
Spell checker(poj 1035)的更多相关文章
- POJ 1035 Spell checker (模拟)
题目链接 Description You, as a member of a development team for a new spell checking program, are to wri ...
- Spell checker(串)
http://poj.org/problem?id=1035 题意:给定一个单词判断其是否在字典中,若存在输出"%s is correct",否则判断该单词删掉一个字母,或增加一个 ...
- 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: 2000 MS Memory Limit: 65536 KB 64-bit integer IO format: %I64d , %I64u J ...
- 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 ...
- POJ 1035 代码+具体的目光
Spell checker Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 19319 Accepted: 7060 Descri ...
- VSCode中插件Code Spell Checker
说在前面 介绍 Code Spell Checker 是在VSCode中的一款插件,能够帮助我们检查单词拼写是否出现错误,检查的规则遵循 camelCase (驼峰拼写法). 安装方法 打开VSCod ...
随机推荐
- HDU 1285 确定比赛名次
传送门 确定比赛名次 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total ...
- codeforce 626E(二分)
E. Simple Skewness time limit per test 3 seconds memory limit per test 256 megabytes input standard ...
- jmap命令详解
1.命令基本概述 Jmap是一个可以输出所有内存中对象的工具,甚至可以将VM 中的heap,以二进制输出成文本.打印出某个java进程(使用pid)内存内的,所有‘对象’的情况(如:产生那些对象,及其 ...
- hibernate提供的5种检索数据方式
一.五种检索数据方式 1.OID检索,即使用session.get或session.load通过类及指定id查询数据,如Customer c=(Customer)session.get("C ...
- find只查当前目录 和 -exec和xargs区别
1.find默认查找当前目录和子目录,通过maxdepth限制只查当前目录: find . -maxdepth 1 -type f -name "*.php" 2. find . ...
- centos7 nginx用systemctl方式管理的脚本
vim /usr/lib/systemd/system/nginx.service [Unit] Description=nginx - high performance web server Doc ...
- mysql字符串截取
mysql字符串截取 update zcat ) where lev1 is null; update zcat ) where lev2 is null; 函数: 1.从左开始截取字符串 left( ...
- Array和ArrayList互相转换
class Order{ public string orderId; public string orderName; public decimal orderPrice; } public cla ...
- Matlab图像处理入门
1. Matlab基础 1.1 数据格式 Matlab默认的数据格式为双精度浮点数的矩阵或数组,同时支持其它数据类型.Matlab将单变量看作1´1的数组.Matlab支持的数据类型如下: 索 ...
- xpath基础知识
相关链接: http://www.ruanyifeng.com/blog/2009/07/xpath_path_expressions.html 自动生成xpath的工具: http://blog.s ...