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

推荐订阅源

The Hacker News
The Hacker News
F
Full Disclosure
Cloudbric
Cloudbric
Blog — PlanetScale
Blog — PlanetScale
W
WeLiveSecurity
N
News and Events Feed by Topic
T
Troy Hunt's Blog
V2EX - 技术
V2EX - 技术
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
B
Blog
GbyAI
GbyAI
C
Check Point Blog
B
Blog RSS Feed
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Recorded Future
Recorded Future
The Last Watchdog
The Last Watchdog
N
News and Events Feed by Topic
T
The Blog of Author Tim Ferriss
O
OpenAI News
V
V2EX
人人都是产品经理
人人都是产品经理
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
IT之家
IT之家
WordPress大学
WordPress大学
www.infosecurity-magazine.com
www.infosecurity-magazine.com
S
Security @ Cisco Blogs
C
Cisco Blogs
Security Latest
Security Latest
S
Security Affairs
V
Visual Studio Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Hacker News - Newest:
Hacker News - Newest: "LLM"
博客园 - 司徒正美
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Microsoft Azure Blog
Microsoft Azure Blog
Last Week in AI
Last Week in AI
AWS News Blog
AWS News Blog
雷峰网
雷峰网
Apple Machine Learning Research
Apple Machine Learning Research
PCI Perspectives
PCI Perspectives
博客园_首页
U
Unit 42
Google DeepMind News
Google DeepMind News
Hugging Face - Blog
Hugging Face - Blog
Project Zero
Project Zero
Cisco Talos Blog
Cisco Talos Blog
The Register - Security
The Register - Security
N
Netflix TechBlog - Medium
L
LINUX DO - 热门话题
H
Hacker News: Front Page

博客园 - 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");
     }
     }

}