⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sort.c

📁 学生成绩管理系统,C语言开发,图形界面,希望对大家有所帮助
💻 C
字号:
/*以下函数完成对学生成绩的排序,把链表重排。*/ 
#define sortX 250 
#define sortY 200 
#define dotred 0 
#define dotgreen 0 
#define dotblue 0 
#define sbkred 255 
#define sbkgreen 255 
#define sbkblue 255 
char *Sort="change.bmp"; 
void Putpixel4(int x,int y,char red,char green,char blue,int xor){ 
int i=3; 
for(i=3;i>1;i--) 
midcircle(x,y,i,red,green,blue,0); 
exputpixel(x,y,red,green,blue,xor); 
} 
void SortBigToSmall(char *s){ 
struct student *p,*bigp,*bigfore,*Cbigfore,*head; 
struct stdinfor *q,*bigq; 
int i=0,j=0; 
p=MainHead; 
q=p->stdhead; 
head=p; 
bigfore=p; 
Cbigfore=p; 
bigp=MainHead; 
bigq=bigp->stdhead; 
do 
{ 
if(strcmp(bigq->objectname,s)==0) 
break; 
else 
bigq=bigq->stdp; 
}while(q!=NULL); 
do 
{ 
do 
{ 
if(strcmp(q->objectname,s)==0) 
break; 
else 
q=q->stdp; 
}while(q!=NULL); 
if((q->degree)>(bigq->degree)) 
{ 
bigfore=Cbigfore; 
bigp=p; 
bigq=q; 
} 
Cbigfore=p; 
p=p->stup; 
q=p->stdhead; 
}while(p!=NULL); 
if(head==bigp); 
else 
{ 
bigfore->stup=bigp->stup; 
if(head==MainHead) 
{ 
bigp->stup=head; 
MainHead=bigp; 
head=bigp; 
} 
else 
{ 
bigp->stup=head->stup; 
head->stup=bigp; 
head=bigp; 
} 
} 
head=bigp; 
p=head->stup; 
q=p->stdhead; 
bigp=p; 
bigq=bigp->stdhead; 
bigfore=p; 
do 
{ 
do 
{ 
if(strcmp(bigq->objectname,s)==0) 
break; 
else 
bigq=bigq->stdp; 
}while(q!=NULL); 
do 
{ 
do 
{ 
if(strcmp(q->objectname,s)==0) 
break; 
else 
q=q->stdp; 
}while(q!=NULL); 
if((q->degree)>(bigq->degree)) 
{ 
bigfore=Cbigfore; 
bigp=p; 
bigq=q; 
} 
Cbigfore=p; 
p=p->stup; 
q=p->stdhead; 
}while(p!=NULL); 
if((head->stup!=bigp)) 
{ 
bigfore->stup=bigp->stup; 
bigp->stup=head->stup; 
head->stup=bigp; 
head=bigp; 
} 
head=bigp; 
p=head->stup; 
q=p->stdhead; 
bigp=p; 
bigq=bigp->stdhead; 
bigfore=p; 
}while((p->stup)!=NULL); 
} 
void SortSmallToBig(char *s){ 
struct student *p,*bigp,*bigfore,*Cbigfore,*head; 
struct stdinfor *q,*bigq; 
int i=0,j=0; 
p=MainHead; 
q=p->stdhead; 
head=p; 
bigfore=p; 
Cbigfore=p; 
bigp=MainHead; 
bigq=bigp->stdhead; 
do 
{ 
if(strcmp(bigq->objectname,s)==0) 
break; 
else 
bigq=bigq->stdp; 
}while(q!=NULL); 
do 
{ 
do 
{ 
if(strcmp(q->objectname,s)==0) 
break; 
else 
q=q->stdp; 
}while(q!=NULL); 
if((q->degree)<(bigq->degree)) 
{ 
bigfore=Cbigfore; 
bigp=p; 
bigq=q; 
} 
Cbigfore=p; 
p=p->stup; 
q=p->stdhead; 
}while(p!=NULL); 
if(head==bigp); 
else 
{ 
bigfore->stup=bigp->stup; 
if(head==MainHead) 
{ 
bigp->stup=head; 
MainHead=bigp; 
head=bigp; 
} 
else 
{ 
bigp->stup=head->stup; 
head->stup=bigp; 
head=bigp; 
} 
} 
head=bigp; 
p=head->stup; 
q=p->stdhead; 
bigp=p; 
bigq=bigp->stdhead; 
bigfore=p; 
do 
{ 
do 
{ 
if(strcmp(bigq->objectname,s)==0) 
break; 
else 
bigq=bigq->stdp; 
}while(q!=NULL); 
do 
{ 
do 
{ 
if(strcmp(q->objectname,s)==0) 
break; 
else 
q=q->stdp; 
}while(q!=NULL); 
if((q->degree)<(bigq->degree)) 
{ 
bigfore=Cbigfore; 
bigp=p; 
bigq=q; 
} 
Cbigfore=p; 
p=p->stup; 
q=p->stdhead; 
}while(p!=NULL); 
if((head->stup!=bigp)) 
{ 
bigfore->stup=bigp->stup; 
bigp->stup=head->stup; 
head->stup=bigp; 
head=bigp; 
} 
head=bigp; 
p=head->stup; 
q=p->stdhead; 
bigp=p; 
bigq=bigp->stdhead; 
bigfore=p; 
}while((p->stup)!=NULL); 
} 
void SortSumBtoS(void) 
{ 
struct student *p,*bigfore,*cbigfore,*big; 
struct student *head; 
p=MainHead; 
bigfore=cbigfore=big=head=p; 
do 
{ 
if((p->sum)>(big->sum)) 
{ 
bigfore=cbigfore; 
big=p; 
} 
cbigfore=p; 
p=p->stup; 
}while(p!=NULL); 
if(head!=big) 
{ 
bigfore->stup=big->stup; 
big->stup=head; 
MainHead=big; 
head=big; 
} 
p=head->stup; 
big=p; 
cbigfore=p; 
do 
{ 
printf("ok!"); 
do 
{ 

if((p->sum)>(big->sum)) 
{ 
bigfore=cbigfore; 
big=p; 
} 
cbigfore=p; 
p=p->stup; 
}while(p!=NULL); 
if(head->stup!=big) 
{ 
bigfore->stup=big->stup; 
big->stup=head->stup; 
head->stup=big; 
head=big; 
} 
else 
head=head->stup; 
p=head->stup; 
big=p; 
cbigfore=p; 
}while((p!=NULL)&amt;&amt;(p->stup!=NULL)); 
} 
void SortSumStoB(void) 
{ 
struct student *p,*bigfore,*cbigfore,*big; 
struct student *head; 
p=MainHead; 
bigfore=cbigfore=big=head=p; 
do 
{ 
if((p->sum)<(big->sum)) 
{ 
bigfore=cbigfore; 
big=p; 
} 
cbigfore=p; 
p=p->stup; 
}while(p!=NULL); 
if(head!=big) 
{ 
bigfore->stup=big->stup; 
big->stup=head; 
MainHead=big; 
head=big; 
} 
p=head->stup; 
big=p; 
cbigfore=p; 
do 
{ 

do 
{ 

if((p->sum)<(big->sum)) 
{ 
bigfore=cbigfore; 
big=p; 
} 
cbigfore=p; 
p=p->stup; 
}while(p!=NULL); 
if(head->stup!=big) 
{ 
bigfore->stup=big->stup; 
big->stup=head->stup; 
head->stup=big; 
head=big; 
} 
else 
head=head->stup; 
p=head->stup; 
big=p; 
cbigfore=p; 
}while((p!=NULL)&amt;&amt;(p->stup!=NULL)); 
} 
void SortStdnumberBtoS(void) 
{ 
struct student *p,*bigfore,*cbigfore,*big; 
struct student *head; 
p=MainHead; 
bigfore=cbigfore=big=head=p; 
do 
{ 
if((p->numint)>(big->numint)) 
{ 
bigfore=cbigfore; 
big=p; 
} 
cbigfore=p; 
p=p->stup; 
}while(p!=NULL); 
if(head!=big) 
{ 
bigfore->stup=big->stup; 
big->stup=head; 
MainHead=big; 
head=big; 
} 
p=head->stup; 
big=p; 
cbigfore=p; 
do 
{ 
do 
{ 

if((p->numint)>(big->numint)) 
{ 
bigfore=cbigfore; 
big=p; 
} 
cbigfore=p; 
p=p->stup; 
}while(p!=NULL); 
if(head->stup!=big) 
{ 
bigfore->stup=big->stup; 
big->stup=head->stup; 
head->stup=big; 
head=big; 
} 
else 
head=head->stup; 
p=head->stup; 
big=p; 
cbigfore=p; 
}while((p!=NULL)&amt;&amt;(p->stup!=NULL)); 
} 
void SortStdnumberStoB(void) 
{ 
struct student *p,*bigfore,*cbigfore,*big; 
struct student *head; 
p=MainHead; 
bigfore=cbigfore=big=head=p; 
do 
{ 
if((p->numint)<(big->numint)) 
{ 
bigfore=cbigfore; 
big=p; 
} 
cbigfore=p; 
p=p->stup; 
}while(p!=NULL); 
if(head!=big) 
{ 
bigfore->stup=big->stup; 
big->stup=head; 
MainHead=big; 
head=big; 
} 
p=head->stup; 
big=p; 
cbigfore=p; 
do 
{ 
do 
{ 

if((p->numint)<(big->numint)) 
{ 
bigfore=cbigfore; 
big=p; 
} 
cbigfore=p; 
p=p->stup; 
}while(p!=NULL); 
if(head->stup!=big) 
{ 
bigfore->stup=big->stup; 
big->stup=head->stup; 
head->stup=big; 
head=big; 
} 
else 
head=head->stup; 
p=head->stup; 
big=p; 
cbigfore=p; 
}while((p!=NULL)&amt;&amt;(p->stup!=NULL)); 
} 
void ShowSortBox(void){ 
int circle1k=0,circle2k=0,closek=0; 
char *s1="总分",*s2="学号"; 
showbmprealcolor32(Sort,sortX,sortY); 
showbmprealcolor32(close1,sortX+444,sortY+6); 
while(1) 
{ 
UpdateMouse(); 
/*以下为CLOSE按钮处理部分。*/ 
if(mouseinbox(sortX+444,sortX+464,sortY+6,sortY+26)==1&amt;&amt;closek==0) 
{ 
showbmprealcolor32(close2,sortX+444,sortY+6); 
closek=1; 
} 
if(mouseinbox(sortX+444,sortX+464,sortY+6,sortY+26)==0&amt;&amt;closek==1) 
{ 
showbmprealcolor32(close1,sortX+444,sortY+6); 
closek=0; 
} 
if(mouseinbox(sortX+444,sortX+464,sortY+6,sortY+26)==1) 
{ 
if(leftpress()==1) 
{ 
MouseOff(); 
return(0); 
} 
} 
/*以下为BOX框处理部分。*/ 
if(mouseinbox(sortX+66,sortX+181,sortY+95,sortY+127)==1) 
{ 
if(leftpress()==1) 
{ 
ShowReadKey(73,100,0); 
} 
} 
/*以下为CIRCLE1处理部分。*/ 
if(mouseinbox(sortX+237,sortX+256,sortY+76,sortY+95)==1&amt;&amt;circle1k==0&amt;&amt;circle2k==0) 
{ 
if(leftpress()==1) 
{ 
Putpixel4(sortX+247,sortY+86,dotred,dotgreen,dotblue,0); 
circle1k=1; 
while(leftpress()==1); 
if(strcmp(askedname,s1)==0) 
SortSumBtoS(); 
else if(strcmp(askedname,s2)==0) 
{ 
fill_numintc(); 
SortStdnumberBtoS(); 
} 
else 
SortBigToSmall(askedname); 
InitAskData(); 
return(0); 
} 
} 
if(mouseinbox(sortX+237,sortX+256,sortY+76,sortY+95)==1&amt;&amt;circle1k==1) 
{ 
if(leftpress()==1) 
{ 
Putpixel4(sortX+247,sortY+86,sbkred,sbkgreen,sbkblue,0); 
circle1k=0; 
while(leftpress()==1); 
} 
} 
/*以下为CIRCLE2处理部分。*/ 
if(mouseinbox(sortX+235,sortX+256,sortY+119,sortY+139)==1&amt;&amt;circle2k==0&amt;&amt;circle1k==0) 
{ 
if(leftpress()==1) 
{ 
Putpixel4(sortX+245,sortY+129,dotred,dotgreen,dotblue,0); 
circle2k=1; 
while(leftpress()==1); 
if(strcmp(askedname,s1)==0) 
SortSumStoB(); 
else if(strcmp(askedname,s2)==0) 
{ 
fill_numintc(); 
SortStdnumberStoB(); 
} 
else 
SortSmallToBig(askedname); 
InitAskData(); 
return(0); 
} 
} 
if(mouseinbox(sortX+235,sortX+256,sortY+119,sortY+139)==1&amt;&amt;circle2k==1) 
{ 
if(leftpress()==1) 
{ 
Putpixel4(sortX+245,sortY+129,sbkred,sbkgreen,sbkblue,0); 
circle2k=0; 
while(leftpress()==1); 
} 
} 
} 
} 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -