我的第一部作品
来源:互联网 发布:720云全景软件 编辑:程序博客网 时间:2024/05/16 18:31
#include<stdio.h>
#include<malloc.h>
#define LEN sizeof(struct student)
#include<stdlib.h>
struct student
...{long num;
char name[10];
float score;
struct student *next;
};
int n;
struct student *creat(void)
...{struct student *p,*q;
int i=0;
n=1;
q=(struct student *)malloc(LEN);
q->num=100;
q->next=NULL;
for(i=1;i<=5;i++)
...{p=(struct student *)malloc(LEN);
scanf("%ld,%s,%f",&p->num,p->name,&p->score);
p->next=q->next;
q->next=p;
n++;
}
return(q);
}
void print(struct student *q)
...{struct student *p;
printf("there are %d student in the list ,they are: ",n);
p=q;
if(q!=NULL)
do...{
printf("%ld%s%.2f ",p->num,p->name,p->score);
p=p->next;
}while(p!=NULL);
}
struct student *insert(struct student *q,int i)
...{struct student *p,*s;
int j=0;
p=q;
while(p&&j<(i-1)) ...{p=p->next;j++;}
if(!p||j>i-1) printf("wrong,input again");
else
...{ printf("input the student's message which you want to insert: ");
s=(struct student *)malloc(LEN);
scanf("%ld,%s,%f",&s->num,s->name,&s->score);
s->next=p->next;
p->next=s;
n=n+1;
}
return(p);
}
struct student *search(struct student *q,int i)
...{struct student *p;
int j=1;
p=q;
while(p&&j<i)
...{p=p->next;
j++;
}
if(!p||j>i)
printf("error!");
else
...{printf("the number of %d student's message are: ",i);
printf("%ld,%s,%.2f ",p->num,p->name,p->score);}
}
struct student *deleted(struct student *L,int i)
...{struct student *p,*q;
int j=0;
p=L;
while(p->next&&j<(i-1))
...{p=p->next;
j++;}
if(!(p->next)||j>(i-1)) printf("error!");
q=p->next;
p->next=q->next;
printf("the num of %ld studnet was deleted: ",q->num);
n=n-1;
}
int main()
...{struct student *head,*stu;
int i,j;
printf("************** ");
printf("************** ");
for(i=1;i<=4;i++)
...{
for(j=1;j<=4-i;j++)
printf(" ");
for(j=1;j<=(2*i-1);j++)
printf("*");
printf(" ");
}
for(i=4;i>=1;i--)
...{
for(j=1;j<=4-i;j++)
printf(" ");
for(j=1;j<=(2*i-1);j++)
printf("*");
printf(" ");
}
printf("************** ");
printf("************** ");
printf("input the student's message:num,name,score(end with 0,0,0) ");
head=creat();
print(head);
printf(" ");
printf(" 1-charu ");
printf(" 2-shanchu ");
printf(" 3-chazhao ");
printf(" 4-dayin ");
printf("input a number(1-4) to make a choose ");
scanf("%d",&i);
switch(i)
...{ case 1:printf("input before which studnet you want to insert: ");
scanf("%d",&i);
while(i)
...{head=insert(head,i);
print(head);
printf("input before which studnet you want to insert: ");
scanf("%d",&i);
} break;
case 2:printf("which number of the student do you want to deleted: ");
scanf("%d",&i);
while(i)
...{head=deleted(head,i);
print(head);
printf("which number of the stuent do you want to deleted: ");
scanf("%d",&i);
}
break;
case 3:printf("which number of the student do you want to search: ");
scanf("%d",&i);
while(i)
...{head=search(head,i);
print(head);
printf("which of the studnet do you want to search: ");
scanf("%d",&i);
} break;
case 4:print(head); break;
default :printf("the number you input are wrong: ");
}
system("pause");
return 0;
}
#include<malloc.h>
#define LEN sizeof(struct student)
#include<stdlib.h>
struct student
...{long num;
char name[10];
float score;
struct student *next;
};
int n;
struct student *creat(void)
...{struct student *p,*q;
int i=0;
n=1;
q=(struct student *)malloc(LEN);
q->num=100;
q->next=NULL;
for(i=1;i<=5;i++)
...{p=(struct student *)malloc(LEN);
scanf("%ld,%s,%f",&p->num,p->name,&p->score);
p->next=q->next;
q->next=p;
n++;
}
return(q);
}
void print(struct student *q)
...{struct student *p;
printf("there are %d student in the list ,they are: ",n);
p=q;
if(q!=NULL)
do...{
printf("%ld%s%.2f ",p->num,p->name,p->score);
p=p->next;
}while(p!=NULL);
}
struct student *insert(struct student *q,int i)
...{struct student *p,*s;
int j=0;
p=q;
while(p&&j<(i-1)) ...{p=p->next;j++;}
if(!p||j>i-1) printf("wrong,input again");
else
...{ printf("input the student's message which you want to insert: ");
s=(struct student *)malloc(LEN);
scanf("%ld,%s,%f",&s->num,s->name,&s->score);
s->next=p->next;
p->next=s;
n=n+1;
}
return(p);
}
struct student *search(struct student *q,int i)
...{struct student *p;
int j=1;
p=q;
while(p&&j<i)
...{p=p->next;
j++;
}
if(!p||j>i)
printf("error!");
else
...{printf("the number of %d student's message are: ",i);
printf("%ld,%s,%.2f ",p->num,p->name,p->score);}
}
struct student *deleted(struct student *L,int i)
...{struct student *p,*q;
int j=0;
p=L;
while(p->next&&j<(i-1))
...{p=p->next;
j++;}
if(!(p->next)||j>(i-1)) printf("error!");
q=p->next;
p->next=q->next;
printf("the num of %ld studnet was deleted: ",q->num);
n=n-1;
}
int main()
...{struct student *head,*stu;
int i,j;
printf("************** ");
printf("************** ");
for(i=1;i<=4;i++)
...{
for(j=1;j<=4-i;j++)
printf(" ");
for(j=1;j<=(2*i-1);j++)
printf("*");
printf(" ");
}
for(i=4;i>=1;i--)
...{
for(j=1;j<=4-i;j++)
printf(" ");
for(j=1;j<=(2*i-1);j++)
printf("*");
printf(" ");
}
printf("************** ");
printf("************** ");
printf("input the student's message:num,name,score(end with 0,0,0) ");
head=creat();
print(head);
printf(" ");
printf(" 1-charu ");
printf(" 2-shanchu ");
printf(" 3-chazhao ");
printf(" 4-dayin ");
printf("input a number(1-4) to make a choose ");
scanf("%d",&i);
switch(i)
...{ case 1:printf("input before which studnet you want to insert: ");
scanf("%d",&i);
while(i)
...{head=insert(head,i);
print(head);
printf("input before which studnet you want to insert: ");
scanf("%d",&i);
} break;
case 2:printf("which number of the student do you want to deleted: ");
scanf("%d",&i);
while(i)
...{head=deleted(head,i);
print(head);
printf("which number of the stuent do you want to deleted: ");
scanf("%d",&i);
}
break;
case 3:printf("which number of the student do you want to search: ");
scanf("%d",&i);
while(i)
...{head=search(head,i);
print(head);
printf("which of the studnet do you want to search: ");
scanf("%d",&i);
} break;
case 4:print(head); break;
default :printf("the number you input are wrong: ");
}
system("pause");
return 0;
}
- 我的第一部作品
- Adobe Premiere 5.1教程(1)我的第一部电影
- 我的第一部MFC编程视频教程终于上线了
- 我的网站作品
- 我的作品
- 我的以前作品
- 我的作品
- PIMS,我的作品
- 我的作品
- 我的作品
- 我的作品分享
- 我的素描作品
- 我的浮雕作品
- 我的新作品
- 我的作品截图
- 我的新作品~
- 我的作品
- 我的作品下载
- 鼠标事件
- 昨天我哭了。
- 熊猫烧香病毒文化(图:熊猫烧香QQ表情,网友PS图片)
- 网页中按钮 、超级链接的处理细节
- GNU Make 学习笔记(一)
- 我的第一部作品
- 如何合并相同单元格的数据
- 如何才能过快速了解成品软件的数据库结构
- 管理名言
- 大嘴的年会个人感觉
- 原生类型 和 参数化类型
- AV必修日语 [转]
- SAP做报表的三重境界(作者:lz_0509)
- c#2.0的新功能(一):泛型类