Пример #1
0
int main(){
 	int *n;
 	n = (int *) malloc(2);
 	float a[MAX];
 	input_array(a,n);
	sort(a,0,*n-1);	
	MaxOutput(a,n);
	free(n);
	getch();
}
int main() {
	//end, start, CLOCKS_PER_SEC are integers
	//clock_t start, end;
	//start = clock();

	input_array(); 
	
	if (n > 100) {
		prepare();
		input_query();
	}
	else
		input_query2();

	//end = clock();
	//printf("The time was: %d seconds\n", (end - start) / (int)CLOCKS_PER_SEC);
	
	return 0;
}
Пример #3
0
int main()
{
	int *array;
	int total_count;
	
	printf("\t\t-------SELECTION SORTING-------\n");
	printf("Enter the numbers of elements to be added to array:");
	scanf("%d", &total_count);

    input_array(&array, total_count);

	printf("\nElements before sorting are:\n");
    display_array(array,total_count);

    selectionsort(array, total_count);

	printf("Elements after sorting are:\n");
    display_array(array,total_count);

	return 0;
}
Пример #4
0
int main(int argc, char *argv[])
{
	int length = Max-1, ret, input = 1, method = 1;
	double start, end;

	if(argc != 3)
	{
		usage();
		return 0;
	}
	else 
	{
		if(strcmp(argv[1], "-i"))
			input = 1;
		else
			input = 0;
			
		if(!strcmp(argv[2], "-1"))
			method = 1;
		else if(!strcmp(argv[2], "-2"))
			method = 2;
		else if(!strcmp(argv[2], "-3"))
			method = 3;
		else if(!strcmp(argv[2], "-4"))
			method = 4;
		else if(!strcmp(argv[2], "-5"))
			method = 5;
		else if(!strcmp(argv[2], "-6"))
			method = 6;
		else if(!strcmp(argv[2], "-7"))
			method = 7;
		else
			method = 1;	
	}

	if(input)
		rand_array(my_array, length);
	else
		input_array(my_array, &length);

	start = (double) nowTime;

	switch(method){
	case 1:
		printf("Insert sort:\n");
		insert_sort(my_array, length);	
		break;
	case 2:
		printf("bubble sort:\n");
		bubble_sort(my_array, length);
		break;
	case 3:
		printf("merge sort:\n");
		merge_sort(my_array, 0, length-1);
		break;
	case 4:
		printf("quick sort:\n");
		quick_sort(my_array, 0, length-1);
		break;
	case 5:
		printf("shell sort:\n");
		shell_sort(my_array, length);
		break;
	case 6:
		printf("heap sort:\n");
		heap_sort(my_array, length);
		break;
	case 7:
		printf("radix sort:\n");
		radix_sort(my_array, length);
		break;
	default:
		printf("quick sort:\n");
		quick_sort(my_array, 0, length-1);
	}

	end = (double) nowTime;
	printf("Sort Method spens %lfms\n", end - start);

	print_array(my_array, length);

	return 0;
}
Пример #5
0
void main()
{
    input_array();
    insert_sort();
    binari_search();
}