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();
}