#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include<dos.h>
#include<string.h>
#define LEN sizeof(struct student)
#define FORMAT "%-8d%-15s%-12.1lf%-12.1lf%-12.1lf%-12.1lfn"
#define DATA stu[i].num,stu[i].name,stu[i].elec,stu[i].expe,stu[i].requ,stu[i].sum
struct student
{ int num
char name[15]
double elec
double expe
double requ
double sum
}
struct student stu[50]
void in()
void show()
void order()
void del()
void modify()
void menu()
void insert()
void total()
void search()
void main()
{ int n
menu()
scanf("%d",&n)
while(n)
{ switch(n)
{ case 1: in()break
case 2: search()break
case 3: del()break
case 4: modify()break
case 5: insert()break
case 6: order()break
case 7: total()break
case 8: show()break
default:break
}
getch()
menu()
scanf("%d",&n)
}
}
void in()
{ int i,m=0
char ch[2]
FILE *fp
if((fp=fopen("data.txt","a+"))==NULL)
{
printf("can not openn")
return
}
while(!feof(fp))
{
if(fread(&stu[m] ,LEN,1,fp)==1)
m++
}
fclose(fp)
if(m==0)
printf("No record!n")
else
{
system("cls")
show()
}
if((fp=fopen("data.txt","wb"))==NULL)
{
printf("can not openn")
return
}
for(i=0i<mi++)
fwrite(&stu[i] ,LEN,1,fp)
printf("please input(y/n):")
scanf("%s",ch)
while(strcmp(ch,"Y")==0||strcmp(ch,"y")==0)
{
printf("number:")
scanf("%d",&stu[m].num)
for(i=0i<mi++)
if(stu[i].num==stu[m].num)
{
printf("the number is existing,press any to continue!")
getch()
fclose(fp)
return
}
printf("name:")
scanf("%s",stu[m].name)
printf("elective:")
scanf("%lf",&stu[m].elec)
printf("experiment:")
scanf("%lf",&stu[m].expe)
printf("required course:")
scanf("%lf",&stu[m].requ)
stu[m].sum=stu[m].elec+stu[m].expe+stu[m].requ
if(fwrite(&stu[m],LEN,1,fp)!=1)
{
printf("can not save!")
getch()
}
else
{
printf("%s saved!n",stu[m].name)
m++
}
printf("continue?(y/n):")
scanf("%s",ch)
}
fclose(fp)
printf("OK!n")
}
void show()
{ FILE *fp
int i,m=0
fp=fopen("data.txt","rb")
while(!feof(fp))
{
if(fread(&stu[m] ,LEN,1,fp)==1)
m++
}
fclose(fp)
printf("number name elective experiment required sumtn")
for(i=0i<mi++)
{
printf(FORMAT,DATA)
}
}
void menu()
{
system("cls")
printf("nnnnn")
printf("tt|---------------------STUDENT-------------------|n")
printf("tt|t 0. exit |n")
printf("tt|t 1. input record |n")
printf("tt|t 2. search record |n")
printf("tt|t 3. delete record |n")
printf("tt|t 4. modify record |n")
printf("tt|t 5. insert record |n")
printf("tt|t 6. order |n")
printf("tt|t 7. number |n")
printf("tt|t 8. show |n")
printf("tt|-----------------------------------------------|nn")
printf("tttchoose(0-8):")
}
void order()
{ FILE *fp
struct student t
int i=0,j=0,m=0
if((fp=fopen("data.txt","r+"))==NULL)
{
printf("can not open!n")
return
}
while(!feof(fp))
if(fread(&stu[m] ,LEN,1,fp)==1)
m++
fclose(fp)
if(m==0)
{
printf("no record!n")
return
}
if((fp=fopen("data.txt","wb"))==NULL)
{
printf("can not openn")
return}
for(i=0i<m-1i++)
for(j=i+1j<mj++)
if(stu[i].sum<stu[j].sum)
{ t=stu[i]stu[i]=stu[j]stu[j]=t}
if((fp=fopen("data.txt","wb"))==NULL)
{ printf("can not openn")return}
for(i=0i<mi++)
if(fwrite(&stu[i] ,LEN,1,fp)!=1)
{
printf("%s can not save!n")
getch()
}
fclose(fp)
printf("save successfullyn")
}
void del()
{FILE *fp
int snum,i,j,m=0
char ch[2]
if((fp=fopen("data.txt","r+"))==NULL)
{ printf("can not openn")return}
while(!feof(fp)) if(fread(&stu[m],LEN,1,fp)==1) m++
fclose(fp)
if(m==0)
{
printf("no record!n")
return
}
printf("please input the number:")
scanf("%d",&snum)
for(i=0i<mi++)
if(snum==stu[i].num)
break
printf("find the student,delete?(y/n)")
scanf("%s",ch)
if(strcmp(ch,"Y")==0||strcmp(ch,"y")==0)
for(j=ij<mj++)
stu[j]=stu[j+1]
m--
if((fp=fopen("data.txt","wb"))==NULL)
{ printf("can not openn")return}
for(j=0j<mj++)
if(fwrite(&stu[j] ,LEN,1,fp)!=1)
{ printf("can not save!n")
getch()}
fclose(fp)
printf("delete successfully!n")
}
void search()
{ FILE *fp
int snum,i,m=0
char ch[2]
if((fp=fopen("data.txt","rb"))==NULL)
{ printf("can not openn")return}
while(!feof(fp)) if(fread(&stu[m],LEN,1,fp)==1) m++
fclose(fp)
if(m==0) {printf("no record!n")return}
printf("please input the number:")
scanf("%d",&snum)
for(i=0i<mi++)
if(snum==stu[i].num)
{ printf("find the student,show?(y/n)")
scanf("%s",ch)
if(strcmp(ch,"Y")==0||strcmp(ch,"y")==0)
{
printf("number name elective experiment required sumtn")
printf(FORMAT,DATA)
break
}
}
if(i==m) printf("can not find the student!n")
}
void modify()
{ FILE *fp
int i,j,m=0,snum
if((fp=fopen("data.txt","r+"))==NULL)
{ printf("can not openn")return}
while(!feof(fp))
if(fread(&stu[m],LEN,1,fp)==1) m++
if(m==0) {printf("no record!n")
fclose(fp)
return
}
show()
printf("please input the number of the student which do you want to modify!n")
printf("modify number:")
scanf("%d",&snum)
for(i=0i<mi++)
if(snum==stu[i].num)
break
printf("find the student!you can modify!n")
printf("name:")
scanf("%s",stu[i].name)
printf("elective:")
scanf("%lf",&stu[i].elec)
printf("experiment:")
scanf("%lf",&stu[i].expe)
printf("required course:")
scanf("%lf",&stu[i].requ)
printf("modify successful!")
stu[i].sum=stu[i].elec+stu[i].expe+stu[i].requ
if((fp=fopen("data.txt","wb"))==NULL)
{ printf("can not openn")return}
for(j=0j<mj++)
if(fwrite(&stu[j] ,LEN,1,fp)!=1)
{ printf("can not save!") getch() }
fclose(fp)
}
void insert()
{ FILE *fp
int i,j,k,m=0,snum
if((fp=fopen("data.txt","r+"))==NULL)
{ printf("can not openn")return}
while(!feof(fp))
if(fread(&stu[m],LEN,1,fp)==1) m++
if(m==0) {printf("no record!n")
fclose(fp)
return
}
printf("please input position where do you want to insert!(input the number)n")
scanf("%d",&snum)
for(i=0i<mi++)
if(snum==stu[i].num)
break
for(j=m-1j>ij--)
stu[j+1]=stu[j]
printf("now please input the new information.n")
printf("number:")
scanf("%d",&stu[i+1].num)
for(k=0k<mk++)
if(stu[k].num==stu[i+1].num)
{
printf("the number is existing,press any to continue!")
getch()
fclose(fp)
return
}
printf("name:")
scanf("%s",stu[i+1].name)
printf("elective:")
scanf("%lf",&stu[i+1].elec)
printf("experiment:")
scanf("%lf",&stu[i+1].expe)
printf("required course:")
scanf("%lf",&stu[i+1].requ)
stu[i+1].sum=stu[i+1].elec+stu[i+1].expe+stu[i+1].requ
if((fp=fopen("data.txt","wb"))==NULL)
{ printf("can not openn")return}
for(k=0k<=mk++)
if(fwrite(&stu[k] ,LEN,1,fp)!=1)
{ printf("can not save!") getch() }
fclose(fp)
}
void total()
{ FILE *fp
int m=0
if((fp=fopen("data.txt","r+"))==NULL)
{ printf("can not openn")return}
while(!feof(fp))
if(fread(&stu[m],LEN,1,fp)==1)
m++
if(m==0) {printf("no record!n")fclose(fp)return}
printf("the class are %d students!n",m)
fclose(fp)
}
我去年做的
#include<time.h>
#include<stdio.h>
#include<conio.h>
#include <stdlib.h>
#define MAX 50
void input()
void sort()
void display()
void insert()
void del()
void average()
int now_no=0
struct student
{
int no
char name[20]
char sex[4]
float score1
float score2
float score3
float sort
float ave
float sum
}
struct student stu[MAX],*p
main()//主函数
{
char as
start: printf("ttt欢迎使用学生成绩管理系统nn")
//一下为功能选择模块
do{
printf("ntttt1.录入学员信息ntttt2.显示学员信息ntttt3.成绩排序信息ntttt4.添加学员信息ntttt5.删除学员信息ntttt6.退出n")
printf("tttt选择功能选项:")
as=getch()
switch(as)
{
case '1':
system("cls")
input()
break
case '2':
system("cls")
display()
break
case '3':
system("cls")
sort()
break
case '4':
system("cls")
insert()
break
case '5':
system("cls")
del()
break
case '6':
system("exit")
exit(0)
default:
system("cls")
goto start
}
}while(1)
//至此功能选择结束
}
void input()//原始数据录入模块
{
int i=0
char ch
do
{
printf("tttt1.录入学员信息n输入第%d个学员的信息n",i+1)
printf("n输入学生编号:")
scanf("%d",&stu[i].no)
fflush(stdin)
printf("n输入学员姓名:")
fflush(stdin)
gets(stu[i].name)
printf("n输入学员性别:")
fflush(stdin)
gets(stu[i].sex)
printf("n输入学员成绩:")
fflush(stdin)
scanf("%f",&stu[i].score1)
printf("n输入学员成绩:")
fflush(stdin)
scanf("%f",&stu[i].score2)
printf("n输入学员成绩:")
fflush(stdin)
scanf("%f",&stu[i].score3)
printf("nn")
i++
now_no=i
printf("%d",now_no)
printf("是否继续输入?(Y/N)")
ch=getch()
system("cls")
}
while(ch!='n')
system("cls")
}
void sort()//排序数据函数
{
struct student temp
int i,j
for(i=1i<now_noi++)
{
for(j=1j<=now_no-ij++)
{
if(stu[j-1].ave<stu[j].ave)
{temp=stu[j]
stu[j]=stu[j-1]
stu[j-1]=temp
}}}
}
void display()//显示数据函数
{
int i
char as
float ave
do
{
printf("tt班级学员信息列表n")
printf("t编号t姓名t性别t成绩t成绩t成绩t平均值n")
for(i=0i<now_noi++)
{
stu[i].sum=stu[i].score1+stu[i].score2+stu[i].score3
stu[i].ave=stu[i].sum/3
printf("t%dt%st%st%.2ft%.2ft%.2ft%.2fn",stu[i].no,stu[i].name,stu[i].sex,stu[i].score1,stu[i].score2,stu[i].score3,stu[i].ave)
}
printf("tt按任意键返回主菜单.")
as=getch()
goto exit
}
while(as!='n')
exit: system("cls")
}
void insert()//插入数据函数
{
char ch
do
{
printf("ntt输入新插入学员队信息n")
printf("n输入学生编号:")
scanf("%d",&stu[now_no].no)
fflush(stdin)
printf("n输入学员姓名:")
fflush(stdin)
gets(stu[now_no].name)
printf("n输入学员性别:")
fflush(stdin)
gets(stu[now_no].sex)
printf("n输入学员成绩:")
fflush(stdin)
scanf("%f",&stu[now_no].score1)
printf("n输入学员成绩:")
fflush(stdin)
scanf("%f",&stu[now_no].score2)
printf("n输入学员成绩:")
fflush(stdin)
scanf("%f",&stu[now_no].score3)
printf("nn")
now_no=now_no+1
sort()
printf("是否继续输入?(Y/N)")
ch=getch()
system("cls")
}
while(ch!='n')
}
void del()//删除数据函数
{
int inum,i,j
printf("输入要删除学员的编号:")
fflush(stdin)
scanf("%d",&inum)
for(i=0i<now_noi++)
{
if(stu[i].no==inum)
{
for(j=ij<now_noj++)
{
stu[i]=stu[i+1]
}
now_no=now_no-1
}
break
}
system("cls")
}
#include <stdio.h>
#include <string.h>
#include <windows.h>
struct student
{
long int num
char name[20]
int age
char sex[4]
char b[30]
char p[15]
}
int n=0
struct student stu[100]
struct student *p
void lr()
void ll()
void cx()
void xg()
void sc()
void main()
{
int z
printf("+---------------------------+n")
printf("| 欢迎使用学生信息管理系统 |n")
printf("+---------------------------+n")
printf("提示:为保证您的操作得到保存,请按正常顺序退出系统^_^n")
do
{
printf("nttt--------------------------------n")
printf("ttt+主菜单|n")
printf("ttt--------------------------------n")
printf("ttt+[1]----录入学生信息 |n")
printf("ttt+[2]----浏览学生信息 |n")
printf("ttt+[3]----查询学生信息 |n")
printf("ttt+[4]----删除学生信息 |n")
printf("ttt+[5]----修改学生信息 |n")
printf("ttt+[0]----退出系统 |n")
printf("ttt--------------------------------n")
printf("请输入您的选择:")
scanf("%d", &z)
system("color 2f")
switch(z)
{
case 0 :break
case 1 :lr()break
case 2 :ll()break
case 3 :cx()break
case 4 :sc()break
case 5 :xg()break
default:printf("n无效选项!")
}
}
while(z!= 0)
}
void lr()
{
int y
if(n==0)
p=stu
do
{
printf("--------------------n")
printf("请输入学生的学号:")
scanf("%ld",&p->num)
printf("请输入学生的姓名:")
scanf("%s",p->name)
printf("请输入学生的年龄:")
scanf("%d",&p->age)
printf("请输入学生的性别:")
scanf("%s",p->sex)
printf("请输入学生的地址:")
scanf("%s",p->b)
printf("请输入学生的电话:")
scanf("%s",p->p)
n++
p++
printf("n1.继续输入.n0.输入完毕.n")
printf("请选择:")
scanf("%d",&y)
}
while(y==1)
printf("提示:输入完毕!你一共输入%d个n",n)
}
void ll()
{
int i,j
if(n!=0)
{ printf("学生总数:%dn", n)
printf("学号t姓名t年龄t性别t地址tt电话n")
printf("-----------------------------------------------------n")
for(i=0i<ni++)
printf("%ldt%st%dt%st%stt%sn",stu[i].num,stu[i].name,stu[i].age,stu[i].sex,stu[i].b,stu[i].p)
}
else printf("提示:无学生数据,请输入数据!")
}
void cx()
{
int c
int w,i,j=0
char name[20]
if(n!=0)
{
do{printf("n")
printf("+--------------------+n")
printf("| 按学号查询 请按 1 |n")
printf("| 按姓名查询 请按 2 |n")
printf("| 取消请按 0 |n")
printf("+--------------------+n")
printf("请输入您的选择:")
scanf("%d", &c)
switch(c)
{
case 0:break
case 1:
printf("请输入学生的学号")
scanf("%ld", &w)
printf("n")
for(i=0i<ni++)
if(stu[i].num==w)
{
printf("n学号t姓名t年龄t性别t地址tt电话n")
printf("%ldt%st%dt%st%stt%sn",stu[i].num,stu[i].name,stu[i].age,stu[i].sex,stu[i].b,stu[i].p)
j=1
}
if(j==0)
printf("提示:没有该学生记录,请核对!")
break
case 2:
printf("请输入学生的姓名:")
scanf("%s", name)
printf("n")
for(i=0i<ni++)
if(strcmp(name,stu[i].name)==0)
{
printf("n学号t姓名t年龄t性别t地址tt电话n")
j=1
printf("%ldt%st%dt%st%stt%sn",stu[i].num,stu[i].name,stu[i].age,stu[i].sex,stu[i].b,stu[i].p)
}
if(j==0)
printf("提示:没有该学生记录,请核对!")
break
default:
printf("n提示:无效选项!")
break
}
}while(c!= 0)
}else printf("提示:无学生数据,请输入数据!")
return
}
void xg()
{
long int num
int i,j,c
if(n!=0)
{
printf("请输入您要修改的学生的学号:")
scanf("%ld", &num)
printf("n")
for(i=0i<ni++)
if(stu[i].num==num)
j=i
do{
printf("请选择您要修改的学生的信息内容:n")
printf("+----------------------+n")
printf("| 姓名 请按 1 |n")
printf("| 年龄 请按 2 |n")
printf("| 性别 请按 3 |n")
printf("| 学号 请按 4 |n")
printf("| 地址 请按 5 |n")
printf("| 电话 请按 6 |n")
printf("| 取消 请按 0 |n")
printf("+----------------------+n")
printf("请输入您的选择:")
scanf("%d", &c)
printf("n")
switch(c)
{
case 0:break
case 1:printf("请输入新姓名:")
scanf("%s",stu[j].name)
break
case 2:printf("请输入新年龄:")
scanf("%d",&stu[j].age)
break
case 3:printf("请输入新性别:")
scanf("%s",stu[j].sex)
break
case 4:printf("请输入新学号:")
scanf("%ld",&stu[j].num)
break
case 5:printf("请输入新地址:")
scanf("%s",stu[j].b)
break
case 6:printf("请输入新电话:")
scanf("%s",stu[j].p)
break
default:
printf("n无效选项!")
break
}
}while(c!= 0)
}else printf("提示:无学生数据,请输入数据!")
}
void sc()
{
long int num
int i,j,e
if(n!=0)
{
printf("学号t姓名t年龄t性别t地址tt电话n")
printf("-----------------------------------------------------n")
for(i=0i<ni++)
printf("%ldt%st%dt%st%stt%sn",stu[i].num,stu[i].name,stu[i].age,stu[i].sex,stu[i].b,stu[i].p)
printf("请输入您要删除的学生的学号:")
scanf("%ld", &num)
printf("n")
for(i=0i<ni++)
if(num==stu[i].num)
j=i
if(j!=(n-1))
{
for(e=i-1e<ne++,j++)
{
stu[j].num=stu[j+1].num
strcpy(stu[j].name,stu[j+1].name)
strcpy(stu[j].sex,stu[j+1].sex)
stu[j].age=stu[j+1].age
strcpy(stu[j].b,stu[j+1].b)
strcpy(stu[j].p,stu[j+1].p)
n--p--
}
}else {n--p--}
printf("提示:删除完毕!")
}elseprintf("提示:无学生数据,请输入数据!")
}
#include <stdio.h>
struct Student
{
int num
char name[20]
float score[3]
float avg
}stus[30]
void Add()//填加学员
void List()//学员详细列表
void Asc()//显示后三名学员
void Desc()//显示前三名学员
void Display()
void main()
{
int s
while(1)
{
printf("学员管理系统:n")
printf("1、增加学员n")
printf("2、学员详细列表n")
printf("3、显示前三名n")
printf("4、显示后三名n")
printf("5、显示平均成绩n")
printf("6、退出n")
printf("请选择:")
scanf("%d",&s)
switch(s)
{
case 1:
Add()
break
case 2:
List()
break
case 3:
Desc()
Display()
break
case 4:
Asc()
Display()
break
case 5:
Display()
break
case 6:
return
break
default:
printf("选择错误!n")
break
}
}
}
void Add()
{
int i,k
float sum
char c
for(i=0i<30i++)
{
printf("请输入第%d个学员信息:n",i+1)
printf("学号:")
scanf("%d",&stus[i].num)
printf("姓名:")
fflush(stdin)
scanf("%s",stus[i].name)
printf("请输入三门课的成绩:n")
sum=0
for(k=0k<3k++)
{
printf("%d:",k+1)
scanf("%f",&stus[i].score[k])
sum+=stus[i].score[k]
}
stus[i].avg=sum/3
printf("是否继续?")
fflush(stdin)
scanf("%c",&c)
if(c=='n' || c=='N')
return
}
}
void List()
{
int i,j=0
printf("学号t姓名t成绩1t成绩2t成绩3t平均n")
for(i=0i<30i++)
{
if(stus[i].num!=0)
{
printf("%dt%st%.2ft%.2ft%.2ft%.2fn",stus[i].num,stus[i].name,stus[i].score[0],stus[i].score[1],stus[i].score[2],stus[i].avg)
}
}
}
void Asc()
{
int i,j
struct Student c
for(i=0i<30i++)
{ for(j=0j<29-ij++)
if(stus[j].avg<stus[j+1].avg)
{
c=stus[j]
stus[j]=stus[j+1]
stus[j+1]=c
}
}
}
void Desc()
{
int i,j
struct Student c
for(i=0i<30i++)
{ for(j=0j<29-ij++)
if(stus[j].avg>stus[j+1].avg)
{
c=stus[j]
stus[j]=stus[j+1]
stus[j+1]=c
}
}
}
void Display()
{
int i,d=0
printf("学号t姓名t平均n")
for(i=0i<30i++)
{
if(stus[i].num!=0)
{
printf("%dt%st%.2fn",stus[i].num,stus[i].name,stus[i].avg)
d++
}
if(d==3)
break
}
}
看看我写的这个!
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include<dos.h>
#include<string.h>
#define LEN sizeof(struct student)
#define FORMAT "%-8d%-15s%-12.1lf%-12.1lf%-12.1lf%-12.1lfn"
#define DATA stu[i].num,stu[i].name,stu[i].elec,stu[i].expe,stu[i].requ,stu[i].sum
struct student
{ int num
char name[15]
double elec
double expe
double requ
double sum
}
struct student stu[50]
void in()
void show()
void order()
void del()
void modify()
void menu()
void insert()
void total()
void search()
void main()
{ int n
menu()
scanf("%d",&n)
while(n)
{ switch(n)
{ case 1: in()break
case 2: search()break
case 3: del()break
case 4: modify()break
case 5: insert()break
case 6: order()break
case 7: total()break
case 8: show()break
default:break
}
getch()
menu()
scanf("%d",&n)
}
}
void in()
{ int i,m=0
char ch[2]
FILE *fp
if((fp=fopen("data.txt","a+"))==NULL)
{
printf("can not openn")
return
}
while(!feof(fp))
{
if(fread(&stu[m] ,LEN,1,fp)==1)
m++
}
fclose(fp)
if(m==0)
printf("No record!n")
else
{
system("cls")
show()
}
if((fp=fopen("data.txt","wb"))==NULL)
{
printf("can not openn")
return
}
for(i=0i<mi++)
fwrite(&stu[i] ,LEN,1,fp)
printf("please input(y/n):")
scanf("%s",ch)
while(strcmp(ch,"Y")==0||strcmp(ch,"y")==0)
{
printf("number:")
scanf("%d",&stu[m].num)
for(i=0i<mi++)
if(stu[i].num==stu[m].num)
{
printf("the number is existing,press any to continue!")
getch()
fclose(fp)
return
}
printf("name:")
scanf("%s",stu[m].name)
printf("elective:")
scanf("%lf",&stu[m].elec)
printf("experiment:")
scanf("%lf",&stu[m].expe)
printf("required course:")
scanf("%lf",&stu[m].requ)
stu[m].sum=stu[m].elec+stu[m].expe+stu[m].requ
if(fwrite(&stu[m],LEN,1,fp)!=1)
{
printf("can not save!")
getch()
}
else
{
printf("%s saved!n",stu[m].name)
m++
}
printf("continue?(y/n):")
scanf("%s",ch)
}
fclose(fp)
printf("OK!n")
}
void show()
{ FILE *fp
int i,m=0
fp=fopen("data.txt","rb")
while(!feof(fp))
{
if(fread(&stu[m] ,LEN,1,fp)==1)
m++
}
fclose(fp)
printf("number name elective experiment required sumtn")
for(i=0i<mi++)
{
printf(FORMAT,DATA)
}
}
void menu()
{
system("cls")
printf("nnnnn")
printf("tt|---------------------STUDENT-------------------|n")
printf("tt|t 0. exit |n")
printf("tt|t 1. input record |n")
printf("tt|t 2. search record |n")
printf("tt|t 3. delete record |n")
printf("tt|t 4. modify record |n")
printf("tt|t 5. insert record |n")
printf("tt|t 6. order |n")
printf("tt|t 7. number |n")
printf("tt|t 8. show |n")
printf("tt|-----------------------------------------------|nn")
printf("tttchoose(0-8):")
}
void order()
{ FILE *fp
struct student t
int i=0,j=0,m=0
if((fp=fopen("data.txt","r+"))==NULL)
{
printf("can not open!n")
return
}
while(!feof(fp))
if(fread(&stu[m] ,LEN,1,fp)==1)
m++
fclose(fp)
if(m==0)
{
printf("no record!n")
return
}
if((fp=fopen("data.txt","wb"))==NULL)
{
printf("can not openn")
return}
for(i=0i<m-1i++)
for(j=i+1j<mj++)
if(stu[i].sum<stu[j].sum)
{ t=stu[i]stu[i]=stu[j]stu[j]=t}
if((fp=fopen("data.txt","wb"))==NULL)
{ printf("can not openn")return}
for(i=0i<mi++)
if(fwrite(&stu[i] ,LEN,1,fp)!=1)
{
printf("%s can not save!n")
getch()
}
fclose(fp)
printf("save successfullyn")
}
void del()
{FILE *fp
int snum,i,j,m=0
char ch[2]
if((fp=fopen("data.txt","r+"))==NULL)
{ printf("can not openn")return}
while(!feof(fp)) if(fread(&stu[m],LEN,1,fp)==1) m++
fclose(fp)
if(m==0)
{
printf("no record!n")
return
}
printf("please input the number:")
scanf("%d",&snum)
for(i=0i<mi++)
if(snum==stu[i].num)
break
printf("find the student,delete?(y/n)")
scanf("%s",ch)
if(strcmp(ch,"Y")==0||strcmp(ch,"y")==0)
for(j=ij<mj++)
stu[j]=stu[j+1]
m--
if((fp=fopen("data.txt","wb"))==NULL)
{ printf("can not openn")return}
for(j=0j<mj++)
if(fwrite(&stu[j] ,LEN,1,fp)!=1)
{ printf("can not save!n")
getch()}
fclose(fp)
printf("delete successfully!n")
}
void search()
{ FILE *fp
int snum,i,m=0
char ch[2]
if((fp=fopen("data.txt","rb"))==NULL)
{ printf("can not openn")return}
while(!feof(fp)) if(fread(&stu[m],LEN,1,fp)==1) m++
fclose(fp)
if(m==0) {printf("no record!n")return}
printf("please input the number:")
scanf("%d",&snum)
for(i=0i<mi++)
if(snum==stu[i].num)
{ printf("find the student,show?(y/n)")
scanf("%s",ch)
if(strcmp(ch,"Y")==0||strcmp(ch,"y")==0)
{
printf("number name elective experiment required sumtn")
printf(FORMAT,DATA)
break
}
}
if(i==m) printf("can not find the student!n")
}
void modify()
{ FILE *fp
int i,j,m=0,snum
if((fp=fopen("data.txt","r+"))==NULL)
{ printf("can not openn")return}
while(!feof(fp))
if(fread(&stu[m],LEN,1,fp)==1) m++
if(m==0) {printf("no record!n")
fclose(fp)
return
}
show()
printf("please input the number of the student which do you want to modify!n")
printf("modify number:")
scanf("%d",&snum)
for(i=0i<mi++)
if(snum==stu[i].num)
break
printf("find the student!you can modify!n")
printf("name:")
scanf("%s",stu[i].name)
printf("elective:")
scanf("%lf",&stu[i].elec)
printf("experiment:")
scanf("%lf",&stu[i].expe)
printf("required course:")
scanf("%lf",&stu[i].requ)
printf("modify successful!")
stu[i].sum=stu[i].elec+stu[i].expe+stu[i].requ
if((fp=fopen("data.txt","wb"))==NULL)
{ printf("can not openn")return}
for(j=0j<mj++)
if(fwrite(&stu[j] ,LEN,1,fp)!=1)
{ printf("can not save!")getch()}
fclose(fp)
}
void insert()
{ FILE *fp
int i,j,k,m=0,snum
if((fp=fopen("data.txt","r+"))==NULL)
{ printf("can not openn")return}
while(!feof(fp))
if(fread(&stu[m],LEN,1,fp)==1) m++
if(m==0) {printf("no record!n")
fclose(fp)
return
}
printf("please input position where do you want to insert!(input the number)n")
scanf("%d",&snum)
for(i=0i<mi++)
if(snum==stu[i].num)
break
for(j=m-1j>ij--)
stu[j+1]=stu[j]
printf("now please input the new information.n")
printf("number:")
scanf("%d",&stu[i+1].num)
for(k=0k<mk++)
if(stu[k].num==stu[i+1].num)
{
printf("the number is existing,press any to continue!")
getch()
fclose(fp)
return
}
printf("name:")
scanf("%s",stu[i+1].name)
printf("elective:")
scanf("%lf",&stu[i+1].elec)
printf("experiment:")
scanf("%lf",&stu[i+1].expe)
printf("required course:")
scanf("%lf",&stu[i+1].requ)
stu[i+1].sum=stu[i+1].elec+stu[i+1].expe+stu[i+1].requ
if((fp=fopen("data.txt","wb"))==NULL)
{ printf("can not openn")return}
for(k=0k<=mk++)
if(fwrite(&stu[k] ,LEN,1,fp)!=1)
{ printf("can not save!")getch()}
fclose(fp)
}
void total()
{ FILE *fp
int m=0
if((fp=fopen("data.txt","r+"))==NULL)
{ printf("can not openn")return}
while(!feof(fp))
if(fread(&stu[m],LEN,1,fp)==1)
m++
if(m==0) {printf("no record!n")fclose(fp)return}
printf("the class are %d students!n",m)
fclose(fp)
}
以上就是关于C语言编写一个教务管理系统 注:可以把这个程序也发我一下吗全部的内容,如果了解更多相关内容,可以关注,你们的支持是我们更新的动力!
版权声明:我们致力于保护作者版权,注重分享,被刊用文章【c教务管理系统程序设计】因无法核实真实出处,未能及时与作者取得联系,或有版权异议的,请联系管理员,我们会立即处理! 部分文章是来自自研大数据AI进行生成,内容摘自(百度百科,百度知道,头条百科,中国民法典,刑法,牛津词典,新华词典,汉语词典,国家院校,科普平台)等数据,内容仅供学习参考,不准确地方联系删除处理!;
工作时间:8:00-18:00
客服电话
电子邮件
beimuxi@protonmail.com
扫码二维码
获取最新动态