Software Bugs Time Limit: 5000ms, Special Time Limit:12500ms, Memory Limit:65536KB Total submit users: 12, Accepted users: 9 Problem 11302 : No special judgement Problem description The biggest problem for all software developers are bugs. You definitely know the situation when a user calls to say ”I’ve found a bug in your program”. Once you have found and removed the bug, another one appears immediately. It is a hard and never-ending process.Recently, there appeared a promising open-source initiative called “bug-preprocessor”. The bugpreprocessor is a program able to find all bugs in your source code and mark them, so they are relatively easy to be removed. Your task is to write a program that will remove all marked bugs from the preprocessed source code. Input The input contains a text representing the preprocessed source code, an unspecified number of lines of text, some of them may be empty. Bugs are represented by a case-sensitive string “BUG”.The text is terminated by the end of file. No line in the input will be longer than 100 characters. Output Your program must remove all of the bugs from the input and print a text that does not contain any BUG strings. Nothing else than bugs may be removed, not even spaces. Sample Input print "No bugs here..." void hello() { BUGBUG printfBUG("Hello, world!\n"); } wriBUGBUGtelBUGn("Hello B-U-G"); Sample Output print "No bugs here..." void hello() { printf("Hello, world!\n"); } writeln("Hello B-U-G"); Problem Source Central Europe Regional Contest 2007 — Practice Session Submit Discuss Judge Status Problems Ranklist 很简单的一个题!但有一点点小的陷井! 可能在删除一个BUG后剩下的字符串又组成一个BUG #include<stdio.h>#include<string.h>int main(){ int len,flag; int i,j; char begin[120],end[120]; while(gets(begin)) { flag=1; len=strlen(begin); while(flag) { flag=0; for(i=0,j=0;i<len;i++) { if(i+2<len && begin[i]=='B' && begin[i+1]=='U' && begin[i+2]=='G') { i=i+2; flag=1; } else { end[j++]=begin[i]; } } end[j]='\0'; for(i=0;i<=j;i++) { begin[i]=end[i]; } len=j; } puts(end); } return 0;}

评论