poj 3753(水题,指针的简单应用)

#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int main(){
    char s[260],t[20],*p,old;
    while(scanf("%s",s)==1){
        while(scanf("%s",t)&&strcmp(t,"END")!=0){
            if(strcmp(t,"NULL")==0){
                printf("0 NULL\n");
                continue;
            }
            p = strstr(s,t);
            if(p){
                old = *p;
                *p = '\0';
                if(p==s){
                    printf("0 NULL\n");
                }
                else{
                    printf("%d %s\n",strlen(s),s);
                }
                *p = old;
            }
            else{
                printf("%d %s\n",strlen(s),s);
            }
        }
    }
    return 0;
}

 

posted @ 2021-08-14 00:31  智人心  阅读(52)  评论(0)    收藏  举报