当前位置:编程学习 > C/C++ >>

C语言程序[编程]

急求学生管理程序 要用C语言
答案:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct stud
{
long num;
char name[20];
double score;
};

typedef struct stucode
{
struct stud student ;
struct stucode *next;
}L;
void menu();
void createlist(struct stucode **r);
void out(struct stucode *r);
void search1(struct stucode *r);
void search2(struct stucode *r);
void del(struct stucode **r);
void insert(struct stucode **r);
void sort(struct stucode **r);

void main()
{
char choose;
int flag=1;
struct stucode *r=NULL;

while(flag)
{
system("cls");
menu();
choose=getchar();
switch(choose)
{
case '1':
createlist(&r);
out(r);
printf("Testing function 1\nPress any key to continue\n");
getchar();
getchar();
break;

case '2':
search1(r);
printf("Testing function 1\nPress any key to continue\n");
getchar();
getchar();
break;

case '3':
search2(r);
printf("Testing function 1\nPress any key to continue\n");
getchar();
getchar();
break;

case '4':
del(&r);
out(r);
printf("Testing function 1\nPress any key to continue\n");
getchar();
getchar();
break;

case '5':
insert(&r);
out(r);
printf("Testing function 1\nPress any key to continue\n");
getchar();
getchar();
break;

case '6':
sort(&r);
out(r);
printf("Testing function 1\nPress any key to continue\n");
getchar();
getchar();
break;

case '7':
out(r);
printf("Testing function 7\nPress any key to continue\n");
getchar();
getchar();
break;

case '0':
flag=0;
printf("The end.\n");
break;

default: printf("\nWrong Selection!(选择错误,请重选!)\n");getchar();getchar();
}
}
}
void createlist(struct stucode **r)
{
struct stucode *p,*t;
long n;
char a[20];
double s;
if(*r) *r=NULL;
printf(" \n请输入:\n 学号(请按学号升序排列) 姓名 分数 (若要结束请输入三个为零)\n");
scanf("%ld%s%lf",&n,a,&s);
if(n==0) return;

p=(L *)malloc(sizeof(L));
p->student.num=n;
strcpy(p->student.name,a);
p->student.score=s;
p->next=NULL;
*r=p;

scanf("%ld%s%lf",&n,a,&s);
你的要求是什么?不说出怎么给你出主意呢
#include"stdio.h"
#include"stdlib.h"
#include"conio.h"
struct student
{
int no;
char name[20];
float score[2];
float avg;
};

struct student input();
int display(struct student [],int);
int sort(struct student [],int);
int find(struct student [],int,int);
int query(struct student [],int);
int update(struct student [],int);
int remove(struct student [],int*);

int main()
{
struct student stu[20];
int count=0;
char sel='1',flag;
while( sel != '7')
{
system ("cls");
printf("-------------学员信息管理系统-------------\n");
printf("1.录入\n2.显示\n3.排序\n4.查询\n5.修改\n6.删除\n7.退出\n");
printf("\n请选择");
sel=getchar();
switch(sel)
{
case '1':
system("cls");
do
{
stu[count]=input();
count++;
printf("\n是否继续(y/n):");
fflush(stdin);
flag=getchar();
}
while(flag=='y'||flag=='Y');
break;
case '2':
display(stu,count);
break;
case '3':
sort(stu,count);
break;
case '4':
query(stu,count);
break;
case '5':
update(stu,count);
break;
case '6':
remove(stu,&count);
break;
}
}
}


上一个:C语言怎么调用函数
下一个:什么是C语言啊

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,