Exemplo n.º 1
0
/*************************************************
	Function: 		main
	Description: 	主函数
	Calls: 			scanf	printf
	Called By:		编译器
	Input: 			无
	Output: 		无
	Return: 		0
*************************************************/
int main(void)
{
	int len;
	int res;
	int pos = 0;
	int val = 1030;
	struArray StruArray;
	printf("input the array length\n");
	scanf("%d", &len);
	InitArr(&StruArray, len);
	
	//下列为测试程序
	AppendArr(&StruArray, 512);
	ShowArr(&StruArray);
	AppendArr(&StruArray, 999);
	ShowArr(&StruArray);
	AppendArr(&StruArray, 1111);
	ShowArr(&StruArray);
	AppendArr(&StruArray, val);
	ShowArr(&StruArray);
	AppendArr(&StruArray, 666);
	ShowArr(&StruArray);
	InsertArr(&StruArray, 10, 40);
	ShowArr(&StruArray);
	DeleteArr(&StruArray, 9);
	ShowArr(&StruArray);
	if (FindVal(&StruArray, val, &pos))
	{
		printf("%d:%d\n", val, pos);
	}
	if (Get(&StruArray, 8, &res))
	{
		printf("res:%d\n", res);
	}
	SortArr(&StruArray);
	ShowArr(&StruArray);
	if (FindVal(&StruArray, val, &pos))
	{
		printf("%d:%d\n", val, pos);
	}
	InverseArr(&StruArray);
	ShowArr(&StruArray);
	if (FindVal(&StruArray, val, &pos))
	{
		printf("%d:%d\n", val, pos);
	}
	DeleteAll(&StruArray);
	return 0;
}
Exemplo n.º 2
0
int	main()
{
	int	n;
	clock_t start,stop;

	initArr(arr,N);
	
	start=clock();
	SortArr	(arr);
	stop=clock();
	
	/*if((n=errors(arr,N)))
		printf("Se encontraron %d errores\n",n);
	else
		*/printf("%d elementos ordenados en %1.2f segundos\n",N,((float)stop-(float)start)/1000.0);
		
	Sleep(3000);
}