1. 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;
}
2. c语言课程设计:医院挂号收费管理系统
三点注意一下应该没有问题了
1结构的构造
2文件的读入和操作
3文件输出
算法的部分不难
lz好好翻翻书,静下心来,挺简单的其实
像这种问题在网络上面,一般的人都不太乐意回答
就算回答了,也是不痛不痒的,就像我一样
除非有人正好做过这道题~~
哈哈
3. 教务信息管理系统(C语言)
/* Note:Your choice is C IDE */
#include <stdio.h>
struct Student
{
int num;
char name[20];
float score[3];
float avg;
}stus[30];
void Add(float*);/*填加学员*/
void List();/*/学员详细列表 */
void Asc();/*/显示后三名学员 */
void Desc();/*/显示前三名学员*/
void Display();
void main()
{
int s;
float xxx;
while(1)
{
printf("Students System:\n");
printf("1. Add Student\n");
printf("2. Student list\n");
printf("3. Display the before Three\n");
printf("4. Display the last three NUm\n");
printf("5. Display the average\n");
printf("6. Exit\n");
printf("Please input select:\t");
scanf("%d",&s);
switch(s)
{
case 1:
Add(&xxx);
break;
case 2:
List();
break;
case 3:
Desc();
Display();
break;
case 4:
Asc();
Display();
break;
case 5:
Display();
break;
case 6:
return;
break;
default:
printf("Select Wrong!\n");
break;
}
}
}
void Add(float* p)
{
int i,k;
float sum;
char c;
for(i=0;i<30;i++)
{
printf("Input the num %d student Information:\n",i+1);
printf("Num:");
scanf("%d",&stus[i].num);
printf("Name:");
fflush(stdin);
scanf("%s",stus[i].name);
printf("Please the before three chenji:\n");
sum=0;
for(k=0;k<3;k++)
{
printf("%d:",k+1);
scanf("%f",p);
stus[i].score[k]=*p;
sum+=stus[i].score[k];
}
stus[i].avg=sum/3;
printf("Is go on?");
fflush(stdin);
scanf("%c",&c);
if(c=='n' || c=='N')
return;
}
}
void List()
{
int i,j=0;
printf("Num\tName\tChenji1\tChenji2\tChenji3\tAverage\n");
for(i=0;i<30;i++)
{
if(stus[i].num!=0)
{
printf("%d\t%s\t%.2f\t%.2f\t%.2f\t%.2f\n",stus[i].num,stus[i].name,stus[i].score[0],stus[i].score[1],stus[i].score[2],stus[i].avg);
}
}
}
void Asc()
{
int i,j;
struct Student c;
for(i=0;i<30;i++)
{ for(j=0;j<29-i;j++)
if(stus[j].avg<stus[j+1].avg)
{
c=stus[j];
stus[j]=stus[j+1];
stus[j+1]=c;
}
}
}
void Desc()
{
int i,j;
struct Student c;
for(i=0;i<30;i++)
{ for(j=0;j<29-i;j++)
if(stus[j].avg>stus[j+1].avg)
{
c=stus[j];
stus[j]=stus[j+1];
stus[j+1]=c;
}
}
}
void Display()
{
int i,d=0;
printf("Num\tName\tAverage\n");
for(i=0;i<30;i++)
{
if(stus[i].num!=0)
{
printf("%d\t%s\t%.2f\n",stus[i].num,stus[i].name,stus[i].avg);
d++;
}
if(d==3)
break;
}
}
在楼上的这位基础上稍候修改了一下,因为其在TC中不能正常编译.......
4. 用C语言做一个医院信息管理系统(HIS)
医生系统具有系统结构紧凑,效率高,实用性好,有很高的可靠性与稳定性。系统操作简便,系统提供优化的系统录入界面,可以大幅度提高输入信息的速度及准确性.
5. 求教大神:C语言课程设计报告——医院挂号系统
我给你讲下思路吧,如果实在不能自己搞定 我再帮你
1、录入功能 核心函数就用scanf 再配合循环
2、添加 这和录入差不多 只是添加的位置在最后
3、删除 可以用一条其他信息覆盖要被删掉的信息
5、修改 先用顺序查找找到要被修改的信息 然后录入要修改的部分数据
6、浏览 依次输出所有信息即可
7、编号查询 输入编号 然后顺序查找 输出 ok
8、排序 用冒泡法
6. 用c语言编写医院排队看病系统,急啊!!!求大神!!
#include <stdio.h>
#include <malloc.h>
typedef int queuetype;
queuetype num=1;
typedef struct qnode
{
queuetype data;
struct qnode *next;
} QNode; //链队结点类型
typedef struct
{
QNode *front,*rear;
} QuType;
void initlqueue(QuType *L)
{
L->front=L->rear=NULL;
}
void pushlqueue(QuType *L,queuetype e)
{
QNode *p=(QNode*)malloc(sizeof(QNode));
p->data=e;
p->next=NULL;
if(!L->front)
{
L->front=p;
}
if(L->rear)
L->rear->next=p;
L->rear=p;
num++;
}
void deletlqueue(QuType *L)
{
if(L->front)
{
QNode *p;
p=L->front;
printf("第%d位选手已经就诊!
",p->data);
L->front=p->next;
if(!p)
L->rear=NULL;
else
free(p);
}
else
{
num=0;
printf("所有的病人都已就诊完毕!
");
}
}
void showqueueperson(QuType *L)
{
QNode *p=L->front;
printf("输出所有排队者的序号:
");
while(p)
{
printf(" %d
",p->data);
p=p->next;
}
if(!L->front)
printf("病人都已经看病完成!
");
}
void quikSee(QuType*L,queuetype e)
{
QNode *p=L->front,*q,*t;
while(p&&p->data!=e)
{
t=p;
p=p->next;
}
if(p->data==e)
{
printf("find!%d号即可进行诊疗!
",p->data);
q=t->next;
if(q->next)
t->next=q->next;
if(t->next==L->rear)
t->next=L->rear=NULL; free(q);
}
else
printf("队列中无此人!无需删除操作!
");
}
//链队类型
void SeeDoctor()
{
int sel,flag=1;
QuType *qu=(QuType*)malloc(sizeof(QuType));
queuetype quik=0;
initlqueue(qu);//创建空队
while (flag==1) //循环执行
{
printf("1:排队 2:就诊 3:查看排队 4.不再排队,余下依次就诊 5:下班 请选择:");
scanf("%d",&sel);
switch(sel)
{ //排队,入队
case 1: pushlqueue(qu,num); printf("
挂号成功!
"); break;
case 2: deletlqueue(qu);
printf("
");break; //就诊,出队
case 3: showqueueperson(qu); break; //显示排队病人
case 4: {
printf("若您需要马上就诊,请输入您的号:");
scanf("%d",&quik);
quikSee(qu,quik);
printf("
");
} break; //任意顺序就诊
case 5: {
printf("抱歉!已下班,请排队的病人明天再来就诊!
");//下班,明天就医!
flag=0; //退出
break;
}
default : printf("输入错误,请从新输入!
"); continue;
}
}
}
void main()
{
SeeDoctor();
}
病人的姓名等信息就在结构体里加几个成员就行了!主要功能已经实现了!
我截张图给你吧!
7. 学生信息管理系统(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();
}