题目链接:http://poj.org/problem?id=4054

本题的题意是在下面那部分待检验的单词中找到与之相对应的正确的代词,包含几种情况,一是全部字母相同,二是有一个字母不相同,三是多一个字母,四是少一个字母。

解本道题目:首先把错误的情况分为三种

1.字母数相同

2.待检验的单词的字母数比正确的单词的字母数多一

3.待检验的单词的字母数比正确的单词的字母数少一

然后注意一下细节;找到前面三种类型的单词,不要急着将单词输出,将这些单词保存在另外一个数组里面,如果遇到正确的单词,直接输出is correct,否则输出数组里面的字符串

代码如下:

 #include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
char dic[][],che[][];
char res[][];
char temp[];
int flag;
int num;
int main(){
int len1=,len2=;
bool flag;
while(){
cin>>dic[len1];
if(dic[len1][]=='#'){
break;
}
len1++;
}
while(){
cin>>che[len2];
if(che[len2][]=='#'){
break;
}
len2++;
}
for(int i=;i<len2;i++){
int len4=strlen(che[i]);
flag=;
num=;
for(int k=;k<;k++){
for(int j=;j<;j++){
res[k][j]='\0';
}
}
for(int j=;j<len1;j++){
int len3=strlen(dic[j]);
if(len3==len4){ //字符串长度相等的情况
if(strcmp(che[i],dic[j])==){
printf("%s is correct",dic[j]);
flag=;
break;
}
else{
int sum=;
for(int k=;k<len3;k++){
if(che[i][k]!=dic[j][k]){
sum++;
}
}
if(sum==){
strcpy(res[num],dic[j]);
num++;
}
}
}
else if(len3==len4+){ //字典里面的单词比待检验的单词的数量多一
for(int k=;k<len3;k++){
strcpy(temp,dic[j]);
for(int h=k;h<len3;h++){
temp[h]=temp[h+];
}
if(strcmp(temp,che[i])==){
strcpy(res[num],dic[j]);
num++;
break;
}
}
}
else if(len4==len3+){ //待检验的单词比字典里面的字母数多一
for(int k=;k<len4;k++){
strcpy(temp,che[i]);
for(int h=k;h<len4;h++){
temp[h]=temp[h+];
}
if(strcmp(temp,dic[j])==){
strcpy(res[num],dic[j]);
num++;
break;
}
}
}
}
if(flag==){
// cout<<num<<endl<<endl;
printf("%s: ",che[i]);
for(int j=;j<num;j++){
printf("%s ",res[j]);
// cout<<a++<<endl;
}
}
printf("\n");
}
return ;
}

poj 1035KINA Is Not Abbreviation的更多相关文章

  1. OpenJudge/Poj 2001 Shortest Prefixes

    1.链接地址: http://bailian.openjudge.cn/practice/2001 http://poj.org/problem?id=2001 2.题目: Shortest Pref ...

  2. poj 2001 Shortest Prefixes(特里)

    主题链接:http://poj.org/problem?id=2001 Description A prefix of a string is a substring starting at the ...

  3. POJ 2001 Shortest Prefixes (Trie)

    题目链接:POJ 2001 Description A prefix of a string is a substring starting at the beginning of the given ...

  4. POJ 3370. Halloween treats 抽屉原理 / 鸽巢原理

    Halloween treats Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 7644   Accepted: 2798 ...

  5. POJ 2356. Find a multiple 抽屉原理 / 鸽巢原理

    Find a multiple Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7192   Accepted: 3138   ...

  6. POJ 2965. The Pilots Brothers' refrigerator 枚举or爆搜or分治

    The Pilots Brothers' refrigerator Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 22286 ...

  7. POJ 1753. Flip Game 枚举or爆搜+位压缩,或者高斯消元法

    Flip Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 37427   Accepted: 16288 Descr ...

  8. POJ 3254. Corn Fields 状态压缩DP (入门级)

    Corn Fields Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 9806   Accepted: 5185 Descr ...

  9. POJ 2739. Sum of Consecutive Prime Numbers

    Sum of Consecutive Prime Numbers Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 20050 ...

随机推荐

  1. nginx服务部署 说明

    第1章 常用的软件 1.1 常用来提供静态服务的软件   Apache :这是中小型Web服务的主流,Web服务器中的老大哥,   Nginx :大型网站Web服务的主流,曾经Web服务器中的初生牛犊 ...

  2. java爬虫--jsoup简单的表单抓取案例

    分析需求: 某农产品网站的农产品价格抓取 网站链接:点击打开链接 页面展示如上: 标签展示如上: 分析发现每日价格行情包括了蔬菜,水果,肉等所有的信息,所以直接抓每日行情的内容就可以实现抓取全部数据. ...

  3. Fiddler手机抓包图文教程

    上篇Fiddler教程,我们教了大家Fiddler安装配置及如何使用Fiddler进行基本的Http抓包及模拟请求,今天给大家介绍下如何使用Fiddler进行手机抓包. 运行环境为Windows 10 ...

  4. webapp通用选择器:iosselect

    1,这个组件解决什么问题 在IOS系统中,safari浏览器的select标签默认展示样式和iOS-UIPickerView展示方式一致,形如下图: 这个选择器操作方便,样式优美.但是在安卓系统中展示 ...

  5. Virtual

    Virtual 作用: 允许在派生类中重新定义与基类同名函数并且可以通过其类的指针或引用来访问基类何派生类的同名函数. 1. 概述简单地说,每一个含有虚函数(无论是其本身的,还是继承而来的)的类都至少 ...

  6. Oracle Database 12c Release 2安装详解

    第1章 Oracle Database 12c Release 2安装详解 1.1 下载方法 oracle官网https://www.oracle.com 1)打开官方网站,找到下载连接 2)选择更多 ...

  7. 用C#操作IIS创建虚拟目录和网站

    #region CreateWebsite 添加网站 public string CreateWebSite(string serverID, string serverComment, string ...

  8. C#中简单的this与get的用法(string,decimal)

    代码 namespace First{publicpartialclass Form1 : Form{public Form1(){InitializeComponent();} privatevoi ...

  9. 从零开始搭建ELK+GPE监控预警系统

    前言 本文可能不会详细记录每一步实现的过程,但一定程度上可以引领小伙伴走向更开阔的视野,串联每个环节,呈现予你不一样的效果. 业务规模 8个平台 100+台服务器 10+个集群分组 微服务600+ 用 ...

  10. Builder模式的思考(Effective Java)

    <Effective Java>(第2版)中第二条中提到:遇到多个构造器参数时要考虑用构建器.在复习static关键字和内部类时回头看了一下,这才明白了为什么要用静态内部类来做处理,这里记 ...