当前位置:首页 » 编程语言 » 学生管理c语言版
扩展阅读
webinf下怎么引入js 2023-08-31 21:54:13
堡垒机怎么打开web 2023-08-31 21:54:11

学生管理c语言版

发布时间: 2023-05-25 05:24:57

Ⅰ 用c语言编写一个学生管理系统。

学生信息管理系统

#include<stdio.h>

#inelude<stdlib.h>

#include<stnng.h

#define BUFLEN 100

#define LEN 15

#define N 100

#strucet record

char codc[LEN+I J;

char name[LEN-1];

int age:

char sex 13l:

char timc[1.KN-I J;

char add[301;

char tcl [l.EN+1 J:

char mail[30]:

}stu[N]:

int k=1.n,m.

void readfilcO;

void seekO;

void modify(;

void insert();

void del();

void display(;

void save();

void menu(;

int main(

While(k)

menu();

system("pause");

一℃himl 0:

}

void help()

{

printf(" nO.欢迎使用系统帮助, );

printf(" 1.进入系统后,先制新学生信息,再查询: ’);

printf(" 2.按照菜单提示键入数字代号

printf(" 3. 增加学生信息后,切记保存按;.n”

printf(" 4. 谢谢您的仗用! ");

}

void n:adlilcO

r

r

char *p-"studcnt.txt'

FILE *fp,

hit i-0;

if ((fp=fopen("studcnt.txt","r" ))`=NULL)

{

printf("Open file %s error' Strike any key to exit! P);

system("pause");

exit(0);

}

while(fscanf(fp,"%s 0os0od0,os 0os %s %s 0os",stu[i].code,stu[i1.name,&stu(i1.age,

stu[i].sex,stuLiJ.time,stuLiJ.add,stu[iJ.tel.stu [iJ.mail)"==8)

{

i++;

i-i;

}

char codc[LEN+1 J;

char name[LEN-1 ];

nit age;

char sex [3I;

char timc[LEN-I J;

char add[30];

char tcl[LEN+I I;

char mail[30J;

)stu[N];

int k=1.n,m;

void readfilcO;

void seek();

void modify();

void insert();

void delO;

void display();

void save();

void menu();

int main()

{

while(k)

menu();

systcm("pause");

return 0:

}

void help()

{

printf(" nO.欢迎仗用系统帮助, ");

printf(" }n1.进入系统后,先刷新学生信息,再查询: );

printf("in2.按照菜单提示键入数字代号加 );

printf("1n,. t}加学生信息后,切记保存按钮 ”

printf("'nd. i$:41您的使用 );

}

void readfile()

{

char *p-"studcnLtxt";

FILE*fp

int i=0;

if ((fp=fopcn("student. tx t","r'' )卜=NULL)

{

printf("Open file %s error' Strike any key to exit!".p);

systcm("pause");

exit(0);

}

i++;

i=i;

}

printf("请选择菜单编号:’’);

scanf("%d",&num);

switch(num)

{

case 0:help();break;

cast 1:readflic();break;

case 2:seek();break;

case 3:modify();break;

case 4:insert();break;

case 5:del();break:

case 6:display();break;

case 7:savc();break;

case 8:k=0,break:

defaalt:prinf(”请在一8之间选择 "):

}

}

拓展资料

C语言是一门通用计算机编程语言,应用广泛。C语言的设计目标是提供一种能以简易的方式编译、处理低级存储器、产生少量的机器码以及不需要任何运行环境支持便能运行的编程语言。

尽管C语言提供了许多低级处理的功能,但仍然保持着良好跨平台的特性,以一个标准规格写出的C语言程序可在许多电脑平台上进行编译,甚至包含一些嵌入式处理器(单片机或称MCU)以及超级电脑等作业平台。

Ⅱ 学生管理系统C语言

#include<stdio.h>
#define N 30
int Input1(long xuehao[],int score[],int n);
int Sum(int score[],int n);
int No3(long xuehao[],int score[],int n);
int No4(long xuehao[],int score[],int n);
int No5(long xuehao[],int score[],int n);
int No6(int score[],int n);
int Input1(long xuehao[],int score[],int n){
int i;

printf("输入学号和成绩\n");
for(i=0;i<n;i++){
scanf("%ld %d",&xuehao[i],&score[i]);
}
// for(i=0;i<n;i++){
// printf("学号%ld 成绩%d\n",xuehao[i],score[i]);
//}
}

int Sum(int score[],int n){
int sum;
float aver;
sum=0; aver=0;
int i;
for(i=0;i<n;i++){
sum=sum+score[i];
}
aver=(float)sum/n;
printf("总分为%d,平均分为%.2f",sum,aver);
}

int No3(long xuehao[],int score[],int n){
int i,j,k,temp1;
long temp2;
for(i=0;i<n-1;i++){
k=i;
for(j=i+1;j<n;j++){
if(score[j]>score[k]){ k=j; }

}
if(k!=i){
/*交换成绩*/
temp1=score[k];score[k]=score[i];score[i]=temp1;
/*交换学号*/
temp2=xuehao[k];xuehao[k]=xuehao[i];xuehao[i]=temp2;
}
}
int a;
printf("按成绩高低排序\n");
for(a=0;a<n;a++){
printf("学号%ld 成绩%d\n",xuehao[a],score[a]);
}

}
int No4(long xuehao[],int score[],int n){

int i,j,k,temp1;
long temp2;
for(i=0;i<n-1;i++){
k=i;
for(j=i+1;j<n;j++){
if(xuehao[j]>xuehao[k]){ k=j; }

}

if(k!=i){
/*交换学号*/
temp1=xuehao[k];xuehao[k]=xuehao[i];xuehao[i]=temp1;
/*交换成绩*/
temp2=score[k];score[k]=score[i];score[i]=temp2;
}
}
int a;
printf("按学号排序\n");
for(a=0;a<n;a++){
printf("学号%ld 成绩%d\n",xuehao[n-1-a],score[n-1-a]);
}

}

int No5(long xuehao[],int score[],int n){
int i,a;
long x;
No3(xuehao,score,n);
printf("输入学号\n");
scanf("%ld",&x);
for(i=0;i<n;i++){
if(xuehao[i]==x){
a=i;
break;
}
}
printf("学号%ld 成绩%d 排名%d\n ",xuehao[a],score[a],a+1);
}

int No6(int score[],int n){
int i;
int a=0,b=0,c=0,d=0,e=0;
float a1,b1,c1,d1,e1;

for(i=0;i<n;i++){
if(score[i]>=90) {a++; }
else if(score[i]>=80){b++; }
else if(score[i]>=70) {c++; }
else if(score[i]>=60) {d++; }
else {e++; printf("e is%d",e);}
}
a1=(float)a/n*100;b1=(float)b/n*100;c1=(float)c/n*100;d1=(float)d/n*100;e1=(float)e/n*100;
printf("优秀%d %.1f%%\n良好%d %.1f%% \n中等%d %.1f%% \n及格%d %.1f%%\n不及格%d %.1f%%\n",a,a1,b,b1,c,c1,d,d1,e,e1);

// printf("%.2f %.2f %.2f %.2f %.2f\n",a1,b1,c1,d1,e1);

}

int No7(long xuehao[],int score[],int n){
int i;
for(i=0;i<n;i++){
printf("学号%ld 成绩%d\n",xuehao[i],score[i]);
}
Sum(score,n);
}

main(){
int score[N];
long xuehao[N];
int n;
printf("1.Input record\n");
printf("2.caculate total and average score of course\n");
printf("3.sort in descending order by score\n");
printf("4.sort in ascending order by score\n");
printf("5.search by number \n");
printf("6.statistic analysis\n");
printf("7.list record\n");
printf("0.exit\n");
int num;
printf("人数(不许超过30!不许超过30!不许超过30)\n");

do{scanf("%d",&n);}while(n<1 || n>30);
if(n>30) printf("wrong!\n");
//printf("输入选项\n");
//scanf("%d",&num);
int p=1; //控制结束
do{
printf("输入选项\n");
scanf("%d",&num);
switch(num){
case 1:
Input1(xuehao,score,n);
break;
case 2: Sum(score,n);
break;
case 3: No3(xuehao,score,n);

break;
case 4: No4(xuehao,score,n);
break;
case 5: No5(xuehao,score,n);
break;
case 6: No6(score,n);
break;
case 7: No7(xuehao,score,n);
break;
case 0: p=-1;
break;
}
}while(p!=-1);
return 0;
}

Ⅲ 用c语言编写学生管理系统

由于插入记录森吵会把之后的记录给覆盖掉
有三条思路给楼主选择:
1、此链侍每次插入一个数据都把所有的学生记录给读出来,在结构体数组中做好后,再重新写回去。(相当费内存,cpu)
2、从文件的末尾开始读,依次把数据向后移一个,直到唤仿要插入的数据
3、在插入数据之前,先把要覆盖的数据给读出来,然后再覆盖,同上,接着读下一个数据,接着覆盖,知道文件结束。

Ⅳ 用C语言实现学生管理系统

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef struct student {
int id; //学号
char name[20]; //名字
float score[3]; //3门成绩
float average; //平均分
struct student *next;
}sinfo,*pinfo;

pinfo head;

void inithead() //初始化头结点
{
head = NULL;

head = (pinfo)malloc(sizeof(sinfo));
if(head == NULL)
{
printf("memeroy error!\n");
exit(0);
}
head->id = 0;
memset(head->name,0,sizeof(head->name));
head->score[0] = 0;
head->score[1] = 0;
head->score[2] = 0;
head->average = 0;
head->next = NULL;

return ;
}

void getdata() //接受学生数据
{
int i;
pinfo p = head->next;
pinfo s = NULL;

s = (pinfo)malloc(sizeof(sinfo));
if(s == NULL)
{
printf("memeroy error!\n");
exit(0);
}
printf("please input the student infomation like:\n");
printf("id name score(1) score(2) score(3)\n");
scanf("%d %s %f %f %f",&s->id,s->name,&s->score[0],&s->score[1],&s->score[2]);
s->average = (s->score[0] + s->score[1] + s->score[2])/3.0;

if(head->next == NULL)
{
head->next = s;
s->next = NULL;
}else
{
while(p->next != NULL)
{
p = p->next;
}
p->next = s;
s->next = NULL;
}

return ;
}

void deleteinfo()
{
int id;

printf("input the id to delete:\n");
scanf("%d",&id);

pinfo p = head;
pinfo q = head->next;

while(p->next != NULL)
{
if(q->id == id)
{
p->next = q->next;
break;
}
p = p->next;
q = q->next;
}
}

void sortinfo() //排序
{
int i,j;
int count = 0;
pinfo s,k;
pinfo p = head;
pinfo q = head->next;
struct student top;

if(head->next == NULL || q->next == NULL)
{
printf("the list is empty or only have one member\n");
return ;
}
while(p->next != NULL)
{
count++;
p = p->next;
}
p = head;
for(i=0; i<count; i++)
{
for(j=0; j<(count-i); j++)
{
if(q->next == NULL)
{
if(p->average > q->average)
{
k->next->next = q;
q->next = p;
p->next = NULL;
}
break;
}
k = p;
p = p->next;
q = q->next;
if(p->average > q->average && q->next != NULL)
{
s = q->next;
k->next = q;
q->next = p;
p->next = s;
q = s;
}else if(p->average > q->average && q->next == NULL)
{
k->next = q;
q->next = p;
p->next = NULL;
break;
}
}
p = head;
q = head->next;
}

return ;
}

void showinfo() //输出
{
pinfo p = head;

if(head->next == NULL)
{
printf("the list is empty!\n");
return;
}
printf("the student information list:\n");
printf("id\tname\tscore(1)\tscore(2)\tscore(3)\taverage\n");
while(p->next != NULL)
{
p = p->next;
printf("%d\t%s\t%.2f",p->id,p->name,p->score[0]);
printf("\t\t%.2f\t\t%.2f\t\t%.2f\n",p->score[1],p->score[2],p->average);
}
}

int main()
{
int choice;

inithead();
while(1)
{
do {
choice = 6;
printf("input your choice:\n");
printf("\t1.input student data\n");
printf("\t2.delete student data\n");
printf("\t3.sort student data\n");
printf("\t4.show student data\n");
printf("\t0.quit\n");
scanf("%d",&choice);
getchar();
}while(choice != 1 && choice != 2 && choice != 3 && choice != 4 && choice != 0);

switch(choice)
{
case 1:
getdata();
break;
case 2:
deleteinfo();
break;
case 3:
sortinfo();
break;
case 4:
showinfo();
break;
case 0:
printf("welcome to come again!\n");
return 0;
}
}
}

正好写了一个。。。

Ⅳ 学生信息管理系统(C语言版)

#include "stdio.h"
#include "bios.h"
#include "conio.h"
#include "STRING.H"
#include "DOS.h"
#include "process.h"
#include "stdlib.h"
#include "math.h"
#define key_down 80
#define key_up 72
#define key_esc 1
#define key_alt_f 33
#define key_alt_x 45
#define key_enter 28
#define key_alt_c 46
#define key_alt_e 18
#define key_alt_s 31
#define key_alt_d 32
#define key_alt_r 19
#define key_alt_p 25
#define key_alt_o 24
struct student
{
char name[20];
long num;
char age[2];
char sex[4];
char xibie[16];
char jiguan[50];
struct{
float chinese;
float english;
float math;
float total;
float ave;}score;
struct student *next;
};
struct student agent[50];
struct student *head,*this1,*new1,*new2,*stud;
char numstr[40]={' ',' '};
int n=0;
int r=0;
int k=0;
long num;
int get_key();
void box(int startx,int starty,int high,int width);
void new1name(void),listall(void),wfile(void),rfile(void);
struct student *insert(struct student *head ,struct student *stud);
void cjlr(),cjtj(),cjpx(),cxxs(),list(),cxcj();
void del();
int mmm();
int nnn();
void ab();
mmm()
{char aaa[6],bbb[6];
char d; //int r=0;
int i=0;
FILE *fp;
char a[6];
char b[6];
clrscr();
if((fp=fopen("file1","r"))==NULL)
{ window(1,1,80,25);
textbackground(1);
textcolor(0);
clrscr();
window(20,8,60,20);
textbackground(14);
textcolor(0);
clrscr();
gotoxy(8,2);
cprintf("NO UER!");
fclose(fp);
fp=fopen("file1","w");
gotoxy(2,4);
printf("Please input name:");
gets(a);fwrite(a,6,1,fp);
gotoxy(2,8);
printf("Please input key:");
gets(b); fwrite(b,6,1,fp);
fclose(fp);
ab();
}
else
{ window(1,1,80,25);
textbackground(1);
textcolor(0);
clrscr();
window(20,8,60,20);
textbackground(14);
textcolor(0);
clrscr();
gotoxy(8,2);
cprintf("Input Your Name And Password:");
gotoxy(2,8);
cprintf(" PWD:");
gotoxy(2,4);
cprintf("NAME:");
scanf("%s",aaa);

gotoxy(7,8);
while(d=getch())
{
if(d==13)
break;
cprintf("*");
bbb[i]=d;
i++;
}
fp=fopen("file1","r");
fread(a,6,1,fp);
fread(b,6,1,fp);
fclose(fp);
for(i=0;i<=5;i++)
{
if(aaa[i]!=a[i] || bbb[i]!=b[i])
exit(0);

}

}

ab();

}
nnn()
{union REGS inregs ,outregs;
inregs.h.ah=0x2a;
intdos(&inregs,&outregs);
window(60,24,80,25);
textbackground(14);
textcolor(0);
clrscr();
cprintf("Data is 2004-%d-%d.\n",outregs.h.dh,outregs.h.dl);
return 0;
}

void ab()
{int i;
clrscr();
window(1,1,80,25);
textbackground(1);
textcolor(0);
clrscr();
window(20,8,62,20);
textbackground(14);
textcolor(128);
clrscr();
for(i=0;i<=11;i++)
{window(20,8+i,62,9+i);
textbackground(i);
textcolor(128+i*2);
clrscr();
cprintf(" Welcome To Students Management System!");
}
getch();
}
main()
{int i,key,x,y,l;
char *menu[]={"input(F)","print1(O)","del(D)","find(C)","print(P)","save(S)","exit(X)"};
char *red[]={"input","printf1","del","find","print","cpoy","exit"};
char *f[]={"xueji luru","chengji luru","chenji tongji","add student","chengji paixu"};
char *c[]={"student","chengji"};
char buf[16*10*4],buf1[16*4];
struct student *stud;
if(k++==0)
mmm();
window(1,2,80,25);
textbackground(15);
textcolor(0);
clrscr();
textbackground(1);
clrscr();
window(1,1,80,1);
textbackground(15);
textcolor(0);
clrscr();
window(1,1,80,2);
gotoxy(1,1);
for(i=0,l=0;i<7;i++)
{x=wherex();
y=wherey();
cprintf(" %s",menu[i]);
l=strlen(menu[i]);
gotoxy(x,y);
textcolor(RED);
cprintf(" %s",red[i]);
x=x+l+4;
gotoxy(x,y);
textcolor(BLACK);
}
nnn();
if(r++==0)
main();
window(1,2,80,25);
while(1)
{
key=0;
while(bioskey(1)==0);
key=get_key();
if(key==key_alt_x) exit(0) ;
if(key==key_alt_s) wfile();
if(key==key_alt_d) del();
if(key==key_alt_r) rfile();
if(key==key_alt_p) listall();
if(key==key_alt_o) list();
if(key==key_alt_f)
{textbackground(0);
textcolor(15);
gotoxy(4,1);
cprintf("%s",menu[0]);
gettext(4,2,18,12,buf);
window(4,2,18,8);
textbackground(15);
textcolor(0);
clrscr();
window(4,2,19,9);
box(1,1,7,16);
for(i=2;i<7;i++)
{gotoxy(2,i);
cprintf("%s",f[i-2]);}
gettext(2,2,18,3,buf1);
textbackground(0);
textcolor(15);
gotoxy(2,2);
cprintf("%s",f[0]);
y=2;
key=get_key();
while(key!=key_alt_x && key!=key_enter && key!=key_esc)
{if(key==key_up || key==key_down)
{puttext(2,y,18,y+1,buf1);
if(key==key_up)
y=y==2?6:y-1;
if(key==key_down)
y=y==6?2:y+1;
gettext(2,y,18,y+1,buf1);
textbackground(0);
textcolor(15);
gotoxy(2,y);
cprintf("%s",f[y-2]);
}
key=get_key();
}
if(key==key_alt_x) exit(0);
if(key==key_enter)
{switch(y-1)
{case 1 : new1name();break;
case 2 : cjlr();break;
case 3 : cjtj();break;
case 4 : insert(head,stud);break;
case 5 : cjpx();break;
default : break;
}
}
}
else
{
window(1,1,80,1);
puttext(2,2,19,10,buf);
textbackground(15);
textcolor(0);
gotoxy(4,1);
cprintf("%s",menu[0]);

}
if(key==key_alt_c)
{textbackground(0);
textcolor(15);
gotoxy(39,1);
cprintf("%s",menu[3]);
gettext(39,2,50,7,buf1);
window(39,2,49,5);
textbackground(15);
textcolor(0);
clrscr();
window(39,2,49,6);
box(39,1,4,11);
for(i=2;i<4;i++)
{
gotoxy(2,i);
cprintf("%s",c[i-2]);
}
gettext(39,2,49,3,buf1);
textbackground(0);
textcolor(15);
gotoxy(2,2);
cprintf("%s",c[0]);
y=2;
key=get_key();
while(key!=key_alt_x&&key!=key_enter&&key!=key_esc)
{if(key==key_up||key==key_down)
{puttext(39,y,49,y+1,buf1);
if(key==key_up)
y=y==2?3:y-1;
if(key==key_down)
y=y==3?2:y+1;
gettext(39,y,49,y+1,buf1);
textbackground(0);
textcolor(15);
gotoxy(2,y);
cprintf("%s",c[y-2]);
}
key=get_key();
}
if(key==key_alt_x) exit(0);
if(key==key_enter)
{switch(y-1)
{case 1: cxxs();break;
case 2: cxcj();break;

default:break;
}
}
}
else
{window(1,1,80,2);
puttext(39,2,49,7,buf);
textbackground(15);
textcolor(0);
gotoxy(39,1);
cprintf("%s",menu[3]);

}
} }

int get_key()
{ union REGS rg;
rg.h.ah=0;
int86(0x16,&rg,&rg);
return rg.h.ah;
}

void box(int startx,int starty,int high,int width)
{ int i;
gotoxy(startx,starty);
putch(0xda);
for(i=starty+1;i<width;i++)
putch(0xc4);
putch(0xbf);
for(i=starty+1;i<high;i++)
{gotoxy(startx,i);
putch(0xb3);
gotoxy(width,i);putch(0xb3);}
gotoxy(startx+1,width);
putch(0xc0);
for(i=startx+1;i<width;i++)
putch(0xc4);
putch(0xd9);
return;
}

/* void new1name(void)
{ int key;
window(1,2,80,25);
textbackground(BLUE);
clrscr();
cprintf("Are you sure input?");
key=get_key();
while(key!=key_alt_x && key!=key_esc)
{
window(1,2,80,25);
textbackground(BLUE);
clrscr();
new1=new2=(struct student *)malloc(sizeof(struct student));
if(head==NULL)
head=new1;
else
{ this1=head;
while(this1->next!=NULL)
this1=this1->next;
this1->next=new1;
}
this1=new1;
printf("\nRecord%d:",n+1);
printf("\nXing Ming:");
gets(this1->name);
printf("\nXue Hao:");
gets(numstr);
this1->num=atol(numstr);
printf("\nNian Ling:");
gets(this1->age);
printf("\nXing Bie:");
gets(this1->sex);
printf("\nXue Yuan:");
gets(this1->xibie);
printf("\nJi Guan:");
gets(this1->jiguan);
n++;
this1->next=NULL;
printf("Are you sure input :Y/N?");
if(getch()=='n')
main();
else
new1name();
}
} */

void new1name(void)
{ int key;
char a;
window(1,2,80,25);
textbackground(BLUE);
clrscr();
cprintf("Are you sure input?");
key=get_key();
while(key!=key_alt_x && key!=key_esc)
{
window(1,2,80,25);
textbackground(BLUE);
clrscr();
new1=new2=(struct student *)malloc(sizeof(struct student));
if(head==NULL)
head=new1;
else
{ this1=head;
while(this1->next!=NULL)
this1=this1->next;
this1->next=new1;
}
this1=new1;
printf("\nRecord%d:",n+1);
printf("\nXing Ming:");
gets(&a);
gets(this1->name);
printf("\nXue Hao:");
gets(numstr);
this1->num=atol(numstr);
printf("\nNian Ling:");
gets(this1->age);
printf("\nXing Bie:");
gets(this1->sex);
printf("\nXue Yuan:");
gets(this1->xibie);
printf("\nJi Guan:");
gets(this1->jiguan);
n++;
this1->next=NULL;
printf("Are you sure input :Y/N?");
if(getch()=='n')
main();
else
new1name();
}
main();
}
/**/
void listall(void)
{
int i=0;
window(1,2,80,25);
textbackground(1);
textcolor(0);
clrscr();
if(head==NULL)
{cprintf("\nempty list .\n");return;
}
this1=head;

do
{ cprintf("\nrecord number %d\n",++i);
cprintf(" name:%s",this1->name);
cprintf(" number:%ld",this1->num);
cprintf(" age:%s",this1->age);
cprintf(" sex:%s",this1->sex);
cprintf(" xibie:%s",this1->xibie);
cprintf(" jiguan:%s",this1->jiguan);
cprintf(" chinese:%6.2f",this1->score.chinese);
cprintf(" english:%6.2f",this1->score.english);
cprintf(" math:%6.2f",this1->score.math);
cprintf(" total:%6.2f",this1->score.total);
cprintf(" ave:%6.2f\n",this1->score.ave);
this1=this1->next;
//this1->next=NULL;
}while(this1!=NULL);
getch();
main();
}
//*insert
struct student *insert(struct student *head,struct student *stud)
{
struct student *p0,*p1,*p2;
p1=head;
p0=stud;
if(head==NULL)
{head=p0;p0->next=NULL;}
else
while((p0->num>p1->num) && (p1->next!=NULL))
{p2=p1;p1=p1->next;}
if(p0->num<=p1->num)
{if(head==p1)
{head=p0;
p0->next=p1;
}
else
{p2->next=p0;
p1->next=p1;
}
}
else
{p1->next=p0;
p0->next=NULL;
}
n=n+1;
return(head);
}
void wfile(void)
{FILE *fptr;
char a[10];
if(n<1)
{printf("\nCan't write empty list.\n");return;}
// char a[10];
cprintf("Please input filename:");
gets(a);
if((fptr=fopen(a,"wb"))==NULL)
printf("\nCant' open file agents.rec\n");
else
{this1=head;
while(this1->next!=NULL)
{fwrite(this1,sizeof(struct student ),1,fptr);
this1=this1->next;
}
// fwrite(this1,sizeof(struct student ),1,fptr);
fclose(fptr);
printf("\nFile of %d records have writen.\n",n);
}
getch();
main();
}
//*rfile
void rfile(void)
{FILE *fptr;
char b[10];
cprintf("Please input filename:");
gets(b);
if((fptr=fopen(b,"rb"))==NULL)
printf("\nCan't open file %s\n",b);
else
{n=0;
head=(struct student *)malloc(sizeof(struct student));
this1=head;
fread(this1,sizeof(struct student),1,fptr);
n++;
while(1)
{if(feof(fptr))
{fclose(fptr);
this1->next=NULL;printf("\nFile read.Total agents is now %d.\n",n);
getch(); main() ;
}else{
this1->next=(struct student *)malloc(sizeof(struct student));
this1=this1->next;
fread(this1,sizeof(struct student),1,fptr);
n++;
}} this1->next=NULL;

//fread(this1,sizeof(struct student),1,fptr);
//n++;
fclose(fptr);
printf("\nFile read.Total agents is now %d.\n",n);
}
getch();
main();
}
//*wfile
/*void wfile(void)
{char a[10];
FILE *fptr;
if(n<1)
{printf("\nCan't write empty list.\n");return;}
cprintf("Please input filename:");
gets(a);
if((fptr=fopen(a,"wb"))==NULL)
{cprintf("\nCant' open file ");puts(a);cprintf("\n");
}
else
{fwrite(agent,sizeof(struct student ),n,fptr);
fclose(fptr);
printf("\nFile of %d records writen.\n",n);
}
getch();
main();
}
//*rfile
void rfile(void)
{FILE *fptr;
char a[10];
cprintf("Please input filename:");
gets(a);
if((fptr=fopen(a,"wb"))==NULL)
{cprintf("\nCan't open file ");puts(a);
}
else
{while(fread(&agent[n],sizeof(agent[n]),1,fptr)==1)
n++;
fclose(fptr);
printf("\nFile read.Total agents is now %d.\n",n);
}
getch();
main();
} */
//*cjlr
void cjlr(void)
{struct student *p1;
long num; char ddd[5];
char ccc[5];
window(1,2,80,25);
textbackground(BLUE);
clrscr();
p1=head;
printf("input the student' number:");
scanf("%ld",&num);
if(head==NULL)
{
printf("\nlist null!\n");
}
p1=head;
while(num!=p1->num && p1->next!=NULL)
{p1=p1->next;}
if(p1->num==num)
{printf("chinese:");
scanf("%f",&p1->score.chinese);
// gets(ccc);printf("\n");
// p1->score.chinese=atof(ccc);
printf("english:");
scanf("%f",&p1->score.english);
// gets(numstr);
//p1->score.english=atof(numstr);
//getch();
printf("math:");
scanf("%s",ddd);
// gets(ddd);
p1->score.math=atof(ddd);
p1->score.total=p1->score.chinese+p1->score.english+p1->score.math;
p1->score.ave=(p1->score.chinese+p1->score.english+p1->score.math)/3.0;
}
getch();
main();
}
//*cjlr
/*void cjlr(void)
{struct student *p1;
long num; char ddd[4];
window(1,2,80,25);
textbackground(BLUE);
clrscr();
p1=head;
printf("input the student' number:");
scanf("%ld",&num);
if(head==NULL)
{
printf("\nlist null!\n");
}
p1=head;
while(num!=p1->num && p1->next!=NULL)
{p1=p1->next;}
if(p1->num==num)
{printf("chinese:");
scanf("%f",p1->score.chinese);
//gets(numstr);
//p1->score.chinese=atof(numstr);
//getch();
printf("english:");
scanf("%f",p1->score.english);
//gets(numstr);
//p1->score.english=atof(numstr);
// getch();
printf("math:");
//scanf("%f",p1->score.math);
gets(ddd);
p1->score.math=atof(ddd);
p1->score.ave=(p1->score.chinese+p1->score.english+p1->score.math)/3.0;
getch();
}
getch();
main();
} */
//*del
void del()
{struct student *p1,*p2;
long num;
window(1,2,80,25);
textbackground(BLUE);
clrscr();
printf("input the del student' number:");
scanf("%ld",&num);
if(head==NULL)
{
printf("\nlist null!\n"); exit(1);
}
p1=head;
while(num!=p1->num && p1->next!=NULL)
{p2=p1;p1=p1->next;
}
if(num==p1->num)
{if(p1==head) head=p1->next;
else
p2->next=p1->next;
printf("the %ld message have del\n",num);
n=n-1;
}
else
printf("No find %ld!\n",num);
getch();
main();
}
//
void cjtj(void)
{struct student *p;
for(p=head;p!=NULL;p=p->next)
{ p->score.total=p->score.chinese+p->score.english+p->score.math;
p->score.ave=p->score.total/3.0;
}
}
//
void cjpx(void)
{
struct student *p,*p1;
int i,j,t;
float temp;
for(i=0;i<n;i++)
{

p=head;
p1=p->next;
if(p->score.total<p1->score.total)
{temp=p->score.total;
p->score.total=p1->score.total;
p1->score.total=temp;
}
}
}
//
void cxxs(void)
{ struct student *p;
char name1[20];
window(1,2,80,25);
textbackground(BLUE);
clrscr();
printf("shu ru yao cha xun de xue sheng de xing ming:");
gets(name1);
for(p=head;p!=NULL;p=p->next)
{if(strcmp(p->name,name1)==0)

{printf("xingming:%s\n",p->name);
printf("xuehao:%ld\n",p->num);
printf("nianling:%s\n",p->age);
printf("xingbie:%s\n",p->sex);
printf("xibie:%s\n",p->xibie);
printf("jiguan:%s\n",p->jiguan);
}
} getch();
main();
}
/*chaxunchengji*/
void cxcj(void)
{ struct student *p;
char name2[20]; int i;
window(1,2,80,25);
textbackground(BLUE);
clrscr();
printf("shu ru yao cha xu de xue sheng de xingming:");
gets(name2);
for(p=head;p!=NULL;p=p->next)
{if(strcmp(p->name,name2)==0)
{printf("xingming:%s\n",p->name);
printf("chinese:%6.2f\n",p->score.chinese);
printf("english:%6.2f\n",p->score.english);
printf("math:%6.2f\n",p->score.math);
printf("total:%6.2f\n",p->score.total);
printf("ave:%6.2f\n",p->score.ave);
}
}getch();
main();
}

/*dayingmugexueshen*/
void list(void)
{ char name3[20];
int i=0;
window(1,2,80,25);
textbackground(BLUE);
clrscr();
printf("shu ru yao da ying de xue sheng xingming:");
gets(name3);
if(head==NULL)
{ printf("\nempty list.\n");
return;
}
for(this1=head;this1!=NULL;this1=this1->next)
{
if(strcmp(this1->name,name3)==0)
{printf("\nnrecord number %d\n",++i);
printf("xingmming:%s\n",this1->name);
printf("xuehao:%ld\n",this1->num);
printf("nianling:%d\n",this1->age);
printf("xingbie:%s\n",this1->sex);
printf("xueyuan:%s\n",this1->xibie);
printf("jiguan:%s\n",this1->jiguan);
printf("chinese:%6.2f\n",this1->score.chinese);
printf("english:%6.2f\n",this1->score.english);
printf("math:%6.2f\n",this1->score.math);
printf("total:%6.2f\n",this1->score.total);
printf("ave:%6.2f\n",this1->score.ave);
}

} getch();
main();
}

Ⅵ C语言 学生管理系统

#include
#include
#include
#include

#define max 20

typedef struct student //学生
{
char sno[max]; // 学号
char sname[max]; //姓名
char sex[max]; //性别
char age[max]; //年龄
char depart[max]; //系
char classs[max]; //班
char grade[max]; //年级

struct student* next;
} student;

student* head;

int LogOn() //登录模块,已实现输入密码不回显,如果中途发现输错某几位,可退格键重输
{
char username[max],password[max];
printf("\n请输入用户名:");
scanf("%s",username);
printf("\n请输入密码(最多15位):");

//开始以不回显且支持退格方式获取输入密码
int i=0;
while((i>=0)&&(password[i++]=getch())!=13)//条件i>=0是用于限制退格的范围
{
if(password[i-1]=='\b')//对退格键的处理
{
printf("%c%c%c",'\b','\0','\b');
i=i-2;
}
else
printf("*");
}
password[--i]='\0';

//已获取密码。验证用户身份
if(!strcmp(username,"zhang")&&!strcmp(password,"8147086"))
{
printf("\n登录成功!");
return 1;
}
else
return 0;

}

void regist()
{
char ch;
student *s,*ptr; //s用来建新结点,ptr用来暂存头结点

do
{

s=(student*)malloc(sizeof(student)); // 新建一个学生结点

printf("\n开始注册..."); //开始注册
printf("\n请输入该学生的学号:");
scanf("%s",s->sno);
printf("\n请输入该学生的姓名:");
scanf("%s",s->sname);
printf("\n请输入该学生的性别:");
scanf("%s",s->sex);
printf("\n请输入该学生的年龄:");
scanf("%s",s->age);
printf("\n请输入该学生的系:");
scanf("%s",s->depart);
printf("\n请输入该学生所在的班:");
scanf("%s",s->classs);
printf("\n请输入该学生所在的年级");
scanf("%s",s->grade);

ptr=head;
head=s;//将新结点插入队头
s->next=ptr;

fflush(stdin);
printf("\n请问是否继续注册?(Y/N)");
scanf("%c",&ch);
}while(ch=='Y'||ch=='y');

return;
}

void ElePrint(char str[]) //输出单个元素
{
if(str==NULL) exit(0);
printf("%s",str);
for(unsigned int i=0;i<12-strlen(str);i++) printf(" ");//为了对齐输出,需插入一些空格
return;
}

int LinePrint(student *ptr) //输出一行
{
if(ptr==NULL) //检查传进来的指针
return 0;

printf("\n");
ElePrint(ptr->sno);
ElePrint(ptr->sname);
ElePrint(ptr->age);
ElePrint(ptr->sex);
ElePrint(ptr->depart);
ElePrint(ptr->classs);
ElePrint(ptr->grade);

return 1;
}

void print() //输出全部学生信息
{
student *ptr=head;
printf("\n学号 姓名 年龄 性别 系 班 年级 ");
while(ptr)
{
LinePrint(ptr);
ptr=ptr->next;
}
printf("\n");
return;
}
void search()//查询模块
{
int method;//查询方式
char no[max],name[max],departm[max],clss[max],grades[max]; //用来接收查询关键字
while(1)
{
printf("\n请选择查询方式");
printf("\n1.按学号查询");
printf("\n2.按姓名查询");
printf("\n3.按所在系查询");
printf("\n4.按所在班级查询");
printf("\n5.按所在年级查询");
printf("\n6.打印全部学生信息");
printf("\n7.返回主菜单\n");

scanf("%d",&method);

student *p=head,*temp;

switch(method)
{
case 1:
printf("\n请输入要查询的学号:");
scanf("%s",no);
while(p)
{
if(!strcmp(p->sno,no))
break;
else
{
temp=p;
p=p->next;
}
}
printf("\n学号 姓名 年龄 性别 系 班 年级 ");
LinePrint(p);
break;
case 2:
printf("\n请输入要查询的姓名:");
scanf("%s",name);
printf("\n学号 姓名 年龄 性别 系 班 年级 ");
while(p)
{
if(!strcmp(p->sname,name))
LinePrint(p);
p=p->next;
}
break;
case 3:
printf("\n请输入学生所在的系:");
scanf("%s",departm);
printf("\n学号 姓名 年龄 性别 系 班 年级 ");
while(p)
{
if(!strcmp(p->depart,departm))
LinePrint(p);
p=p->next;
}
break;
case 4:
printf("\n请输入学生所在的班:");
scanf("%s",clss);
printf("\n请输入学生所在的年级:");
scanf("%s",grades);
printf("\n学号 姓名 年龄 性别 系 班 年级 ");
while(p)
{
if(!strcmp(p->classs,clss)&&!strcmp(p->grade,grades))
LinePrint(p);
p=p->next;
}
break;

case 5:
printf("\n请输入学生所在的年级:");
scanf("%s",grades);
printf("\n学号 姓名 年龄 性别 系 班 年级 ");
while(p)
{
if(!strcmp(p->grade,grades))
LinePrint(p);
p=p->next;
}
break;

case 6:
print();
break;

case 7:
return;
default:
printf("很抱歉,暂无此查询方式!");
break;
}
}

}

void modify()//修改学生信息
{
char num[max];
student *p=head;
printf("\n请输入要修改的学生的学号:");
scanf("%s",num);
while(p)
{
if(!strcmp(p->sno,num))
break;
else
p=p->next;
}
if(p==NULL)
{
printf("\n错误:没有此学生的信息!\n");
return;

}
LinePrint(p);

printf("\n请输入要修改的该学生的信息:");
printf("\n1.姓名");
printf("\n2.性别");
printf("\n3.年龄");
printf("\n4.所在的系");
printf("\n5.所在的班");
printf("\n6.所在的年级");

char name1[max],sex1[max],age1[max],depart1[max],class1[max],grade1[max];
int select;
fflush(stdin);
scanf("%d",&select);
printf("\n请输入新的信息:");

switch(select)
{
case 1:
scanf("%s",name1);
strcpy(p->sname,name1);
break;
case 2:
scanf("%s",sex1);
strcpy(p->sex,sex1);
break;
case 3:
scanf("%s",age1);
strcpy(p->age,age1);
break;
case 4:
scanf("%s",depart1);
strcpy(p->depart,depart1);
break;
case 5:
scanf("%s",class1);
strcpy(p->classs,class1);
break;
case 6:
scanf("%s",grade1);
strcpy(p->grade,grade1);
break;
default:
printf("\nError!");
break;
}

LinePrint(p);
return;
}

void del()// 删除某学生的信息
{
student *p=head,*temp=head,*s;
char num1[max];
printf("\n请输入要删除的学生的学号:");
scanf("%s",num1);
while(p)//查找该学生所在的结点
{
if(!strcmp(p->sno,num1))
break;
else
{
temp=p;
p=p->next;
}

}//while
if(!p)
{
printf("\n不存在此学生的信息.");
return;
}
LinePrint(p);//输出该学生的信息
printf("\n请问真的要删除该学生的信息吗?(Y/N)");
char ch;
fflush(stdin);
scanf("%c",&ch);
if(ch=='Y'||ch=='y')
{
s=p->next;
temp->next=s;
free(p);
printf("\n已经删除该学生的信息.");
}
return;
}

void sort() //排序模块。将学生记录按学号从小到大排列。用起泡排序算法实现
{

student *ptr,*s=head,*p;
int count=0,count1;
while(s)//统计链表结点个数
{
count++;
s=s->next;
}

for(int i=1;i<count;i++)
{
ptr=head;
p=NULL;
count1=count-i; //用来控制每轮起泡排序的终点,即每次把学号最小的结点移到倒数第i个结点
while(ptr&&ptr->next&&(count1--))
{
if(strcmp(ptr->sno,ptr->next->sno)>0)
{
s=ptr->next;
ptr->next=s->next;
if(p==NULL) //ptr处于队头时
head=s;
else
p->next=s;
s->next=ptr;
p=s;
}
else
{
ptr=ptr->next;
if(p==NULL) //ptr处于队头时
p=head;
else
p=p->next;
}
}
}
return;
}

void quit()
{
char ch;
printf("\n真的要退出?(Y/N)");
fflush(stdin);
scanf("%c",&ch);
if(ch=='Y'||ch=='y')
exit(0);
return;
}

int main()
{
int option;

printf("\nCopyright@2005 KongXinCai All rights reserved.");
printf("\n欢迎使用学生信息管理系统!\n");

//登录模块
int icheck=0;
while(icheck<3)
{
if(LogOn()==0)
icheck++;
else
break;

}
if(icheck==3)
{
printf("\n连续登录三次不成功,退出!");
exit(0);
}

//系统界面

while(1)
{
printf("\n\n请选择需要的服务:");
printf("\n1.注册");
printf("\n2.查询");
printf("\n3.修改");
printf("\n4.删除");
printf("\n5.排序");
printf("\n7.求平均");
printf("\n6.退出\n");

scanf("%d",&option);

switch(option)
{
case 1:
regist();
break;
case 2:
search();
break;
case 3:
modify();
break;
case 4:
del();
break;
case 5:
sort();
break;
case 6:
quit();
break;
}

}

return 0;

}

Ⅶ 学生信息管理系统编程(c语言)

挺好的一个题目啊

但我可不愿意帮人写作业

网上很多类似的,你可以参考下:
#include <stdio.h>
#include <string.h> struct student {
char name[30];
float math;
float chinese;
float english;
float average;
};

int MenuChoice(void);
int EnterAccount(void);
void Enter(struct student *fst);
void Amend(struct student *src);
void Delete(struct student *next);
void Print(struct student *out);

main()
{
struct student one[100] = {0}, *look = one;
int menu, t;

while ((menu = MenuChoice()) != 0)

if (menu >= 1 && menu <= 4 && (t = EnterAccount())) {
look = one + t;

switch (menu) {
case 1:
Enter(look);
break;
case 2:
if (strcmp(look->name, ""))
printf("学号:%d\n姓名: %s\n语文成绩: %.1f\n数学成绩:%.1f\n英语成绩: %f\n平均"成绩:%.1f\n",
t, look->name, look->chinese, look->math, look->english, look->average);
else
printf("对不起,该学号不存在!\n");
break;
case 3:
Amend(look);
break;
case 4:
Delete(look);
break;
}
}
else if (menu == 5)
Print(one);
else
printf("错误的请求!\n");

return 0;
}

int MenuChoice(void)
{
int choice;

printf("请选择:\n"
"1 - 新建学生信息\n"
"2 - 查找学生信息\n"
"3 - 修改学生信息\n"
"4 - 删除学生信息\n"
"5 - 打印学生信息\n"
"0 - 退出\n");
scanf("%d", &choice);

return choice;
}

int EnterAccount(void)
{
int ret;

printf("请输入学号:\n");
scanf("%d", &ret);

if (ret >= 1 && ret <= 100)
return ret -1;

return 0;
}

void Enter(struct student *fst)
{
printf("请输入学生姓名、语文成绩、数学成绩、英语成绩和平均成绩\n");
scanf("%s%f%f%f%f", fst->name, &fst->chinese, &fst->math, &fst->english, &fst->average);
}

void Amend(struct student *src)
{
int t;

printf("请选择:\n"
"1 - 修改学生姓名\n"
"2 - 修改学生语文成绩\n"
"3 - 修改学生数学成绩\n"
"4 - 修改学生英语成绩\n"
"5 - 修改学生平均成绩\n");
scanf("%d", &t);

switch (t) {
case 1:
printf("请输入学生的新名字\n");
scanf("%s", src->name);
break;
case 2:
printf("请输入学生新的语文成绩\n");
scanf("%f", &src->chinese);
break;
case 3:
printf("请输入学生新的数学成绩\n");
scanf("%f", &src->math);
break;
case 4:
printf("请输入学生新的英语成绩\n");
scanf("%f", &src->english);
break;
case 5:
printf("请输入学生新的平均成绩\n");
scanf("%f", &src->average);
break;
}

}

void Delete(struct student *next)
{
strcpy(next->name, "");
next->math = next->english = next->chinese = next->average = 0.0;
}

void Print(struct student *out)
{
struct student *up;

for (up = out; out < &up[100]; out++)

if (strcmp(out->name, ""))
printf("学号:%d\n姓名: %s\n语文成绩: %.1f\n数学成绩:%.1f\n英语成绩: %.1f\n平均成绩:%.1f\n",
out-up + 1, out->name, out->chinese, out->math, out->english, out->average);
}

Ⅷ 用C语言设计一个简单的学生信息管理程序

#include <iostream>#include <stdio.h>#include <string.h>#include <conio.h>#include <iostream>#include <ctime>using namespace std;#define max 100
///////////////////////////////////////////////////////////////知梁///////////strcut stustruct stu //学生资料结构缺毕体{ char name[10]; char num[20]; //学号 char adress[8]; float x,y,z,score; int number;};
//////////////////////////////////////////搭扮运////////////////////////////////////student.cppint count=0;int temp=0;int Exchang=0; //定义数据修改标志,若修改则为1,否则为0class student //学生类{private: stu data[max]; char start_del;public: void input(char *ch1,char *num,char *ch2,float x,float y,float z); //输入 void find(char *num); //查找 void del(char *num); //删除 int check_num(char *num) //确定没有重复学号 { int m=0; while(m<=count) if(!strcmp(num,data[m++].num)) //判断是否相同 break; if(m>count) return 0; else return 1; } void taxis(); //总分排序 void show(); void save(); //保存学生资料 void read(); //从文件"student"读取学生资料};
void student::input(char *ch1,char *num,char *ch2,float x,float y,float z){ strcpy(data[count].name,ch1); strcpy(data[count].num,num); strcpy(data[count].adress,ch2); data[count].x=x; data[count].y=y; data[count].z=z; count++; Exchang=1; //设置已修改数据标志}void student::find(char * num){ int m=0; while(m<=count) if(!strcmp(num,data[m++].num)) break; if(m>count) { cout << "很抱歉,没有该学号的学生" << endl; start_del='n'; getch(); } else { temp=count; count=m; start_del='y'; cout << "该学生的资料为" <<endl << "序号\t姓名\t学号\t\t地址\t\t\t高数\t英语\t计算机" << endl; show(); count=temp; getch(); }}void student::del(char *num){ char chose; find(num); if(start_del=='y') {
cout << "确实要删除该学生资料? Y/N" << endl; cin >> chose; if(chose=='y') { int m=0; while(m<count) if(strcmp(num,data[m++].num)==0) //错在这里 break; temp=count; count=m; if(temp==count) { count=temp-1;printf("2"); cout << "该学生资料已删除" << endl; Exchang=1; //设置已修改数据标志 } else { while(count<temp) { strcpy(data[count-1].name,data[count].name); strcpy(data[count-1].num,data[count].num); strcpy(data[count-1].adress,data[count].adress); data[count-1].x=data[count].x; data[count-1].y=data[count].y; data[count-1].z=data[count].z; count++;
}printf("1"); count=temp-1; cout << "该学生资料已删除" << endl; Exchang=1; //设置已修改数据标志 } } else cout << "学生资料未删除" << endl; getch();
}}void student::taxis(){ int x,y,array[max]; int change; for(x=0;x<count;x++) array[x]=data[x].score=data[x].x+data[x].y+data[x].z; for(x=0;x<count-1;x++) for(y=0;y<count-1-x;y++) if(array[y]<array[y+1]) { change=array[y]; array[y]=array[y+1]; array[y+1]=change; } cout << "总分\t姓名\t学号\t\t地址\t\t高数\t英语\t计算机" << endl; for(x=0;x<count;x++) for(y=0;y<count;y++) if(array[x]==data[y].score) { cout << data[y].score << "\t" << data[y].name << "\t" << data[y].num << "\t" << data[y].adress << "\t" << data[y].x << "\t" << data[y].y << "\t" << data[y].z << endl; } getch(); Exchang=1; //设置已修改数据标志}
void student::show(){ cout << count << "\t" << data[count-1].name << "\t" << data[count-1].num << "\t" << data[count-1].adress << "\t\t" << data[count-1].x << "\t" << data[count-1].y << "\t" << data[count-1].z << endl;}
//////////////////////////////////////////////////////////////////////main.cppvoid main(){ student st; char *ch1,*ch2,chose; char flag[2],num[20],find[20],del[20]; char ch;
float x,y,z; time_t t; time(&t);
while(1) { system("cls"); cout << "------------------------学生管理系统------------------------" <<endl
<< " 1.输入/添加学生资料 "<<endl << " 2.输出学生资料" <<endl << " 3.查找 " <<endl << " 4.删除" <<endl << " 5.总分排序" <<endl << " 6.退出" << endl << endl << " 请选择你要的服务(1-6)"<< endl; cin >> chose; if(chose=='6') { break; } switch(chose) { case '1': // 输入学生信息 { do { cout << "请输入学生姓名:" << endl; ch1=new char[]; ch2=new char[]; cin >> ch1 ; cout << "请输入学号:" << endl; cin >> num ; while(st.check_num(num)) { cout << "学号重复,请重新输入" << endl; cin >> num; } cout << "请输入地址:"<<endl; cin >> ch2 ; cout << "请输入高数成绩:"<<endl; cin >> x; cout << "请输入英语成绩:" <<endl; cin >> y; cout << "请输入计算机成绩:" <<endl; cin >> z; st.input(ch1,num,ch2,x,y,z); printf("\n是否继续输入学生信息?(\"y\"继续)"); scanf("%s", flag); }while(strcmp(flag, "y") == 0); }break; case '2':// 输出学生资料 { temp=count; count=1; cout << "序号\t姓名\t学号\t\t地址\t\t\t高数\t英语\t计算机" << endl; while(count<=temp) { st.show(); count++; } count--; getch(); }break; case '3': { cout << "请输入你要查找学生的学号" << endl; cin >> find; st.find(find); }break; case '4': { cout << "请输入你要删除的学生学号" << endl; cin >> del; st.del(del); }break; case '5': { st.taxis(); }break;
default: { cout << "输入错误!!!,请重新输入" << endl; getch(); } } } cout << "感谢你的使用!\n" <<endl; getch();
}

Ⅸ 用c语言编写学生信息管理系统

我这有伍族个差不多的,要吗?是我写的实训作业
程序:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int man=0;
int j;
char str[20];
struct student
{
char id[11];
char name[10];
int n1;
int n2;
int n3;
int n4;
int n5;
int n6;
int n7;
int n8;
int n9;
int zong;
int ping;
}student[100],temp;
void read(void)
{
FILE *cj;
int i,k;
man=0;
while(1)
{
printf("请输入要读取的文件:\n");
scanf("%s",&str);
if((cj=fopen(str,"r"))==NULL)
{
printf("打唯烂开失败\n");
}
else
{
break;
}
}
for(i=0;i<500;i++)
{
if(fscanf(cj,"%s %s %d %d %d %d %d %d %d %d %d",&student[i].id,&student[i].name,&student[i].n1,&student[i].n2,&student[i].n3,&student[i].n4,&student[i].n5,&student[i].n6,&student[i].n7,&student[i].n8,&student[i].n9)==-1)
{
break;
}
man=man+1;
}
printf("从%s读取去了“%d”条记录\n",str,man);
for(k=0;k<man;k++)
{
student[k].zong=student[k].n1+student[k].n2+student[k].n3+student[k].n4+student[k].n5+student[k].n6+student[k].n7+student[k].n8+student[k].n9;
}
for(i=0;i<man;i++)
{
student[i].ping=student[i].zong/9;
}
fclose(cj);
}
void write(void)
{
FILE *cj;
int i;
char me;
printf("请确认是否保存(是:y,否:任意键):\n");
scanf("%s",&me);
if(me=='y')
{
if((cj=fopen(str,"w"))==NULL)
{
printf("保存失败\n");
}
for(i=0;i<man;i++)
{
fprintf(cj,"%s %s %d %d %d %d %d %d %d %d %d\n",student[i].id,student[i].name,student[i].n1,student[i].n2,student[i].n3,student[i].n4,student[i].n5,student[i].n6,student[i].n7,student[i].n8,student[i].n9);
}
printf("存了“%d”条记录到%s\n",man,str);
fclose(cj);
}
else
return;
}
void save(void)
{
FILE *cj;
int i;
char me;
printf("请输入新的文件名:\n");
scanf("%s",&str);
printf("请确认是否保存(是:y,否:任意键):\n"指橘漏);
scanf("%s",&me);
if(me=='y')
{
if((cj=fopen(str,"w"))==NULL)
{
printf("保存失败\n");
}
for(i=0;i<man;i++)
{
fprintf(cj,"%s %s %d %d %d %d %d %d %d %d %d\n",student[i].id,student[i].name,student[i].n1,student[i].n2,student[i].n3,student[i].n4,student[i].n5,student[i].n6,student[i].n7,student[i].n8,student[i].n9);
}
printf("存了“%d”条记录到%s\n",man,str);
fclose(cj);
}
else
return;
}
void print(void)
{
int i;
for(i=0;i<72;i++)
printf("*");
printf("\n");
printf(" | 学号 姓名 1 2 3 4 5 6 7 8 9 平均分 总分 | \n");
for(i=0;i<man;i++)
{
printf(" | %10s %-6s %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d | \n",student[i].id,student[i].name,student[i].n1,student[i].n2,student[i].n3,student[i].n4,student[i].n5,student[i].n6,student[i].n7,student[i].n8,student[i].n9,student[i].ping,student[i].zong);
}
for(i=0;i<72;i++)
printf("*");
printf("\n");
}
void inquiry(void)
{
int i;
char id[10];
while(1)
{
printf("请输入要查人的学号或名字(输入-1即返回上一级):\n");
scanf("%s",&id);
if(id[0]=='-'&&id[1]=='1')
{
printf("exit\n");
break;
}
else
{
for(i=0;i<man;i++)
{
if(strcmp(student[i].id,id)==0)
{
j=i;
break;
}
if(strcmp(student[i].name,id)==0)
{
j=i;
break;
}

j=-1;

}
if(j==-1)
{
printf("无此人\n");
}
else
{
printf(" | 学号 姓名 1 2 3 4 5 6 7 8 9 总分 平均分 | \n");
printf(" | %10s %-6s %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d | \n",student[j].id,student[j].name,student[j].n1,student[j].n2,student[j].n3,student[j].n4,student[j].n5,student[j].n6,student[j].n7,student[j].n8,student[j].n9,student[i].ping,student[i].zong);
}
}
}
}
void fail(void)
{
int i;
printf("有不及格成绩的学生为:\n");
for(i=0;i<man;i++)
{
if(student[i].n1<60||student[i].n2<60||student[i].n3<60||student[i].n4<60||student[i].n5<60||student[i].n6<60||student[i].n7<60||student[i].n8<60||student[i].n9<60)
{
printf(" | %10s %-6s %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d | \n",student[i].id,student[i].name,student[i].n1,student[i].n2,student[i].n3,student[i].n4,student[i].n5,student[i].n6,student[i].n7,student[i].n8,student[i].n9,student[i].ping,student[i].zong);
}
}
}
void compositor(void)
{
int i,k;
char m;
printf("请选择干什么排序:\n");
printf("1.成绩1\n");
printf("2.成绩2\n");
printf("3.成绩3\n");
printf("4.成绩4\n");
printf("5.成绩5\n");
printf("6.成绩6\n");
printf("7.成绩7\n");
printf("8.成绩8\n");
printf("9.成绩9\n");
printf("0.总成绩或平均成绩\n");
scanf("%s",&m);
if(m=='0')
{
for(k=man;k>0;k--)
{
for(i=0;i<k;i++)
{
if(student[i].zong<student[i+1].zong)
{
temp=student[i];
student[i]=student[i+1];
student[i+1]=temp;
}
}
}
}
else if(m=='1')
{
for(k=man;k>0;k--)
{
for(i=0;i<k;i++)
{
if(student[i].n1<student[i+1].n1)
{
temp=student[i];
student[i]=student[i+1];
student[i+1]=temp;
}
}
}
}
else if(m=='2')
{
for(k=man;k>0;k--)
{
for(i=0;i<k;i++)
{
if(student[i].n2<student[i+1].n2)
{
temp=student[i];
student[i]=student[i+1];
student[i+1]=temp;
}
}
}
}
else if(m=='3')
{
for(k=man;k>0;k--)
{
for(i=0;i<k;i++)
{
if(student[i].n3<student[i+1].n3)
{
temp=student[i];
student[i]=student[i+1];
student[i+1]=temp;
}
}
}
}
else if(m=='4')
{
for(k=man;k>0;k--)
{
for(i=0;i<k;i++)
{
if(student[i].n4<student[i+1].n4)
{
temp=student[i];
student[i]=student[i+1];
student[i+1]=temp;
}
}
}
}
else if(m=='5')
{
for(k=man;k>0;k--)
{
for(i=0;i<k;i++)
{
if(student[i].n5<student[i+1].n5)
{
temp=student[i];
student[i]=student[i+1];
student[i+1]=temp;
}
}
}
}
else if(m=='6')
{
for(k=man;k>0;k--)
{
for(i=0;i<k;i++)
{
if(student[i].n6<student[i+1].n6)
{
temp=student[i];
student[i]=student[i+1];
student[i+1]=temp;
}
}
}
}
else if(m=='7')
{
for(k=man;k>0;k--)
{
for(i=0;i<k;i++)
{
if(student[i].n7<student[i+1].n7)
{
temp=student[i];
student[i]=student[i+1];
student[i+1]=temp;
}
}
}
}
else if(m=='8')
{
for(k=man;k>0;k--)
{
for(i=0;i<k;i++)
{
if(student[i].n8<student[i+1].n8)
{
temp=student[i];
student[i]=student[i+1];
student[i+1]=temp;
}
}
}
}
else if(m=='9')
{
for(k=man;k>0;k--)
{
for(i=0;i<k;i++)
{
if(student[i].n9<student[i+1].n9)
{
temp=student[i];
student[i]=student[i+1];
student[i+1]=temp;
}
}
}
}
else
printf("无此功能\n");
}
void raise(void)
{
printf("请输入添加人的学号:\n");
scanf("%s",&student[man].id);
printf("请输入添加人的姓名:\n");
scanf("%s",&student[man].name);
printf("请输入添加人的成绩1:\n");
scanf("%d",&student[man].n1);
printf("请输入添加人的成绩2:\n");
scanf("%d",&student[man].n2);
printf("请输入添加人的成绩3:\n");
scanf("%d",&student[man].n3);
printf("请输入添加人的成绩4:\n");
scanf("%d",&student[man].n4);
printf("请输入添加人的成绩5:\n");
scanf("%d",&student[man].n5);
printf("请输入添加人的成绩6:\n");
scanf("%d",&student[man].n6);
printf("请输入添加人的成绩7:\n");
scanf("%d",&student[man].n7);
printf("请输入添加人的成绩8:\n");
scanf("%d",&student[man].n8);
printf("请输入添加人的成绩9:\n");
scanf("%d",&student[man].n9);
student[man].zong=student[man].n1+student[man].n2+student[man].n3+student[man].n4+student[man].n5+student[man].n6+student[man].n7+student[man].n8+student[man].n9;
student[man].ping=student[man].zong/9;
man=man+1;
}
void alter(void)
{
int i;
char id[10];
printf("请输入要修改人的学号:\n");
scanf("%s",&id);
for(i=0;i<man;i++)
{
if(strcmp(student[i].id,id)==0)
{
j=i;
break;
}

j=-1;

}
if(j==-1)
{
printf("无此人\n");
}
else
{
printf("请输入要修改为的学号:\n");
scanf("%s",&student[j].id);
printf("请输入要修改为的姓名:\n");
scanf("%s",&student[j].name);
printf("请输入要修改为的成绩1:\n");
scanf("%d",&student[j].n1);
printf("请输入要修改为的成绩2:\n");
scanf("%d",&student[j].n2);
printf("请输入要修改为的成绩3:\n");
scanf("%d",&student[j].n3);
printf("请输入要修改为的成绩4:\n");
scanf("%d",&student[j].n4);
printf("请输入要修改为的成绩5:\n");
scanf("%d",&student[j].n5);
printf("请输入要修改为的成绩6:\n");
scanf("%d",&student[j].n6);
printf("请输入要修改为的成绩7:\n");
scanf("%d",&student[j].n7);
printf("请输入要修改为的成绩8:\n");
scanf("%d",&student[j].n8);
printf("请输入要修改为的成绩9:\n");
scanf("%d",&student[j].n9);
student[j].zong=student[j].n1+student[j].n2+student[j].n3+student[j].n4+student[j].n5+student[j].n6+student[j].n7+student[j].n8+student[j].n9;
student[j].ping=student[j].zong/9;
}
}
void deletes()
{
int i,k;
char id[10];
printf("请输入要删除人的学号:\n");
scanf("%s",&id);
for(i=0;i<man;i++)
{
if(strcmp(student[i].id,id)==0)
{
j=i;
break;
}

j=-1;

}
if(j==-1)
{
printf("无此人\n");
}
else
{
for(k=j;k<man;k++)
{
student[j]=student[j+1];
j=j+1;
}
man=man-1;
}
}
void menu(void)
{
int i;
printf("\n");
for(i=0;i<10;i++)
printf(" ");
for(i=0;i<60;i++)
printf("*");
for(i=0;i<9;i++)
printf(" ");
printf("\n");
for(i=0;i<10;i++)
printf(" ");
printf("# 1.显示学生成绩信息 6.查询不及格学生信息 #\n");
for(i=0;i<10;i++)
printf(" ");
printf("# 2.按成绩由高到低排序 7.修改学生成绩信息 #\n");
for(i=0;i<10;i++)
printf(" ");
printf("# 3.添加学生成绩信息 8.读取文件 #\n");
for(i=0;i<10;i++)
printf(" ");
printf("# 4.删除学生成绩信息 9.保存文件 #\n");
for(i=0;i<10;i++)
printf(" ");
printf("# 5.查询学生成绩信息 -. 另存为 #\n");
for(i=0;i<10;i++)
printf(" ");
printf("# +.退出 #\n");
for(i=0;i<10;i++)
printf(" ");
for(i=0;i<60;i++)
printf("*");
for(i=0;i<9;i++)
printf(" ");
printf("\n");
}
int main(void)
{
char i;
read();
menu();
while(1)
{
printf("请输入要选择的需要功能的序列号(输入0显示菜单):\n");
scanf("%s",&i);
if(i=='1')
{
print();
}
else if(i=='2')
{
compositor();
print();
}
else if(i=='3')
{
raise();
print();
}
else if(i=='4')
{
deletes();
print();
}
else if(i=='5')
{
inquiry();
}
else if(i=='6')
{
fail();
}
else if(i=='7')
{
alter();
print();
}
else if(i=='8')
{
read();
}
else if(i=='9')
{
write();
}
else if(i=='0')
{
menu();
}
else if(i=='+')
{
break;
}
else if(i=='-')
{
save();
}
else
{
printf("无此功能,请重新输入序列号\n");
}
}
return 0;
}
记事本文件:你可以随意起名,但要放在和程序同目录
0615438101 顾佳 44 67 72 60 66 65 93 82 67
0615438103 金一宇 60 77 75 75 78 77 97 74 76
0615438104 李阳涛 50 76 66 73 74 80 92 89 74
0615438105 马凯 66 76 77 66 75 72 95 82 75
0615438106 史超 47 71 65 61 85 72 89 83 70
0615438108 徐磊 60 75 66 80 76 80 92 68 74
0615438109 杨浩 60 81 70 91 83 72 93 72 78
0615438110 于泽 61 75 78 70 87 73 84 92 77
0615438111 张昊 60 71 57 82 72 63 86 38 67
0615438112 张政 60 67 69 80 66 61 87 88 73
0615438114 周艨 61 69 71 38 74 77 76 89 67
0615438131 张楠 86 74 72 90 80 81 97 80 84
0615438132 王凡 29 68 48 35 46 76 88 62 54

Ⅹ 用C语言编写一个学生管理系统。

概述

  • 单纯只用多个数组管理学生成绩信息,不使用结构体,该程序最主要的难点是依据学号或总成绩对学生信息进行排序,借助了临时数组来标记排好序的下标。

  • 运行结果如下:

输入数据:

贴上代码(有点多)

#include <stdio.h>

#include <stdlib.h> //exit函数头文件

#include <string.h> //字符串相关操作头文件

#define MAX_STUDENT 30 //最大学生数

//函数声明,本程序共10个子函数,每个函数对应一个操作

void student_scanf(int n);

void student_printf(int n);

int student_find_name(int n);

int student_find_num(int n);

void student_sort_num(int n);

void student_sort_sum(int n);

int student_alter_num(int n);

int student_alter_name(int n);

int student_delete_num(int n);

int student_delete_name(int n);

//全局数组变量,用于存储学生信息

char names[MAX_STUDENT][50];

int math[MAX_STUDENT];

int english[MAX_STUDENT];

int computer[MAX_STUDENT];

int sum[MAX_STUDENT];

int num[MAX_STUDENT];

//以下变量用于学生信息数组排序,作为临时数组

int temp_num[MAX_STUDENT];

char temp_names[MAX_STUDENT][50];

int temp_math[MAX_STUDENT];

int temp_english[MAX_STUDENT];

int temp_computer[MAX_STUDENT];

int temp_sum[MAX_STUDENT];

//sort数组存储排好序的学号或姓名下标

int sort[MAX_STUDENT];

//循环全局变量

int i, j;

//main主函数

int main(void)

{

int choice,n;

while (1)

{

printf("************************************* ");

printf("欢迎使用学生成绩管理系统 ");

printf("[1] 输入所有学生信息 ");

printf("[2] 输出所有学生成绩 ");

printf("[3] 按学号查找某个学生信息 ");

printf("[4] 按姓名查找某个学生信息 ");

printf("[5] 按学号对学生排序 ");

printf("[6] 按总成绩对学生排序 ");

printf("[7] 按学号修改某个学生信息 ");

printf("[8] 按姓名修改某个学生信息 ");

printf("[9] 按学号删除某个学生信息 ");

printf("[10] 按姓名删除某个学生信息 ");

printf("[0] 退出程序 ");

printf("请输入您的选择(0 - 9):");

scanf("%d",&choice);

printf("**************************************) ");

switch (choice)

{

case 1://录入;

printf("请输入录入的学生信息数: ");

scanf("%d",&n);

student_scanf(n);

break;

case 2://输出;

student_printf(n);

break;

case 3://根据学号查找

student_find_num(n);

break;

case 4://根据姓名查找

student_find_name(n);

break;

case 5://按学号排序

student_sort_num(n);

break;

case 6://按姓名排序

student_sort_sum(n);

break;

case 7://按学号修改

student_alter_num(n);

break;

case 8://按姓名修改

student_alter_name(n);

break;

case 9://按学号删除

student_delete_num(n);

n--;

break;

case 10://按姓名删除

student_delete_name(n);

n--;

break;

case 0://退出程序

printf("退出程序 ");

printf("程序结束,谢谢使用! ");

exit(0);

default:

printf("您输入的菜单有误。请重新输入! ");

}

}

return 0;

}

//1.输入信息

void student_scanf(int n)

{

for (i = 0; i<n; ++i)

{

printf(" 请输入第%d个学生的信息: ", i + 1);

printf(" 学号:");

scanf("%d", &num[i]);

printf(" 姓名:");

scanf("%s", names[i]);

printf(" 数学成绩:");

scanf("%d", &math[i]);

printf(" 英语成绩:");

scanf("%d", &english[i]);

printf(" 计算机成绩:");

scanf("%d", &computer[i]);

//计算总成绩

sum[i] = math[i] + english[i] + computer[i];

}

}

//2.打印信息

void student_printf(int n)

{

printf(" 学号 姓名 数学成绩 英语成绩 计算机成绩 总成绩 ");

printf("---------------------------------------------------------- ");

for (i = 0; i<n; ++i)

{

printf("%d %s %d %d %d %d ", num[i], names[i], math[i], english[i], computer[i], sum[i]);

}

printf("------------------------------------------------------- ");

}

//3.按学号查找

int student_find_num(int n)

{

int nums;

int result;

printf("请输入待查找的学生学号:");

scanf("%d",&nums);

result= -1;

for (i = 0; i<n; ++i)

{

if (nums == num[i])

{

result = i;

break;

}

}

//最后判断q值

if (result == -1)

{

printf("没有该学生信息! ");

return 0;

}

else

{

//先打印表头

printf(" 学号 姓名 数学成绩 英语成绩 计算机成绩 总成绩 ");

//再打印数据

printf("%d %s %d %d %d %d ", num[result], names[result], math[result], english[result], computer[result], sum[result]);

printf("打印出查找结果! ");

}

return 1;

}

//4.用姓名查找成绩

int student_find_name(int n)

{

char name[200];

int result;

printf("请输入待查找的学生姓名:");

scanf("%s", name);

result = -1;

for (i = 0; i<n; ++i)

{

if (strcmp(name, names[i]) == 0)

{

result = i;

break;

}

}

if (result == -1)

{//未找到结果

printf("没有该学生信息! ");

return 0;

}

else//找到结果

{

printf(" 学号 姓名 数学成绩 英语成绩 计算机成绩 总成绩 ");

printf("%d %s %d %d %d %d ", num[result], names[result], math[result], english[result], computer[result], sum[result]);

printf("已完成查找! ");

}

return 1;

}

//5.按学号排序

void student_sort_num(int n)

{

int min,max;

for(i=0; i<n; ++i) //复制临时数组

{

temp_num[i] = num[i];

}

max = 0; //查找学号最大值,将其下标存至sort数组的最后一个值中

for(j=1; j<n; j++)

{

if(temp_num[max]<temp_num[j])

max = j;

}

sort[n-1] = max; //sort数组的最后一个数

for(i=0; i<n-1; ++i)

{

min = i; //查找学号最小值

for(j=0; j<n; ++j)

{

if(temp_num[min]>temp_num[j])

min = j;

}

//sort数组记录排序的学生信息的下标

sort[i] = min;

temp_num[min] = temp_num[max]; //利用临时数组将查找过的学生信息的学号设为最大值,排除查找干扰

}

for(i=0; i<n; ++i) //再复制一次临时数组

{

temp_num[i] = num[i];

strcpy(temp_names[i],names[i]);

temp_math[i] = math[i];

temp_english[i] = english[i];

temp_computer[i] = computer[i];

temp_sum[i] = sum[i];

}

for(i=0; i<n; i++) //按照下标对原数组进行修改

{

num[i] = temp_num[sort[i]];

strcpy(names[i],temp_names[sort[i]]);

math[i] = temp_math[sort[i]];

english[i] = temp_english[sort[i]];

computer[i] = temp_computer[sort[i]];

sum[i] = temp_sum[sort[i]];

}

printf("排序完毕,请按菜单键2查看排序结果! ");

return ;

}

//6.按总成绩排序

void student_sort_sum(int n)

{

int min,max;

for(i=0; i<n; ++i) //复制临时数组

{

temp_sum[i] = sum[i];

}

max = 0; //查找总成绩最大值,将其下标存至sort数组的最后一个值中

for(j=1; j<n; j++)

{

if(temp_sum[max]<temp_sum[j])

max = j;

}

sort[n-1] = max; //sort数组的最后一个数

for(i=0; i<n-1; ++i)

{

min = i; //查找总成绩最小值

for(j=0; j<n; ++j)

{

if(temp_sum[min]>temp_sum[j])

min = j;

}

//sort数组记录排序的学生信息的下标

sort[i] = min;

temp_sum[min] = temp_sum[max]; //利用临时数组将查找过的学生信息的总成绩设为最大值,排除查找干扰

}

for(i=0; i<n; ++i) //再复制一次临时数组

{

temp_num[i] = num[i];

strcpy(temp_names[i],names[i]);

temp_math[i] = math[i];

temp_english[i] = english[i];

temp_computer[i] = computer[i];

temp_sum[i] = sum[i];

}

for(i=0; i<n; i++) //按照下标对原数组进行修改

{

num[i] = temp_num[sort[i]];

strcpy(names[i],temp_names[sort[i]]);

math[i] = temp_math[sort[i]];

english[i] = temp_english[sort[i]];

computer[i] = temp_computer[sort[i]];

sum[i] = temp_sum[sort[i]];

}

printf("排序完毕,请按菜单键2查看排序结果! ");

return ;

}

//7.按学号修改学生信息

int student_alter_num(int n)

{

int nums;

int result;

printf("请输入待修改的学生学号:");

scanf("%d",&nums);

result= -1;

for (i = 0; i<n; ++i)

{

if (nums == num[i])

{

result = i;

break;

}

}

//最后判断q值

if (result == -1)

{

printf("没有该学生信息! ");

return 0;

}

else //修改信息值

{

printf("请重新输入该学生信息: ");

printf("学号: ");

scanf("%d",&num[result]);

printf("姓名: ");

scanf("%s",names[result]);

printf("数学成绩: ");

scanf("%d",&math[result]);

printf("英语成绩: ");

scanf("%d",&english[result]);

printf("计算机成绩: ");

scanf("%d",&computer[result]);

sum[result] = math[result] + english[result] + computer[result];

}

return 1;

}

//8.按姓名修改学生信息

int student_alter_name(int n)

{

char name[50];

int result;

printf("请输入待修改的学生姓名:");

scanf("%s",name);

result= -1;

for (i = 0; i<n; ++i)

{

if (strcmp(name,names[i])==0)

{

result = i;

break;

}

}

//最后判断q值

if (result == -1)

{

printf("没有该学生信息! ");

return 0;

}

else //修改信息值

{

printf("请重新输入该学生信息: ");

printf("学号: ");

scanf("%d",&num[result]);

printf("姓名: ");

scanf("%s",names[result]);

printf("数学成绩: ");

scanf("%d",&math[result]);

printf("英语成绩: ");

scanf("%d",&english[result]);

printf("计算机成绩: ");

scanf("%d",&computer[result]);

sum[result] = math[result] + english[result] + computer[result];

}

return 1;

}

//9.按学号删除学生信息

int student_delete_num(int n)

{

int nums;

int result;

printf("请输入待删除的学生学号:");

scanf("%d",&nums);

result= -1;

for (i = 0; i<n; ++i)

{

if (nums == num[i])

{

result = i;

break;

}

}

//最后判断q值

if (result == -1)

{

printf("没有该学生信息! ");

return 0;

}

else //删除当前学生信息即为将数组从result的位置依次前挪一个位置

{

for(i=result; i<n-1; ++i) //最后在main函数中,要将n的值减1

{

num[i] = num[i+1];

strcpy(names[i],names[i+1]);

math[i] = math[i+1];

english[i] = english[i+1];

computer[i] = computer[i+1];

sum[i] = sum[i+1];

}

}

return 1;

}

//10.按姓名删除学生信息

int student_delete_name(int n)

{

char name[50];

int result;

printf("请输入待删除的学生姓名:");

scanf("%s",name);

result= -1;

for (i = 0; i<n; ++i)

{

if (strcmp(name,names[i])==0)

{

result = i;

break;

}

}

//最后判断q值

if (result == -1)

{

printf("没有该学生信息! ");

return 0;

}

else //删除当前学生信息即为将数组从result的位置依次前挪一个位置

{

for(i=result; i<n-1; ++i) //最后在main函数中,要将n的值减1

{

num[i] = num[i+1];

strcpy(names[i],names[i+1]);

math[i] = math[i+1];

english[i] = english[i+1];

computer[i] = computer[i+1];

sum[i] = sum[i+1];

}

}

return 1;

}