⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 4.c

📁 数据结构练习共18道。
💻 C
字号:
#include <stdio.h>
#include <stdlib.h>

void main()
{
	int List[10];
	int i,j,times=0;
	for (i=1;i<=10;i++)
	{
		List[i]=rand();
		printf("%d ",List[i]);
	}
	for(i=2;i<=10;i++)
	{
	if(List[i]<List[i-1])
		{
			List[0]=List[i];		//复制哨兵
			List[i]=List[i-1];
			for(j=i-2;List[0]<List[j];--j)
			{List[j+1]=List[j];times++;}
			List[j+1]=List[0];
		}
	}
	printf("\nThe sorted list is:\n");
	for(i=1;i<11;i++)printf("%d ",List[i]);
	printf("\nThe compare times is:%d",times);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -