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; }

浙公网安备 33010602011771号