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

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - Jeff

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

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

#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");
     }
     }

}