导航:首页 > 编程语言 > 学籍管理系统程序

学籍管理系统程序

发布时间:2024-05-21 12:11:58

『壹』 C语言课程设计:学生学籍管理系统。有谁有代码给我做个参考吗谢谢了,C语言和C++的都可以。

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

typedef struct stud //学生信息结构
{
long num;
char name[20];
float score;
}Stud;

typedef struct node
{
Stud student;
struct node *next;
}Node;
Node *head=NULL;
void read(void);
void inser(long b);
void print();
void find(long b);
void searchname(char *s);
Node * del(long n);
void sort(int flag);
void menu();

void main()
{
char choose;
int flag=1;

while (flag)
{
menu(); //调用功能菜单函数,显示菜单项。
printf(" 请选择:");
choose=getchar();

switch(choose)
{ 1
case '1': read(); //调用建立链表的函数;输出链表信息;
print();
printf("\nPress any key Continue ");
//getchar();
getchar();
break;
case '2': //调用按学号查找学生信息的函数;并输出查找结果信息;
long c;
printf("input the number you want to find:");
scanf("%ld",&c);
find(c);
printf("\nPress any key Continue.");
getchar();
break;
case '3':
//调用按姓名查找学生信息的函数;并输出查找结果信息;
char s[20];
printf("input the name you want to find:");
scanf("%s",s);
searchname(s);
printf("\n Press any key Continue.");
getchar();
getchar();
break;
case '4':
//调用根据学号删除某个学生信息的函数;并输出删除后的链表信息;
Node *h;
long n;
printf("input the number you want to delete:");
scanf("%ld",&n);
h=del(n);
if(h==NULL) printf("No find the student \n");
else print();
printf("\n Press any key Continue.");
getchar();
getchar();
break;
case '5':
//调用插入新的学生信息的函数;并输出插入后的链表信息;
long a;
printf("input the number for the new:\n");
scanf("%ld",&a);
inser(a); 2
print();
printf("\n Press any key Continue.");
getchar();
getchar();
break;
case '6':
//调用按分数降序排序输出的函数;并输出排序后的链表信息;
sort(1);
print();
sort(0);
printf("\nPress any key Continue.");
getchar();
getchar();
break;
case '0':
//结束程序运行!
flag=0;
printf("\n *** The End! ***\n");
break;
default: printf("\n Wrong Selection !(选择错误,重选)\n");
getchar();
}
}
}

void menu() //综合作业功能菜单
{
printf(" \n 学 生 信 息 管 理 系 统\n");
printf(" \n 菜 单\n\n");
printf(" \n 1. 建 立 链 表 并 显 示 \n");
printf(" \n 2. 查 找 某 学 号 的 学 生 信 息 \n");
printf(" \n 3. 查 找 某 姓 名 的 学 生 信 息 \n");
printf(" \n 4. 删 除 某 个 学 号 的 学 生\n");
printf(" \n 5. 插 入 新 的 学 生 信 息 \n");
printf(" \n 6. 按 分 数 降 序 排 序 输 出 \n");
printf(" \n 0. 退 出\n\n");
}

void read(void)
{
long a;
printf("input the number:");
scanf("%ld",&a);
while(a>0){ 3
inser(a);
printf("input the number:");
scanf("%ld",&a);
}
}
void inser(long b)
{

Node *last,*current,*p;
current=head;
while(current!=NULL&&b>current->student.num){
last=current;
current=current->next;
}

if(current==NULL||b<current->student.num){
printf("input the name,score:");
p=(Node *)malloc(sizeof(Node));
p->student.num=b;
scanf("%s%f",p->student.name,&p->student.score);
p->next=NULL;
if(current==head){
p->next=head;
head=p;
}
else{
p->next=current;
last->next=p;
}
}
else if(b==current->student.num)
printf("error input a different number:");

}

void print()
{
Node *p=head;
printf("学号 姓名 成绩:\n");
while(p!=NULL){
printf("%ld %s %f\n",p->student.num,p->student.name,p->student.score);
p=p->next;
} 4
printf("\n");
}
void find(long b)
{
Node *p=head;
while(p!=NULL&&b!=p->student.num)
p=p->next;
if(!p) printf("No found\n");
else {
printf("学号 姓名 成绩\n");
printf("%ld %s %f\n",p->student.num,p->student.name,p->student.score);
}

}

void searchname(char *s)
{
Node *p=head;
int flag=0;
printf("学号 姓名 成绩:\n");
while(p!=NULL)
{
if(strcmp(p->student.name,s)==0)
{
printf("%ld %s %f\n",p->student.num,p->student.name,p->student.score);
flag=1;
p=p->next;
continue;
}
else p=p->next;
}
if(!flag) printf("No find");
}
Node * del(long n)
{
Node *p=head,*last;
while(p->student.num!=n){
last=p;
p=p->next;
}
if(p==NULL) return p;
else if(p==head) head=p->next;
else last->next=p->next; 5
return head;
}
void sort(int flag)
{
/*flag==1 按分数排序 else 按学号排序*/
Node *p1,*p2,*k;
float t1;
long t2;
char s[20];
for(p1=head;p1->next;p1=p1->next)
{
k=p1;
for(p2=p1->next;p2;p2=p2->next)
if(flag==1&&k->student.score<p2->student.score||!flag&&k->student.num>p2->student.num)
k=p2;
if(k!=p1){
t1=p1->student.score;
p1->student.score=k->student.score;
k->student.score=t1;
t2=p1->student.num;
p1->student.num=k->student.num;
k->student.num=t2;
strcpy(s,p1->student.name);
strcpy(p1->student.name,k->student.name);
strcpy(k->student.name,s);
}
}
}
给你看看

阅读全文

与学籍管理系统程序相关的资料

热点内容
桌面经常出现options文件 浏览:436
成龙可以复活的那个电影叫什么 浏览:986
ugt型刀怎么编程铣外圆 浏览:972
win10主题绅士 浏览:319
苹果7p的双镜头怎么用 浏览:439
enbx文件怎么打开 浏览:632
前戏特别长的电影 浏览:348
文件管理的五大职业是指什么 浏览:351
cad桌面应用程序 浏览:998
少女卖春电影 浏览:61
如何复制word整个文件 浏览:632
和谐网站来一个 浏览:80
360wifi微信无法打开图片 浏览:185
下午我打算去看电影的英文 浏览:592
家政app有哪些优势 浏览:537
18g压缩文件如何传输 浏览:559
微信重新登陆好麻烦 浏览:439
第一次男老师和女学生电影 浏览:135
编程指令goo表示什么意思 浏览:901

友情链接