需要c语言一个学生信息管理系统的项目需求案例!!!都包括啥??

2024-12-03 12:54:40
推荐回答(4个)
回答1:

#include "stdio.h"
#define SIZE 50
int sum=0;
static char *str[]=;
struct student
{ int n;
long num;
char name[10];
int age;
char addr[10];
int score[3];
float avr;
} stu[SIZE];
/* 1--Input */
void fin()
{ int i,j,s;char f;
FILE *fp;
printf(" Warring! Input? ( y/n ) : \7\7\7");
f=getchar();f=getchar();
if(f!='y')
return;
fp=fopen("fstu","wb");
for(i=0;i { printf(" i=%d Input No. (i=-1,return) i=? ",i+1);
scanf("%d",&j);
if (j==-1)
{ printf("\n * * * Press any key return! * * *\n",j);
fclose(fp);getch();return;
}
else
{ printf(" Input num,name,age,addr : ");
stu[i].n=i+1;
scanf("%ld%s%d%s",&stu[i].num,stu[i].name,&stu[i].age,stu[i].addr);
s=0;
for(j=0;j<3;j++)
{ printf(" Input %-7s score : ",str[j]);
scanf("%d",&stu[i].score[j]);
if(stu[i].score[j]>100)

s+=stu[i].score[j];
}
stu[i].avr=s/3.0;
fwrite(&stu[i],sizeof(struct student),1,fp);
}
}
fclose(fp);
}
/* 2--Find */
void ffind()
{ int i,j;
FILE *fp;
fp=fopen("fstu","rb");
for(i=0;fread(&stu[i],sizeof(struct student),1,fp)!=0;i++);
sum=i;
rewind(fp);
printf(" * * * Find student data * * *\n");
printf(" Input n=1 -- %d : ",sum);
scanf("%d",&j);
fseek(fp,(j-1)*sizeof(struct student),0);
printf("\n Display student %d data : \n",j);
printf(" * * * * * * * * * * * * * * * * * * * * * * * * * * *\n");
printf(" No. Num Name Age Addr C Math En. Aver.\n");
printf(" -----------------------------------------------------\n");
fread(&stu[i],sizeof(struct student),1,fp);
printf("%12d%7ld %-10s%2d %-10s",stu[i].n,stu[i].num,stu[i].name,stu[i].age,stu[i].addr);
printf("%3d %3d %3d %6.2f\n",stu[i].score[0],stu[i].score[1],stu[i].score[2],stu[i].avr);
fclose(fp);
printf(" * * * * * * * * * * * * * * * * * * * * * * * * * * *\n\n");
printf("\n\n");getch();
}
/* 3--Change */
void fchan()
{ int i,j,s,m;char ch;
FILE *fp;
for(;;)
{
fp=fopen("fstu","rb+");
for(i=0;fread(&stu[i],sizeof(struct student),1,fp)!=0;i++);
sum=i;
printf(" * * * Change student data * * *\n");
printf(" Input n=1 -- %d : ",sum);
scanf("%d",&j);
m=j-1;
fseek(fp,m*sizeof(struct student),0);
printf("\n Display student %d data : \n",j);
printf(" * * * * * * * * * * * * * * * * * * * * * * * * * * *\n");
printf(" No. Num Name Age Addr C Math En. Aver.\n");
printf(" -----------------------------------------------------\n");
fread(&stu[i],sizeof(struct student),1,fp);
printf("%12d%7ld %-10s%2d %-10s",stu[i].n,stu[i].num,stu[i].name,stu[i].age,stu[i].addr);
printf("%3d %3d %3d %6.2f\n",stu[i].score[0],stu[i].score[1],stu[i].score[2],stu[i].avr);
fclose(fp);
printf(" * * * * * * * * * * * * * * * * * * * * * * * * * * *\n\n");
fclose(fp);printf("\n\n");getch();
fp=fopen("fstu","rb+");
for(i=0;fread(&stu[i],sizeof(struct student),1,fp)!=0;i++);
sum=i;
printf(" * * * Change student %d data * * *\n",j);
fseek(fp,m*sizeof(struct student),0);
printf(" i=%d Input No. (i=-1,return) i=? ",j);
scanf("%d",&j);
if (j==-1)
{ printf("\n * * * Press any key return! * * *\n",j);
fclose(fp);getch();return;
}
else
{ printf(" Input num,name,age,addr : ");
stu[i].n=j;
scanf("%ld%s%d%s",&stu[i].num,stu[i].name,&stu[i].age,stu[i].addr);
s=0;
for(j=0;j<3;j++)
{ printf(" Input %-7s score : ",str[j]);
scanf("%d",&stu[i].score[j]);
if(stu[i].score[j]>100)

s+=stu[i].score[j];
}
}
stu[i].avr=s/3.0;
rewind(fp);
fseek(fp,m*sizeof(struct student),0);
fwrite(&stu[i],sizeof(struct student),1,fp);
fclose(fp);
printf("\n * * * Continue ( y/n ) ? * * *\n",j);
ch=getchar();
if(ch!='y')
return;
}
}
/* 4--Append */
void fappe()
{ int i,j,s;
FILE *fp;
fp=fopen("fstu","ab+");
for(i=0;fread(&stu[i],sizeof(struct student),1,fp)!=0;i++);
sum=i;
rewind(fp);
printf(" List student datas : \n\n");
printf(" * * * * * * * * * * * * * * * * * * * * * * * * * * *\n");
printf(" No. Num Name Age Addr C Math En. Aver.\n");
printf(" -----------------------------------------------------\n");
for(i=0;fread(&stu[i],sizeof(struct student),1,fp)!=0;i++)
{ printf("%12d%7ld %-10s%2d %-10s",stu[i].n,stu[i].num,stu[i].name,stu[i].age,stu[i].addr);
printf("%3d %3d %3d %6.2f\n",stu[i].score[0],stu[i].score[1],stu[i].score[2],stu[i].avr);
}
printf(" * * * * * * * * * * * * * * * * * * * * * * * * * * *\n\n");
getch();
sum=i;
for(i=sum;i { printf(" i=%d Input No. (i=-1,return) i=? ",i+1);
scanf("%d",&j);
if (j==-1)
{ printf("\n * * * Press any key return! * * *\n",j);
fclose(fp);getch();return;
}
else
{ printf(" Input num,name,age,addr : ");
stu[i].n=i+1;
scanf("%ld%s%d%s",&stu[i].num,stu[i].name,&stu[i].age,stu[i].addr);
s=0;
for(j=0;j<3;j++)
{ printf(" Input %-7s score : ",str[j]);
scanf("%d",&stu[i].score[j]);
if(stu[i].score[j]>100)

s+=stu[i].score[j];
}
stu[i].avr=s/3.0;
fwrite(&stu[i],sizeof(struct student),1,fp);
}
}
fclose(fp);
}
/* 5--List */
void flist()
{ int i;
FILE *fp;
fp=fopen("fstu","rb");
for(i=0;fread(&stu[i],sizeof(struct student),1,fp)!=0;i++);
sum=i;
rewind(fp);
printf(" List student datas : \n\n");
printf(" * * * * * * * * * * * * * * * * * * * * * * * * * * *\n");
printf(" No. Num Name Age Addr C Math En. Aver.\n");
printf(" -----------------------------------------------------\n");
for(i=0;fread(&stu[i],sizeof(struct student),1,fp)!=0;i++)
{ printf("%12d%7ld %-10s%2d %-10s",stu[i].n,stu[i].num,stu[i].name,stu[i].age,stu[i].addr);
printf("%3d %3d %3d %6.2f\n",stu[i].score[0],stu[i].score[1],stu[i].score[2],stu[i].avr);
}
fclose(fp);
printf(" * * * * * * * * * * * * * * * * * * * * * * * * * * *\n\n");
getch();
}
/* 6--Sort */
void fsort()
{ int i,j,n;
FILE *fp;
struct student t;
fp=fopen("fstu","rb");
printf(" List fstu file data : \n");
printf(" * * * * * * * * * * * * * * * * * * * * * * * * * * *\n");
printf(" No. Num Name Age Addr C Math En. Aver.\n");
printf(" -----------------------------------------------------\n");
for(i=0;fread(&stu[i],sizeof(struct student),1,fp)!=0;i++)
{ printf("%12d%7ld %-10s%2d %-10s",stu[i].n,stu[i].num,stu[i].name,stu[i].age,stu[i].addr);
printf("%3d %3d %3d %6.2f\n",stu[i].score[0],stu[i].score[1],stu[i].score[2],stu[i].avr);
}
printf(" * * * * * * * * * * * * * * * * * * * * * * * * * * *\n\n");
getch();
n=i;
for(i=0;i for(j=i+1;j if(stu[i].avr { t=stu[i];
stu[i]=stu[j];
stu[j]=t;
}
fp=fopen("fstus","wb");
printf(" List sort fstus file data : \n");
printf(" * * * * * * * * * * * * * * * * * * * * * * * * * * *\n");
printf(" No. Num Name Age Addr C Math En. Aver.\n");
printf(" -----------------------------------------------------\n");
for(i=0;i { fwrite(&stu[i],sizeof(struct student),1,fp);
printf("%12d%7ld %-10s%2d %-10s",stu[i].n,stu[i].num,stu[i].name,stu[i].age,stu[i].addr);
printf("%3d %3d %3d %6.2f\n",stu[i].score[0],stu[i].score[1],stu[i].score[2],stu[i].avr);
}
printf(" * * * * * * * * * * * * * * * * * * * * * * * * * * *\n\n");
printf("\n");getch();
for(i=0;fread(&stu[i],sizeof(struct student),1,fp)!=0;i++)
fwrite(&stu[i],sizeof(struct student),1,fp);
fclose(fp);
}
/* 7--Copy */
void fcopy()
{ int i;
FILE *fp1,*fp2;
fp1=fopen("fstu","rb");
fp2=fopen("fstub","wb");
printf(" List fstu file data : \n");
printf(" * * * * * * * * * * * * * * * * * * * * * * * * * * *\n");
printf(" No. Num Name Age Addr C Math En. Aver.\n");
printf(" -----------------------------------------------------\n");
for(i=0;fread(&stu[i],sizeof(struct student),1,fp1)!=0;i++)
{ printf("%12d%7ld %-10s%2d %-10s",stu[i].n,stu[i].num,stu[i].name,stu[i].age,stu[i].addr);
printf("%3d %3d %3d %6.2f\n",stu[i].score[0],stu[i].score[1],stu[i].score[2],stu[i].avr);
fwrite(&stu[i],sizeof(struct student),1,fp2);
}
fclose(fp2);
printf(" * * * * * * * * * * * * * * * * * * * * * * * * * * *\n\n");
printf("\n");getch();
for(i=0;fread(&stu[i],sizeof(struct student),1,fp1)!=0;i++)
fwrite(&stu[i],sizeof(struct student),1,fp2);
fclose(fp1);
fclose(fp2);
fp2=fopen("fstub","rb");
printf(" List backup fstub file data : \n");
printf(" * * * * * * * * * * * * * * * * * * * * * * * * * * *\n");
printf(" No. Num Name Age Addr C Math En. Aver.\n");
printf(" -----------------------------------------------------\n");
for(i=0;fread(&stu[i],sizeof(struct student),1,fp2)!=0;i++)
{ printf("%12d%7ld %-10s%2d %-10s",stu[i].n,stu[i].num,stu[i].name,stu[i].age,stu[i].addr);
printf("%3d %3d %3d %6.2f\n",stu[i].score[0],stu[i].score[1],stu[i].score[2],stu[i].avr);
}
fclose(fp2);
printf(" * * * * * * * * * * * * * * * * * * * * * * * * * * *\n\n");
getch();printf("\n");
}
/* 8--Restore */
void frest()
{ int i;
FILE *fp1,*fp2;
fp1=fopen("fstub","rb");
fp2=fopen("fstu","wb");
printf(" List backup fstub file data : \n");
printf(" * * * * * * * * * * * * * * * * * * * * * * * * * * *\n");
printf(" No. Num Name Age Addr C Math En. Aver.\n");
printf(" -----------------------------------------------------\n");
for(i=0;fread(&stu[i],sizeof(struct student),1,fp1)!=0;i++)
{ printf("%12d%7ld %-10s%2d %-10s",stu[i].n,stu[i].num,stu[i].name,stu[i].age,stu[i].addr);
printf("%3d %3d %3d %6.2f\n",stu[i].score[0],stu[i].score[1],stu[i].score[2],stu[i].avr);
fwrite(&stu[i],sizeof(struct student),1,fp2);
}
fclose(fp1);
printf(" * * * * * * * * * * * * * * * * * * * * * * * * * * *\n\n");
printf("\n");getch();
for(i=0;fread(&stu[i],sizeof(struct student),1,fp1)!=0;i++)
fwrite(&stu[i],sizeof(struct student),1,fp2);
fclose(fp1);
fclose(fp2);
fp2=fopen("fstu","rb");
printf(" List fstu file data : \n");
printf(" * * * * * * * * * * * * * * * * * * * * * * * * * * *\n");
printf(" No. Num Name Age Addr C Math En. Aver.\n");
printf(" -----------------------------------------------------\n");
for(i=0;fread(&stu[i],sizeof(struct student),1,fp2)!=0;i++)
{ printf("%12d%7ld %-10s%2d %-10s",stu[i].n,stu[i].num,stu[i].name,stu[i].age,stu[i].addr);
printf("%3d %3d %3d %6.2f\n",stu[i].score[0],stu[i].score[1],stu[i].score[2],stu[i].avr);
}
fclose(fp2);
printf(" * * * * * * * * * * * * * * * * * * * * * * * * * * *\n\n");
getch();printf("\n");
}
main()
{ int n;
for(;;)
{ printf("\n\n\n\n\n\n\n\n\n\n\n\n");
printf(" * * * * * * * * * * * * * * * * * *\n");
printf(" * Student M I S *\n");
printf(" * * * * * * * * * * * * * * * * * *\n");
printf(" * 1. Input student data *\n");
printf(" * 2. Find student data *\n");
printf(" * 3. Change student data *\n");
printf(" * 4. Append student data *\n");
printf(" * 5. List student data *\n");
printf(" * 6. Sort student file *\n");
printf(" * 7. Copy backup file *\n");
printf(" * 8. Restore backup file *\n");
printf(" * * * * * * * * * * * * * * * * * *\n");
printf(" * 0. Exit system *\n");
printf(" * * * * * * * * * * * * * * * * * *\n\n");
printf(" Please Enter ( 0 -- 8 ) : ");
scanf("%d",&n);
printf("\n\n\n\n\n");
switch(n)
{ case 1 : fin();break;
case 2 : ffind();break;
case 3 : fchan();break;
case 4 : fappe();break;
case 5 : flist();break;
case 6 : fsort();break;
case 7 : fcopy();break;
case 8 : frest();break;
case 0 : printf(" * * * * * * * * * * * * * * * * * *\n");
printf(" * *\n");
printf(" * Finish ! *\n");
printf(" * *\n");
printf(" * * * * * * * * * * * * * * * * * *\n");
printf(" * *\n");
printf(" * Good Bye ! *\n");
printf(" * *\n");
printf(" * * * * * * * * * * * * * * * * * *\n\n");
getch();exit();
default: printf(" * * * Error ! Press any key continue. * * *\n");
getch();break;
}
}
}

回答2:

基本信息至少还应包括:性别、年龄

1.登录系统
2.录入已知学生信息(读取目标文件)
3.添加、删除、修改指定学生基本信息
4.根据学号对学生基本信息排序(显示结果成有序性)
5.根据学号或身份证号查询学生基本信息
6.根据学号显示指定年级的学生基本信息
7.显示所有学生基本信息
6.操作界面颜色设置、字体颜色设置以及时间显示
7.对操作后的信息数据保存(写入指定文件)

以上各个方面还可继续扩展。

回答3:

我这有个我学习时写的,只是学生信息不一样,你可以参考下.

#include
#define n 100
#include
#include
#include
main()
{
char num[n][12]={{'\0','\0'}},nam[n][10]={{'\0','\0'}},i,cazao[12],a,kl[10]={'\0'};
int sco[n]={0},cs=0,j,b=0,k=0,l=1,th=0;
FILE *fp;
while(strcmp(kl,"z")!=0)
{
printf("请输入密码:");
scanf("%s",kl);
k=k+1;
if(k>2)
exit(0);

}

do
{
fp=fopen("a.txt","r");//打开文件
for(j=0;j {
fscanf(fp,"%s\n",&num[j]);
fscanf(fp,"%s\n",&nam[j]);
fscanf(fp,"%d\n",&sco[j]);//读取数据
if(feof(fp)!=0) break;
}

fclose(fp);

ks: printf("---------------------------------------\n");
printf(" 1添加\n");
printf(" 2查找\n");
printf(" 3查看\n");
printf(" 4删除\n");
printf(" 5清屏\n");
printf(" 6保存\n");
printf(" 7读取\n");
printf(" 8排名\n");
printf(" 9退出\n");
printf("--------------------------------------\n");//菜单
do
{
i=getch();
}while(i<'1'||i>'9');
printf("你选择了:%c\n",i);
}while(i=='7');//回到读取数据

if(i=='1')
{
for(j=0;j {
if(num[j][0]=='\0')
break;
}//查找空的数组
printf("\n操作数为:%d",j+1);
printf("\n请输入学号:");
scanf("%s",num[j]);
printf("请输入学生姓名:");
scanf("%s",nam[j]);
printf("请输入得分:");
scanf("%d",&sco[j]);
goto ks;//回菜单
}
if(i=='2')
{
printf("\n查找方式: 1:学号 2:姓名 ");
a=getche();
if(a=='1')
{
printf("\n请输入学号:\n");
scanf("%s",cazao);
for(j=0;j {
if(strcmp(num[j],cazao)==0)//判断字符
{
b=1;//标记查找到
break;
}
}

if(b==0)
{
printf("没找到!\n");

}
if(b==1)
{
printf("\n操作数为:%d\n",j+1);
printf("学号:%s\n",num[j]);
printf("姓名:%s\n",nam[j]);
printf("得分:%d\n",sco[j]);
}
}

if(a=='2')
{
printf("\n请输入姓名:\n");
scanf("%s",cazao);
for(j=0;j {
if(strcmp(nam[j],cazao)==0)
{
b=1;
printf("\n操作数为:%d\n",j+1);
printf("学号:%s\n",num[j]);
printf("姓名:%s\n",nam[j]);
printf("得分:%d\n",sco[j]);

}
}

if(b==0)
{
printf("没找到!\n");

}

}
goto ks;
}
if(i=='3')
{
ck: l=0;th=0;
printf("操作号 学号 姓名 得分\n");
for(j=0;j {

if(num[j][0]=='\0')
continue;
printf("%-2d %-11s %-10s %2d\n",j+1,num[j],nam[j],sco[j]);

l=l+1;
th=th+sco[j];

}
printf("平均:%d,总分:%d\n",th/l,th);
goto ks;
}
if(i=='4')
{
printf("请输入操作号:");
scanf("%d",&j);
j=j-1;
num[j][0]='\0';
nam[j][0]='\0';

goto ck;
}
if(i=='5')
{
system("cls");
goto ks;
}
if(i=='6')
{
fp=fopen("a.txt","w");
for(j=0;j {
if(num[j][0]=='\0')
continue;

fprintf(fp,"%s\n",num[j]);
fprintf(fp,"%s\n",nam[j]);
fprintf(fp,"%d\n",sco[j]);
}
fclose(fp);
printf("保存成功!\n");
goto ks;
}
if(i=='8')
{
for(j=1;j {
for(l=0;l {
if(sco[l] {
th=sco[l];
sco[l]=sco[j];
sco[j]=th;
strcpy(cazao,nam[j]);
strcpy(nam[j],nam[l]);
strcpy(nam[l],cazao);
strcpy(cazao,num[j]);
strcpy(num[j],num[l]);
strcpy(num[l],cazao);
}
}

}
goto ck;
}
}

回答4:

姓名、学号、身份证号、出生日期、家庭住址。