老兵
hechuanbing
全部博文(39)
Ext(1)
web测试(1)
Ajax/Flex(0)
Javascript(1)
JSP/Servlet(1)
CSS/HTML(0)
Struts2(1)
Software(0)
Handware(0)
电影(0)
体育(0)
perl基础(0)
VB基础(0)
shell(2)
Linux基础(6)
基础知识(5)
机试(1)
数据库(4)
算法(4)
励志(1)
2014年(5)
2013年(1)
2012年(1)
2011年(12)
2010年(24)
Bsolar
b1170912
jiliwa
mr_zeng_
naihe001
hxb56
lexloo
jiefeij
逆光流浪
分类: C/C++
2011-05-31 11:47:06
#include "stdio.h"#include "stdlib.h"typedef struct number{ long key; char name; int count; struct number *next;}student;struct number *add(long k,struct number *head){ int flag=0; struct number *p=head; while(p!=NULL&&flag==0){ if(p->key==k){ flag=1; }else p=p->next; } if(flag==1){ p->count++; }else{ p=head; head=(struct number *)malloc(sizeof(struct number)); head->key=k; head->count=1; head->next=p; } return(head);}void list(struct number *head){ struct number *p=head; while(p!=NULL){ printf("%16ld %d\n",p->key,p->count); p=p->next; }}student *create(int n){ student *s=(student *)malloc(sizeof(student)); s->name='A'; student *head=s; int i; for(i='B';i<'A'+n;i++){ s=(s->next=(student *)malloc(sizeof(student))); s->name=i; s->next=NULL; } while(head){ printf("%s\t",head->name); head++; }}student *reverse(student *head,student *pre){ student *p=head->next; head->next=pre; if(p){ reverse(p,head); }else{ return head; }}main(){ struct number *a=NULL; long k;int i=0; //printf("Input a number:");//scanf("%ld\n",&k); //while(k>=0){ //if(k<0) break; //a=add(k,a); //scanf("%ld\n",&k);//} //list(a); student *head=create(6); reverse(head,NULL); return ;}
上一篇:shell删除日志文件
下一篇:字符串操作
登录 注册