fork(1) download
  1. #include <cstdio>
  2. using namespace std;
  3.  
  4. void shell_sort(int dataList[], int count);
  5.  
  6. int main() {
  7. // your code goes here
  8. int arr[10] = { 0, 2, 9, 8, 3, 1, 7, 5, 6, 4 };
  9. shell_sort(arr, 10);
  10. for(int i = 0; i < 10; i++) printf("%d ", arr[i]);
  11. return 0;
  12. }
  13.  
  14. void shell_sort(int dataList[], int count)
  15. {
  16. int k = 3, gap = dataList.Count / k;
  17. while (gap > 0)
  18. {
  19. for (int i = gap; i < count; i++)
  20. {
  21. int tmp = dataList[i];
  22. int j = i;
  23. while (j >= gap && dataList[j - gap] > tmp)
  24. {
  25. dataList[j] = dataList[j - gap];
  26. j -= gap;
  27. }
  28. dataList[j] = tmp;
  29. }
  30. gap /= k;
  31. }
  32. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘void shell_sort(int*, int)’:
prog.cpp:16:39: error: request for member ‘Count’ in ‘dataList’, which is of non-class type ‘int*’
             int k = 3, gap = dataList.Count / k;
                                       ^~~~~
stdout
Standard output is empty