Source code for submission s1345

Go to diff to previous submission

bugs.cpp

  1. #include <iostream>
  2. #include <stdio.h>
  3. #include <string.h>
  4.  
  5.  
  6. using namespace std;
  7.  
  8. int main ( int argc, char * argv [] )
  9. {
  10. int linesCount;
  11. unsigned int equal;
  12. unsigned int j, k;
  13. string bug;
  14.  
  15.  
  16.  
  17. char *input = new char [2000000];
  18. bool finish = false;
  19. int z = 0;
  20.  
  21.  
  22. while ( cin >> linesCount >> bug ) {
  23.  
  24. z = 0;
  25. while( z < linesCount )
  26. {
  27. if ( z == 0 ) gets(input);
  28. gets(input);
  29.  
  30. for ( unsigned int i = 0; i < strlen( input ); i ++ ) {
  31.  
  32. if ( input[ i ] != bug[ 0 ] ) {
  33. cout << input[ i ];
  34. continue;
  35. }
  36.  
  37. equal = 0;
  38.  
  39. for ( j = 0; j < bug.length(); j ++ ) {
  40.  
  41. if ( i + j > strlen( input ) && j < bug.length() ){
  42. finish = true;
  43. break;
  44. }
  45.  
  46. if ( input[ i + j ] == bug[ j ] )
  47. equal ++;
  48.  
  49. }
  50.  
  51. if ( finish ) {
  52. for ( unsigned x = i; x < strlen( input ); x ++ )
  53. cout << input[ x ];
  54. }
  55.  
  56.  
  57. if ( equal == bug.length() ){
  58. i += bug.length() - 1;
  59. continue;
  60. }
  61.  
  62. for ( k = i; k < i + equal ; k ++ )
  63. cout << input[ k ];
  64. i = i + equal - 1;
  65.  
  66. }
  67. z++;}
  68. }
  69.  
  70.  
  71. delete [] input;
  72.  
  73. return 0;
  74. }
  75.  

Diff to submission s1325

bugs.cpp

--- c4.s1325.cteam003.bugs.cpp.0.bugs.cpp
+++ c4.s1345.cteam003.bugs.cpp.0.bugs.cpp
@@ -23,7 +23,7 @@
         
 z = 0;  
-while( z < linesCount + 1 )
+while( z < linesCount )
 {
-
+        if ( z == 0 )   gets(input);
         gets(input);