易截截图软件、单文件、免安装、纯绿色、仅160KB

求一个链表程序 c高手请进

单链表中各结点存放一个数,请按升序排列
谢谢 各位大虾

本人初学数据结构 希望大虾帮一下 入门

这个很简单的啊,你可以建立一个辅助链表,每次找链表中最小的数的节点插入到新链表中,自己尝试写下,不难的

遍历过去,冒泡就可以。

冒泡阿
初学都得会的

C/C++ code:

#include<stdio.h>

typedef struct node{
char data;
struct node *next;
}Link;

void
display(Link *h)
{
Link *t;
t=h->next;
while(t!=NULL)
{
printf("%d->",t->data);
t=t->next;
}
}
Link *
creat_link()
{
int run=1,v,i=1;
Link *h,*t,*s;
h=(Link *)malloc(sizeof(Link));
if(NULL==h)
exit(1);
t=h;
while(run)
{
printf("please input the %drd node vlaue:",i++);
scanf("%d",&v);
if(v!=-1) //输入-1表示链表结束
{
s=(Link*)malloc(sizeof(Link));
if(NULL==s)
exit(1);
s->data=v;
t->next=s;
t=s;
}
else
run=0;
}
t->next=NULL;

printf("before sort,the link is :");
display(h);
return h;
}

void
sort(Link *h)
{
Link *r,*p,*q;
if(h!=NULL)
{
p=h->next;
r=p->next;
p-


相关问答:

jsp中 <c:if test> 相关问题

在查询后将查询出来的值赋给各输入框
<c:if test="${not empty dataValue}">
      fm.SAMPLING_DATE.value=" <c:out value='${dataValue.SAMPLING_DATE}'/ ......

extern "C"问题

/*-----------c.h--------------*/
#ifndef _C_H_
#define _C_H_
extern "C" int add(int x, int y);
#endif

/*-----------c.c--------------*/
int add(int x, int y){
return ......

一个简单计算器c代码

大家帮我看看这个代码,有很多问题,不知道怎么改,小弟在此谢谢了。
#include <stdio.h>
#include <conio.h>
#include <ctype.h>

float date1,date2;
char op;

void ......

c打印一个N*N的方阵

打印一个N*N的方阵,N为每边字符的个数( 3〈N〈20 ),要求最外层为"X",第二层为"Y",从第三层起每层依次打印数字0,1,2,3,...
例子:当N =5,打印出下面的图形:
X X X X X
X ......

文件读写问题 c高手请进

下面是我的代码 从内存写入文件正确 但从文件读入内存都是乱码 而且程序崩溃 请c高手指点
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct inf
{
  & ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号