单链表的排序

来源:互联网 发布:手机直播平台系统源码 编辑:程序博客网 时间:2024/04/28 06:03
#include<iostream>#include<list>#include<string>#include<vector>using namespace std;template<class T>struct Node{T value;Node<T>* next;};template<class T>void sort(Node<T>* head){if(head==NULL) return;Node<T>* p,q;p = head;int len=0;while(p!=NULL){p=p->next;len++;}int i,j;for(i=0;i<len-1;i++){p = head;for(j=0;j<len-i-1;j++){if(p->value>p->next->value){T temp = p->value;p->value = p->next->value;p->next->value = temp;}p = p->next;}}}int main(){int a = 12;double q = static_cast<double>(a);printf("%f",q);}

原创粉丝点击