void main() { int i,n; clrscr(); puts("Please input total element number of the sequence:"); scanf("%d",&n); if(n<=0||n>MAX) { printf("n must more than 0 and less than %d.\n",MAX); exit(0); } puts("Please input the elements one by one:"); for(i=1;i<=n;i++) scanf("%d",&R[i]); puts("The sequence you input is:"); for(i=1;i<=n;i++) printf("%4d",R[i]); Shell_Sort(n); puts("\nThe sequence after shell_sort is:"); for(i=1;i<=n;i++) printf("%4d",R[i]); puts("\n Press any key to quit..."); getch(); }
int main ( int argc, char *argv[] ) { int i=0; int a[20]; int length=0; int temp[20]; int partion_index=0; int kth_element=0; printf("Input the element of Array(0 as input terminated):\n"); do { scanf("%d",&a[i]); }while(a[i++]!=0); printf("the array ready to sort:\n"); length=i-1; for(i=0;i<length;i++) printf("%d ",a[i]); printf("\n"); Shell_Sort(a,length); printf("\nthe array sorted:\n"); for(i=0;i<length;i++) printf("%d ",a[i]); printf("\n"); return EXIT_SUCCESS; } /* ---------- end of function main ---------- */
void main(void) { int a[ARR_NUM] = {37, 41, 19, 81, 41, 25, 56, 61, 49}, i; cout << "排序前(before sorting ):" << endl; for (i = 0; i < ARR_NUM; i++) { cout << " " << a[i]; } Shell_Sort(a, ARR_NUM); cout << endl << "排序後( after sorting ):" << endl; for (i = 0; i < ARR_NUM; i++) { cout << " " << a[i]; } cout << endl; }
int main(int argc, char* argv[]) { if(argc != 3) { printf("Incorrect arguments\n"); exit(EXIT_FAILURE); } clock_t io_start; clock_t io_end; clock_t io_time; clock_t sort_start; clock_t sort_end; clock_t sort_time; Node* list = NULL; io_start = clock(); list = Load_File(argv[1]); io_end = clock(); io_time = io_end - io_start; if(list == NULL) { exit(EXIT_FAILURE); } sort_start = clock(); Shell_Sort(list); sort_end = clock(); sort_time = sort_end - sort_start; io_start = clock(); Save_File(argv[2], list); io_end = clock(); io_time += (io_end - io_start); double iotime = (double) io_time / CLOCKS_PER_SEC; double sorttime = (double) sort_time / CLOCKS_PER_SEC; // Report printf("I/O time: %le\n", iotime); printf("Sorting time: %le\n", sorttime); return 0; }