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

📄 exam2-7.cpp

📁 一个简单的数值计算程序所使用的数据是一些实数或整数
💻 CPP
字号:
#include <iostream.h>
#include <stdlib.h>

#include "LinList.h"

template <class T>
void LinListSort(LinList<T> &L)
{
	ListNode<T> *curr, *pre, *p, *q;
	p = L.head->next;
	L.head->next = NULL;

	while(p != NULL)
	{
		curr = L.head->next;
		pre = L.head;
		while(curr != NULL && curr->data <= p->data)
		{
			pre = curr;
			curr = curr->next;
		}
		q = p;
		p = p->next;
 		q->next = pre->next;
		pre->next = q;
	}
}

void main(void)
{
	LinList<int> myList;
   	int s[] = {1,3,9,11,8,6,22,16,15,10}, n = 10;
	int temp;

    for(int i = 0; i < n; i++) 	
		myList.Insert(s[i], i);

	cout << "排序前的数据元素:" << endl;
	for(i = 0; i < myList.ListSize(); i++)			
	{   
		temp = myList.GetData(i);
		cout << temp << "   ";
	}
		
	LinListSort(myList);

	cout  << endl << "排序后的数据元素:" << endl;
	for(i = 0; i < myList.ListSize(); i++)			
	{   
		temp = myList.GetData(i);
		cout << temp << "   ";
	}
		
}

⌨️ 快捷键说明

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