皇室战争万圣节竞技场:c语言上机,但很久没用了,帮帮我。
来源:百度文库 编辑:中科新闻网 时间:2024/04/29 08:08:09
请帮我用c语言编写一个程序,非常感谢!我将追加分数。
#include <stdio.h>
struct info{
long no;
int zch;
struct info *next;
}info;
main(){
struct info *p,*student,*q,*tmp;
long xuehao;
int i;
p=(struct info*)malloc(sizeof(info));
p->no=0;
p->zch=60;
p->next=NULL;
student=p;
for(i=1;i<=10;i++){
q=(struct info*)malloc(sizeof(info));
q->no=i;
q->zch=i*10;
printf("-%d-",i);
q->next=NULL;
p->next=q;
p=p->next;
}
printf("\n");
scanf("%ld",&xuehao);
tmp=student;
i=0;
while(tmp){
if(tmp->next->no==xuehao){
tmp->next=tmp->next->next;
break;
}else{
if(xuehao>tmp->no&&(xuehao<tmp->next->no||tmp->next->next==NULL)){
q=(struct info*)malloc(sizeof(info));
q->no=xuehao;
q->zch=100;
q->next=tmp->next->next;
tmp->next->next=q;
break;
}
}
tmp=tmp->next;
}
while(student){
printf("%ld-",student->no);
student=student->next;
}
}