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

📄 wangxu.cpp

📁 数据结构的C++程序
💻 CPP
字号:
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include"wangxu.h"
using namespace std;
void main()
{
	int count;
	int array1[250],array2[250],array3[250],array4[250],array5[250];
	
START:	srand((unsigned)time(NULL));
		do
		{
			count=rand();
		}while(count<100||count>200);
		
		for(int i=1;i<=count;i++)
		{
			array1[i]=rand();
		}
		for(i=1;i<=count;i++)
		{
			
			array2[i]=array1[i]; 
			array3[i]=array1[i];
			array4[i]=array1[i];
			array5[i]=array1[i];
		}
		
		cout<<"排序前的数组为:"<<endl;
		for(i=1;i<=count;i++)
		{
			cout<<setiosflags(ios::left)<<setw(8)<<array1[i];
		}
		cout<<'\n'<<"数组元素的个数为"<<count<<"个。"<<endl;
		cout<<endl;
		
		
		BubbleSort(array1,count);
		cout<<endl;
		InsertSort(array2,count);
		cout<<endl;
		SelectSort(array3,count);
		cout<<endl;
		
		QuickSort(array4,0,count);
		
		QuickSortPrint(array4,count);
		cout<<endl;
		ShellSort(array5,count);
		cout<<endl;
		SelectSort(array5,count);
        
  HeapSort(array1, count);
SELECT:		cout<<"是否重新引入随机数组?请选择 Y or N :";
		char select;
		cin>>select;
	switch(select)
		{
	case 'Y':
	case 'y':
		goto START;
		break;
	case 'N':
	case 'n':
		break;
	default:
		cout<<"对不起,您的输入有误。"<<endl;
		goto SELECT;
		}
}



⌨️ 快捷键说明

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