题目链接: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. 刘强1109 JavaScript基础二(分支与循环结构)

    [if-else结构] 1.结构的写法: if(判断条件){ 条件为true时,执行if{} } else{ 条件为false时,执行else{} } 2.注意事项: ① else{}语句块,可以根据 ...

  2. 交换知识 VLAN VTP STP 单臂路由

    第1章 交换基础 1.1 园区网分层结构 层次 作用 出口层 广域网接入 出口策略 带宽控制 核心层 高速转发 服务器接入 路由选择 汇聚层 流量汇聚 链路冗余 设备冗余 路由选择 接入层 用户接入 ...

  3. 0_Simple__cppIntegration

    引用已经编好的 .cu 和 .cpp 代码来混合使用.在 main.cpp 中调用了使用GPU的 cppIntegration.cu (测试函数也在其中) 和使用CPU的 cppIntegration ...

  4. PHP静态化技术

    很多框架的模板引擎都有页面静态化的功能  目的是为了优化网站运行时间 静态化分两种  纯静态和伪静态 一. 纯静态 纯静态展示的是实实在在的静态页面 运行PHP程序 判断是否存在静态页 如果存在 展示 ...

  5. [转]彻底弄懂css中单位px和em,rem的区别

    难怪会问我 rem 和 em, 这俩或在移动端还是很有必要学习的. root em OK? 国内的设计师大都喜欢用px,而国外的网站大都喜欢用em和rem,那么三者有什么区别,又各自有什么优劣呢? P ...

  6. 一款超好用轻量级JS框架——Zepto.js(下)

       前   言 絮叨絮叨 前面和大家分享了Zepto的原型方法,相信大家也对这个框架有了一定的了解,那么今天再和大家分享一下它的对象方法吧! 1add() 支持一到二个参数,第一个为选择器,与$() ...

  7. Python-psutil模块

    psutil 1.简单介绍 psutil是一个跨平台库(http://code.google.com/p/psutil/),能够轻松实现获取系统运行的进程和系统利用率(包括CPU.内存.磁盘.网络等) ...

  8. 利用C#转换图片格式及转换为ico

    注意:转换为ICO后效果不好. 源代码: using System;using System.Collections.Generic;using System.Text;using System.Dr ...

  9. 实现验证码图像文字的识别(C#调用DLL)

    请先下载http://asprise.com/product/ocr/index.php?lang=csharp 的SDK.里面提供了详细的OCR方法,如下:   将发现图像框picbVeryfyCo ...

  10. MyBatis学习笔记1--初识MyBatis

    我也是初学者,写博客只是想把自己的整个思路整理一下,有不对或者不好的地方,请大家多多指正. 1.MyBatis简介 MyBatis 是一款优秀的持久层框架,它支持定制化 SQL.存储过程以及高级映射. ...