文章
1
粉丝
155
获赞
0
访问
10.8k
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
struct node
{
int element;
node *next;
};
int main() {
int x;
node *head = new node;
head->next = null;
node *r = head;
for (int i = 0; i < 5; i++)
{
scanf_s("%d", &x);
node *p = new node;
p->next=null;
p->element = x;
r->next = p;
r = p;
}
node *a = head->next; //指向第一个有数据的节点
node *b = a->next;
int i = 5;
while (i--)//冒泡排序
{
&nb...
登录后发布评论
冒泡排序里面的while死循环了,加一句b = b->next;