学生教务管理系统c语言

 2025-01-08 13:45:01  阅读 171  评论 0

摘要:#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].ex

#include<stdio.h>

#include<stdlib.h>

#include<conio.h>

学生教务管理系统c语言

#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语言编写一个教务管理系统 注:可以把这个程序也发我一下吗

#include<stdio.h>

#include<string.h>

#include<stdlib.h>

#include<conio.h>

#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=0i<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=1i<counti++)

{

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("nn请选择需要的服务:")

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<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")

}

以上就是关于求........: 教务处任选课管理系统C语言程序全部的内容,如果了解更多相关内容,可以关注,你们的支持是我们更新的动力!

版权声明:我们致力于保护作者版权,注重分享,被刊用文章【学生教务管理系统c语言】因无法核实真实出处,未能及时与作者取得联系,或有版权异议的,请联系管理员,我们会立即处理! 部分文章是来自自研大数据AI进行生成,内容摘自(百度百科,百度知道,头条百科,中国民法典,刑法,牛津词典,新华词典,汉语词典,国家院校,科普平台)等数据,内容仅供学习参考,不准确地方联系删除处理!;

原文链接:https://www.yxiso.com/zhishi/891496.html

发表评论:

关于我们
院校搜的目标不仅是为用户提供数据和信息,更是成为每一位学子梦想实现的桥梁。我们相信,通过准确的信息与专业的指导,每一位学子都能找到属于自己的教育之路,迈向成功的未来。助力每一个梦想,实现更美好的未来!
联系方式
电话:
地址:广东省中山市
Email:beimuxi@protonmail.com

Copyright © 2022 院校搜 Inc. 保留所有权利。 Powered by BEIMUCMS 3.0.3

页面耗时0.0621秒, 内存占用2.05 MB, 访问数据库23次

陕ICP备14005772号-15