用C语言编程实现学生基本信息管理系统

作者&投稿:狐策 (若有异议请与网页底部的电邮联系)
如何用C语言编写学生信息管理系统~

参考如下学生信息管理系统的C源代码吧。
#include #include /*定义学生结构体*/struct Student{ char ID[20]; char Name[20]; float Mark1; float Mark2; float Mark3; float Average;};/*声明学生数组及学生数量*/struct Student students[1000];int num=0;/*求平均值*/float Avg(struct Student stu){ return (stu.Mark1+stu.Mark2+stu.Mark3)/3;}/*通过学号返回数组下标*/int Student_SearchByIndex(char id[]){ int i; for (i=0;i<num;i++) { if (strcmp(students[i].ID,id)==0) { return i; } } return -1;}/*通过姓名返回数组下标*/int Student_SearchByName(char name[]){ int i; for (i=0;i<num;i++) { if (strcmp(students[i].Name,name)==0) { return i; } } return -1;}/*显示单条学生记录*/void Student_DisplaySingle(int index){ printf("%10s%10s%8s%8s%8s%10s
","学号","姓名","成绩","成绩","成绩","平均成绩"); printf("-------------------------------------------------------------
"); printf("%10s%10s%8.2f%8.2f%8.2f%10.2f
",students[index].ID,students[index].Name, students[index].Mark1,students[index].Mark2,students[index].Mark3,students[index].Average);}/*插入学生信息*/void Student_Insert(){ while(1) { printf("请输入学号:"); scanf("%s",&students[num].ID); getchar(); printf("请输入姓名:"); scanf("%s",&students[num].Name); getchar(); printf("请输入成绩:"); scanf("%f",&students[num].Mark1); getchar(); printf("请输入成绩:"); scanf("%f",&students[num].Mark2); getchar(); printf("请输入成绩:"); scanf("%f",&students[num].Mark3); getchar(); students[num].Average=Avg(students[num]); num++; printf("是否继续?(y/n)"); if (getchar()=='n') { break; } }}/*修改学生信息*/void Student_Modify(){ //float mark1,mark2,mark3; while(1) { char id[20]; int index; printf("请输入要修改的学生的学号:"); scanf("%s",&id); getchar(); index=Student_SearchByIndex(id); if (index==-1) { printf("学生不存在!
"); } else { printf("你要修改的学生信息为:
"); Student_DisplaySingle(index); printf("-- 请输入新值--
"); printf("请输入学号:"); scanf("%s",&students[index].ID); getchar(); printf("请输入姓名:"); scanf("%s",&students[index].Name); getchar(); printf("请输入成绩:"); scanf("%f",&students[index].Mark1); getchar(); printf("请输入成绩:"); scanf("%f",&students[index].Mark2); getchar(); printf("请输入成绩:"); scanf("%f",&students[index].Mark3); getchar(); students[index].Average=Avg(students[index]); } printf("是否继续?(y/n)"); if (getchar()=='n') { break; } }}/*删除学生信息*/void Student_Delete(){ int i; while(1) { char id[20]; int index; printf("请输入要删除的学生的学号:"); scanf("%s",&id); getchar(); index=Student_SearchByIndex(id); if (index==-1) { printf("学生不存在!
"); } else { printf("你要删除的学生信息为:
"); Student_DisplaySingle(index); printf("是否真的要删除?(y/n)"); if (getchar()=='y') { for (i=index;i<num-1;i++) { students[i]=students[i+1];//把后边的对象都向前移动 } num--; } getchar(); } printf("是否继续?(y/n)"); if (getchar()=='n') { break; } }}/*按姓名查询*/void Student_Select(){ while(1) { char name[20]; int index; printf("请输入要查询的学生的姓名:"); scanf("%s",&name); getchar(); index=Student_SearchByName(name); if (index==-1) { printf("学生不存在!
"); } else { printf("你要查询的学生信息为:
"); Student_DisplaySingle(index); } printf("是否继续?(y/n)"); if (getchar()=='n') { break; } }}/*按平均值排序*/void Student_SortByAverage(){ int i,j; struct Student tmp; for (i=0;i<num;i++) { for (j=1;j<num-i;j++) { if (students[j-1].Average<students[j].Average) { tmp=students[j-1]; students[j-1]=students[j]; students[j]=tmp; } } }}/*显示学生信息*/void Student_Display(){ int i; printf("%10s%10s%8s%8s%8s%10s
","学号","姓名","成绩","成绩","成绩","平均成绩"); printf("-------------------------------------------------------------
"); for (i=0;i<num;i++) { printf("%10s%10s%8.2f%8.2f%8.2f%10.2f
",students[i].ID,students[i].Name, students[i].Mark1,students[i].Mark2,students[i].Mark3,students[i].Average); }}/*将学生信息从文件读出*/void IO_ReadInfo(){ FILE *fp; int i; if ((fp=fopen("Database.txt","rb"))==NULL) { printf("不能打开文件!
"); return; } if (fread(&num,sizeof(int),1,fp)!=1) { num=-1; } else { for(i=0;i<num;i++) { fread(&students[i],sizeof(struct Student),1,fp); } } fclose(fp);}/*将学生信息写入文件*/void IO_WriteInfo(){ FILE *fp; int i; if ((fp=fopen("Database.txt","wb"))==NULL) { printf("不能打开文件!
"); return; } if (fwrite(&num,sizeof(int),1,fp)!=1) { printf("写入文件错误!
"); } for (i=0;i<num;i++) { if (fwrite(&students[i],sizeof(struct Student),1,fp)!=1) { printf("写入文件错误!
"); } } fclose(fp);}/*主程序*/void main(){ int choice; IO_ReadInfo(); while(1) { /*主菜单*/ printf("
------ 学生成绩管理系统------
"); printf("1. 增加学生记录
"); printf("2. 修改学生记录
"); printf("3. 删除学生记录
"); printf("4. 按姓名查询学生记录
"); printf("5. 按平均成绩排序
"); printf("6. 退出
"); printf("请选择(1-6):"); scanf("%d",&choice); getchar(); switch(choice) { case 1: Student_Insert(); break; case 2: Student_Modify(); break; case 3: Student_Delete(); break; case 4: Student_Select(); break; case 5: Student_SortByAverage(); Student_Display(); break; case 6: exit(0); break; } IO_WriteInfo(); }}

可以参考
#include "stdio.h" /*I/O函数*/
#include "stdlib.h" /*其它说明*/
#include "string.h" /*字符串函数*/
#include "conio.h" /*屏幕操作函数*/
#include "mem.h" /*内存操作函数*/
#include "ctype.h" /*字符操作函数*/
#include "alloc.h" /*动态地址分配函数*/
struct score
{
int mingci;
char xuehao[8];
char mingzi[20];
float score[6];
}data,info[1000];
int i,j,k=0;
char temp[20],ch;
FILE *fp,*fp1;

void shuru()
{
if((fp=fopen("s_score.txt","ab+"))==NULL)
{
printf("cannot open this file.
");
getch();exit(0);
}
for(i=0;i<=1000;i++)
{
printf("
Please shuru xuehao:");
gets(data.xuehao);
printf("Please shuru mingzi:");
gets(data.mingzi);
printf("Please shuru yuwen score:");
gets(temp);data.score[0]=atof(temp);
printf("Please shuru shuxue score:");
gets(temp);data.score[1]=atof(temp);
printf("Please input yingyu score:");
gets(temp);data.score[2]=atof(temp);
printf("Please shuru wuli score:");
gets(temp);data.score[3]=atof(temp);
printf("Please shur huaxue score:");
gets(temp);data.score[4]=atof(temp);
data.score[5]=data.score[0]+data.score[1]+data.score[2]+data.score[3]+data.score[4];
fwrite(&data,sizeof(data),1,fp);
printf("another?y/n");
ch=getch();
if(ch=='n'||ch=='N')
break;
} fclose(fp);
}
void xianshi()
{
float s;int n;
if((fp=fopen("s_score.txt","rb+"))==NULL)
{
printf("Cannot reading this file.
");
exit(0);
}
for(i=0;i<=1000;i++)
{
if((fread(&info[i],sizeof(info[i]),1,fp))!=1)
break;
}
printf("
xuehao mingzi yuwen shuxue yingyu wuli huauxue zhongfen
");
for(j=0,k=1;j<i;j++,k++)
{
info[j].mingci=k;
printf("%6s %8s %3.1f %3.1f %3.1f %3.1f %3.1f %3.1f
",info[j].xuehao,info[j].mingzi,info[j].score[0],info[j].score[1],info[j].score[2],info[j].score[3],info[j].score[4],
info[j].score[5]);
}
getch();
fclose(fp);
}

void xiugai()
{
if((fp=fopen("s_score.txt","rb+"))==NULL||(fp1=fopen("temp.txt","wb+"))==NULL)
{
printf("Cannot open this file.
");
exit(0);
}
printf("
PLease shuru xiugai xuehao:");
scanf("%d",&i); getchar();
while((fread(&data,sizeof(data),1,fp))==1)
{
j=atoi(data.xuehao);
if(j==i)
{
printf("xuehao:%s
mingzi:%s
",data.xuehao,data.mingzi);
printf("Please shuru mingzi:");
gets(data.mingzi);
printf("Please shuru yuwen score:");
gets(temp);data.score[0]=atof(temp);
printf("Please shuru shuxue score:");
gets(temp);data.score[1]=atof(temp);
printf("Please input yingyu score:");
gets(temp);data.score[2]=atof(temp);
printf("Please input wuli score:");
gets(temp);data.score[3]=atof(temp);
printf("Please input huaxue score:");
gets(temp);data.score[4]=atof(temp);
data.score[5]=data.score[0]+data.score[1]+data.score[2]+data.score[3]+data.score[4];

} fwrite(&data,sizeof(data),1,fp1);
}
fseek(fp,0L,0);
fseek(fp1,0L,0);
while((fread(&data,sizeof(data),1,fp1))==1)
{
fwrite(&data,sizeof(data),1,fp);
}

fclose(fp);
fclose(fp1);
}
void chazhao()
{
if((fp=fopen("s_score.txt","rb"))==NULL)
{
printf("
Cannot open this file.
");
exit(0);
}
printf("
PLease shuru xuehao chakan:");
scanf("%d",&i);
while(fread(&data,sizeof(data),1,fp)==1)
{
j=atoi(data.xuehao);
if(i==j)
{
printf("xuehao:%s mingzi:%s
yuwen:%f
shuxue:%f
yingyu:%f
wuli:%f
huaxue:%f
",data.xuehao,data.mingzi,data.score[0],data.score[1],data.score[2],data.score[3],data.score[4],data.score[5]);
}getch();
}
}
void shanchu()
{
if((fp=fopen("s_score.txt","rb+"))==NULL||(fp1=fopen("temp.txt","wb+"))==NULL)
{
printf("
open score.txt was failed!");
getch();
exit(0);
}
printf("
Please input ID which you want to del:");
scanf("%d",&i);getchar();
while((fread(&data,sizeof(data),1,fp))==1)
{
j=atoi(data.xuehao);
if(j==i)
{

printf("Anykey will delet it.
");
getch();
continue;
}
fwrite(&data,sizeof(data),1,fp1);
}
fclose(fp);
fclose(fp1);
remove("s_score.txt");
rename("temp.txt","s_score.txt");
printf("Data delet was succesful!
");
printf("Anykey will return to main.");
getch();
}
main()
{
while(1)
{
clrscr(); /*清屏幕*/
gotoxy(1,1); /*移动光标*/
textcolor(YELLOW); /*设置文本显示颜色为黄色*/
textbackground(BLUE); /*设置背景颜色为蓝色*/
window(1,1,99,99); /* 制作显示菜单的窗口,大小根据菜单条数设计*/
clrscr();
printf("*************welcome to use student manage******************
");
printf("*************************menu********************************
");
printf("* ========================================================= *
");
printf("* 1>shuru 2>xiugai *
");
printf("* 3>shanchu 4>chazhao *
");
printf("* 5>xianshi 6>exit *
");
printf("* *
");
printf("* --------------------------------------------------------- *
");
printf(" Please input which you want(1-6):");
ch=getch();
switch(ch)
{
case '1':shuru();break;
case '2':xiugai(); break;
case '3':shanchu(); break;
case '4':chazhao(); break;
case '5':xianshi(); break;
case '6':exit(0);
default: continue;
}
}
}

以前做过的类似的一个 你拿去看看改改

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define BUFSIZE  1024
#define WORDSIZE  32
#define DESTSIZE 512
#define NR 26
struct node_st {
 struct node_st *arr[NR];
 char *str;
};
static int pos_hash(char ch)
{
 return ch - 'a';
}
static int read_file(FILE *fp, char *word, char *dest)
{
 char buf[BUFSIZE] = {}; 
 if (fgets(buf, BUFSIZE, fp) == NULL)
  return -1;
 buf[strlen(buf)-1] = 0;
 sscanf(buf, "%s %s", word, dest);
 return 0;
}
static void tree_insert(struct node_st **root, const char *word, const char *dest)
{
 struct node_st *new;
 int i;
 if (*root == NULL) {
  new = malloc(sizeof(*new)); 
  //if error
  for (i = 0; i < NR; i++)
   (new->arr)[i] = NULL;
  new->str = NULL;
  *root = new; 
 }
 if (*word == '\0') {
  (*root)->str = strdup(dest);
  return;
 }
 tree_insert(&((*root)->arr)[pos_hash(*word)], word+1, dest);
}
static char *tree_search(struct node_st *root, char *word)
{
 if (root == NULL)
  return NULL; 
 if (*word == '\0')
  return root->str;
 tree_search((root->arr)[pos_hash(*word)], word+1);
}
int main(int argc, char **argv)
{
 FILE *fp;
 struct node_st *root = NULL;
 char word[WORDSIZE] = {};
 char dest[DESTSIZE] = {};
 char *ret;
 if (argc < 3)
  return 1;
 fp = fopen(argv[1], "r");
 //if error
 while (1) {
  if (read_file(fp, word, dest) < 0)
   break;
  tree_insert(&root, word, dest);
  
  memset(word, '\0', WORDSIZE);
  memset(dest, '\0', DESTSIZE);
 }
#if 1
 if ((ret = tree_search(root, argv[2])) == NULL)
  printf("the word is wrong
");
 else
  printf("%s: %s
", argv[2], ret);
#endif
 return 0;
}

 悬赏50也来求答案。送个红包吧




帮忙用C语言编程:有10个学生,每个学生数据包括学号,姓名,四门课的成绩...
printf("所有学生信息如下(依次为学生的姓名,学号,总分,四科成绩):\\n");for(i=0;i<10;i++){ printf("%s %s %d %d %d %d %d %d\\n",b[i].name,b[i].num,b[i].a,b[i].a1,b[i].a2,b[i].a3,b[i].a4);} } int main(){ int i,n;char c;printf("依次输入学生...

用C语言结构体指针编程序实现输入十个学生的学号,期中和期末成绩,计 ...
include<iostream>#include<string> using namespace std;\/\/===<开始定义结构体>===struct combox{ int num;int mark;string name;combox *next;};\/\/===<结束定义结构体>=== \/\/===<开始定义Commonbox类>=== \/

C语言编程用数组输入5个学生的成绩求出这些学生的平均成绩,并输出所 ...
usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;namespace_118_3._4 { classProgram { staticvoidMain(string[]args){ int[]a=newint[5]{78,90,86,75,92};doubles=0;for(inti=0;i<a.Length;i++){ if(a[0]<a[i]...

C语言编程,从键盘输入10个学生的成绩,试统计出他们的成绩总和及平均值...
C语言编程,从键盘输入10个学生的成绩,试统计出他们的成绩总和及平均值,怎么操作?  我来答 1个回答 #热议# 为什么孔子像会雕刻在美最高法院的门楣之上?信必鑫服务平台 2022-11-16 · TA获得超过5008个赞 知道顶级答主 回答量:29万 采纳率:100% 帮助的人:257万 我也去答题访问个人页 展开全部...

C语言编程实现:输入10个学生的名字(不超过20个字符),按名字降序排序输出...
\/\/参考:#include <string.h>#include <stdio.h>int main(){ char name[10][20], temp[20]; int i,j; for (i = 0; i < 10; ++i){ scanf ("%s", name[i]); } for (i = 0; i < 10; ++i){ for (j = i+1; j < 10; ++j){ if (strcm...

C语言 用结构体类型数组编程实现输入5个学生的学号姓名平时成绩期中成 ...
\/*初始化*\/void initInfo (student stu[], int *stuNum) {*stuNum = 2; \/*学生人数设定*\/}\/*输入学生信息*\/void inputInfo (student stu[], int stuIndex) {int i;printf ("第%d名学生↓\\n", stuIndex+1);printf ("学号:");scanf ("%d",&stu[stuIndex].no);printf ("姓名:...

C语言编程 编写程序,对学生的考试成绩给出评定信息。
include<stdio.h>int main(void){int score=0;printf("input score: ");scanf("%d", &score );if ( score >= 90 ) printf("优秀\\n");else if ( score >= 80 ) printf("良好\\n");else if ( score >= 70 ) printf("中等\\n");else if ( score >= 60 ) printf...

编程实现:输入一组学生的姓名和成绩,根据成绩降序排名。
include <stdio.h> include <string.h> define N 3 struct student { int score;char name[20];};main(){ struct student a[N],temp;int i,j;for(i=0;i<N;i++){ printf("input the %dth student's information:\\n",i+1);printf("name:");scanf("%s",a[i].name);printf("...

请用C语言自定义函数的形式编程实现求10名学生1门课程成绩的平均分...
include <stdio.h> float ave(float *a, int n){ float r=0;int i;for(i = 0; i < n; i ++)r+=n;return r\/n;} int main(){ float a[10];int i;for(i = 0; i < 10; i ++)scanf("%f",a+i);printf("%f\\n", ave(a,10));return 0;} ...

编程实现:计算c语言期末成绩,平时成绩占比30%,期末成绩占比70%,成绩...
定义变量来存储平时成绩和期末成绩。根据平时成绩和期末成绩的占比,计算最终成绩。判断最终成绩是否及格。以下是一个简单的C语言程序示例:c复制代码 include <stdio.h> int main() { float usualScore, finalScore, totalScore;\/\/ 获取平时成绩和期末成绩 printf("请输入平时成绩:");scanf("%f", ...

长乐市13526024828: c语言学生信息管理系统 -
丹莎刻免: #include #include struct student{int no;char name[20];float score[2];float avg;};struct student input(); //单个学员信息录入void display(struct student [],int); //显示所有学员信息void sort(struct student [],int); //排序int find(struct student[],int,int); ...

长乐市13526024828: 学生信息管理系统C语言编程 -
丹莎刻免: 原发布者:xuekunlun666 用C语言实现线性表的基本操作,能创建一个基于学生信息管理的链表,至少包含数据输入、数据输出、数据处理等操作.在主函数里能实现以下功能.运行后出现一个选择提示.可选择的功能有1)创建新的学生信息...

长乐市13526024828: 如何用C语言编写学生信息管理系统 -
丹莎刻免: 参考如下学生信息管理系统的C源代码吧.#include <stdio.h>#include <string.h>/*定义学生结构体*/ struct Student { char ID[20]; char Name[20]; float Mark1; float Mark2; float Mark3; float Average; };/*声明学生数组及学生数量*/ struct Student ...

长乐市13526024828: c语言编写学生信息管理系统 -
丹莎刻免: #include"stdio.h" #define SIZE 100000 #include"string.h" #include"stdlib.h" #include"conio.h" struct student {int n; int num; char name[10]; int C; int Maths; int En; float ave; }stu[SIZE]; /*录入数据*/ void finput() { FILE *fp; int i,p; fp=fopen(...

长乐市13526024828: 学生信息管理系统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);...

长乐市13526024828: C语言学生信息管理系统
丹莎刻免: #include #define LEN sizeof(struct student) #define n 10 struct student *p[n+1]; struct student { char num[30]; char name[20]; char sex[10]; int age; char native[20]; char tele[30]; char email[30]; struct student*next; }; void main() { void chose(int a); int b;...

长乐市13526024828: C语言学生信息管理系统设计 -
丹莎刻免: [此问题的推荐答案]#include "stdio.h" #include "stdlib.h" #include "string.h" int shoudsave=0; /* */ struct student { char num[10];/* ...

长乐市13526024828: 怎样用c语言编写一个学生信息管理系统 -
丹莎刻免: 不知道你要做这个用来干什么,如果是只是练习,你最好不要用C做,因为C更适合做系统级开发,像这种应用软件的开发最好还是使用JAVA,.NET等等,

长乐市13526024828: C语言编写一个学生信息管理系统,求原代码谢谢
丹莎刻免: #include <iostream> #include "conio.h" #include "malloc.h" #include "windows.h" using namespace std; typedef struct { char name[20]; int stunum; int score; }StuElem;class StuList { private: StuElem *StuElem1; int Length; int MaxContine; ...

长乐市13526024828: C语言课程任务设计——学生信息管理系统 -
丹莎刻免: #include /*引用库函数*/ #include #include #include typedef struct /*定义结构体数组*/ ...

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 星空见康网