fork(7) download
  1.  
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. void ElimDuplicates( int array[], int n);
  6. //Pre Condition: receives a sorted array containing duplicates
  7. //Post Condition: eliminates duplicates from array and then returns array
  8.  
  9. int main()
  10. {
  11. const int SIZE = 10;
  12. int a[SIZE]={1, 1, 1, 2, 3, 3, 4, 6, 6, 7};
  13. cout << “Before removing duplicates, array contains:<< endl << a[SIZE];
  14. ElimDuplicates(a, SIZE);
  15. cout << endl<< "After removing duplicates, array contains: ” << endl << a[SIZE];
  16. return(0);
  17. }
  18.  
  19.  
  20. void ElimDuplicates(int array[], int n)
  21. {
  22. for ( int i = 0 ; i < n ; i++ )
  23. for ( int j = 0 ; j <=i ; j++ )
  24. if ( array [ j ] == array [ i ] )
  25. array[j]=0;
  26. }
  27.  
  28.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:13:2: error: stray '\342' in program
  cout << “Before removing duplicates, array contains: ” << endl << a[SIZE];
  ^
prog.cpp:13:2: error: stray '\200' in program
prog.cpp:13:2: error: stray '\234' in program
prog.cpp:13:2: error: stray '\342' in program
prog.cpp:13:2: error: stray '\200' in program
prog.cpp:13:2: error: stray '\235' in program
prog.cpp:15:17: warning: missing terminating " character
  cout << endl<< "After removing duplicates, array contains: ” << endl << a[SIZE]; 
                 ^
prog.cpp:15:2: error: missing terminating " character
  cout << endl<< "After removing duplicates, array contains: ” << endl << a[SIZE]; 
  ^
prog.cpp: In function 'int main()':
prog.cpp:13:13: error: 'Before' was not declared in this scope
  cout << “Before removing duplicates, array contains: ” << endl << a[SIZE];
             ^
prog.cpp:16:5: error: expected primary-expression before 'return'
     return(0);
     ^
stdout
Standard output is empty