#include
#include
#include
typedef struct LinkNode
{
int data;
struct LinkNode *next;
}LinkNode;
void InitList(LinkNode *&L)
{
L=(LinkNode*)malloc(sizeof(LinkNode));
L->next=NULL;
}
void CreatList(LinkNode *&L,int a[],int n)
{
LinkNode *s;
L=(LinkNode*)malloc(sizeof(LinkNode));
L->next=NULL;
for(int i=0;idata=a[i];
s->next=L->next;
L->next=s;
}
}
void DisList(LinkNode *L)
{
LinkNode *p=L->next;
while(p!=NULL)
{
printf("\t%d",p->data);
p=p->next;
}
printf("\n");
}
bool panduan(LinkNode *L,int num)
{
int i=1;
LinkNode *p=L->next;
while(p!=NULL&&p->data!=num)
{
p=p->next;
i++;
}
if(p==NULL)
{
return false;
}
else
{
return true;
}
}
void sort(LinkNode *L,int num,bool dui)
{
LinkNode *p=L->next,*t=NULL,*h=NULL,*s=NULL;
L->next=NULL;
if(dui==true)
{
while(p)
{
t=p;
p=p->next;
t->next=NULL;
if(!L->next)
{
L->next=t;
}
else if (t->data>num)
{
h=L;
while(h->next)
{
h=h->next;
}
h->next=t;
}
else{
h=L->next;s=L;
while(h&&h->datas=h,h=h->next;
}
if(s==L)
{
t->next=L->next;
L->next=t;
}
else
{
t->next=s->next;
s->next=t;
}
}
}
DisList(L);
}
else{
printf("ERROR input");
}
}
int main()
{
int n,e[100];
int x;
LinkNode *L;
InitList(L);
scanf("%d",&n);
for(int i=0;i"%d",&e[i]);
}
scanf("%d",&x);
bool dui;
dui=panduan(L,x);
CreatList(L,e,n);
DisList(L);
sort(L,x,dui);
return 0;
}
这是题目:
(没错俺偷懒直接把作业报告改改(其实没怎么改)就发出来了)
(虽然说是小游戏,但不知为什么压缩后都超50MB了555)
首先上源码链接(内含食用方法)
发现用百度网盘发太费事了,所以直接传到github公开了,欢迎直接运行
GitHub - robin-bird-go/fake_piano_blocks: 钢琴块的低仿拉胯版
(以及总代码在链接里面,文中的基本上是半伪代码)
(先上个图镇楼,整了个简单gif)