惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

The GitHub Blog
The GitHub Blog
Google Online Security Blog
Google Online Security Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
酷 壳 – CoolShell
酷 壳 – CoolShell
Y
Y Combinator Blog
L
LangChain Blog
博客园_首页
云风的 BLOG
云风的 BLOG
博客园 - 叶小钗
月光博客
月光博客
S
Schneier on Security
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
C
CXSECURITY Database RSS Feed - CXSecurity.com
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
D
DataBreaches.Net
Vercel News
Vercel News
P
Privacy International News Feed
D
Darknet – Hacking Tools, Hacker News & Cyber Security
C
Cyber Attacks, Cyber Crime and Cyber Security
J
Java Code Geeks
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
人人都是产品经理
人人都是产品经理
G
GRAHAM CLULEY
有赞技术团队
有赞技术团队
A
Arctic Wolf
I
InfoQ
T
Tor Project blog
Attack and Defense Labs
Attack and Defense Labs
Microsoft Security Blog
Microsoft Security Blog
博客园 - 司徒正美
K
Kaspersky official blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Recent Announcements
Recent Announcements
D
Docker
TaoSecurity Blog
TaoSecurity Blog
G
Google Developers Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
爱范儿
爱范儿
T
Troy Hunt's Blog
Help Net Security
Help Net Security
量子位
罗磊的独立博客
C
Cisco Blogs
Hacker News - Newest:
Hacker News - Newest: "LLM"
博客园 - 【当耐特】
腾讯CDC
Webroot Blog
Webroot Blog
N
News and Events Feed by Topic
小众软件
小众软件
N
Netflix TechBlog - Medium

博客园 - Jeff

4个月 C++ 有限状态机 POJ1019 POJ1007 POJ1005 ONLINE_JUDGE Linux shell定时器 怪异的grep结果 URL2FILE C primer笔记 Vxworks增加system call C语言常用宏定义技巧 分苹果 Socket 为什么选择SMP而不是AMP RTP memory in Vxworks Windriver的项目类型 RTP affinity Symmetric multiprocessing (SMP)
POJ1035
Jeff · 2012-01-16 · via 博客园 - Jeff

2012-01-16 10:29  Jeff  阅读(567)  评论()    收藏  举报

#include "stdio.h"

struct thedic{
     char wordname[17];
     int thelen;
    }thedic_p[10010];
int i =0;
int p =0;
int x=0;
int correct =0;
int j,count,len,mywordlen,totalnumber;
char myword[17];
char * tempword;
char* tempmyword;
char wordtopass[17];

//Replace one character
void replace(const char * wordpro,const char * dicword){
         int count =0;
         tempword = dicword;
         tempmyword = wordpro;
         for(j=0;j<strlen(tempword);j++){
             if(tempmyword[j] != tempword[j])count++;
             if(count > 1)return;
         }
         printf(" %s",tempword);
    }

//Add one character to myword
void add(const char * wordpro,const char *dicword){
         tempword = dicword;
         tempmyword = wordpro;
         for(j=0;j<=strlen(tempword);j++){
             if(tempmyword[j] != tempword[j]){
                len = strlen(tempmyword);
                while(len-- > j){
                      tempmyword[len+1]=tempmyword[len];
                }
                tempmyword[j] = tempword[j];
                if(!strcmp(tempmyword,tempword)){
                  printf(" %s",tempword);
                }
                return;
             }
        }
        return;
    }

//Delete one character from myword
void deleteone(const char * wordpro,const char * dicword){
        tempword = dicword;
        tempmyword = wordpro;

         for(j=0;j<strlen(tempmyword);j++){
             if(tempmyword[j] != tempword[j]){
                len = strlen(tempmyword);
                if(j <(len-1)){
                while(j++ < (len-1)){
                      tempmyword[j-1]=tempmyword[j];
                      tempmyword[j] ='';
                }
                }
                else if(j== (len-1)){
                      tempmyword[j] =' ';
                }

                if(!strcmp(tempmyword,tempword)){
                  printf(" %s",tempword);
                }
                return;
             }
        }
        return;
    }

int main(void) {
    #ifndef ONLINE_JUDGE
    freopen("in.txt","r",stdin);
    #else
    #endif
    while(scanf("%s",thedic_p[i++].wordname)){
          if(!strcmp(thedic_p[i-1].wordname,"#")){
          totalnumber = i-1;
          break;
          }
          thedic_p[i-1].thelen= strlen(thedic_p[i-1].wordname);
    }

     for(;;){

        for(i=0;i<17;i++){
            myword[i]=' ';
            wordtopass[i]=' ';
        }

        correct=0;
        scanf("%s",myword);
        if(!strcmp(myword,"#"))break;
        mywordlen=strlen(myword);

        for(p=0;p<totalnumber;p++){
            //printf("")
            if(!strcmp(myword,thedic_p[p].wordname)){
            printf("%s is correctn",myword);
            correct=1;
            break;
            }
        }
        if(correct != 1){
        printf("%s:",myword);
        for(p=0;p<totalnumber;p++){ 
            strcpy(wordtopass,myword);
            if(abs(mywordlen-thedic_p[p].thelen)>1)continue;
            if(mywordlen==thedic_p[p].thelen)
               replace(wordtopass,thedic_p[p].wordname);
            if(mywordlen > thedic_p[p].thelen)
               deleteone(wordtopass,thedic_p[p].wordname);
            else
               add(wordtopass,thedic_p[p].wordname);
        }
        printf("n");
     }
     }

}