-
大小: 625KB文件類型: .zip金幣: 2下載: 0 次發布日期: 2021-06-15
- 語言: C/C++
- 標簽:
資源簡介
C語言 學生信息管理系統 課程設計實驗報告 源碼

代碼片段和文件信息
#include?????
#include????
#include???
#define??A??“%4ld?%4s?%4s?%4d?%4d“
#define??B??p->nump->namep->sexp->agep->score
#define??C??&p->nump->namep->sex&p->age&p->score
struct??st?????????????/*定義數據結構*/
{
????long?num;?????????/*學號*/
????char?name[20];????/*姓名*/
????char?sex[6];??????/*性別*/
????int?age;??????????/*年齡*/
????int?score;????????/*成績*/
????struct?st?*next;
};
void??append()?????/*?添加函數*/
{
????FILE?*fp;
????char?a;
????int??i=1;
????struct?st?*p*head*q;
????p=head=(struct?st?*)malloc(sizeof(struct?st));???
????fp=fopen(“信息.txt““a+“);
????while(1)
????{???
????????q=(struct?st?*)malloc(sizeof(struct?st));
printf(“\n第%d個學生的信息:\n“i++);
printf(“學號:“);
scanf(“%ld“&q->num);
printf(“姓名:“);
setbuf(stdinNULL);
gets(q->name);
printf(“性別:“);
setbuf(stdinNULL);
gets(q->sex);
printf(“年齡:“);
scanf(“%d“&q->age);
printf(“成績:“);
scanf(“%d“&q->score);
????????p->next=q;
????????p=q;
????????fprintf(fpAB);
????????printf(“繼續?(Y/N)“);
????????setbuf(stdinNULL);
????????scanf(“%c“&a);
????????if(a==‘N‘?||?a==‘n‘)
????????break;
????}
????????fclose(fp);
}
struct?st?*output()??????????????????????????????????/*輸出學生信息*/
{
????FILE?*fp;
????struct?st?*p*head*q;
????q=head=(struct?st?*)malloc(sizeof(struct?st));
????//p=(struct?st?*)malloc(sizeof(struct?st));???
????head->next=p;
????if((fp=fopen(“信息.txt““r“))==NULL)
????{
??????printf(“\n***********文件不存在!!!**********\n??????????????請創建“);
??????getchar();
??????exit(1);
????}
????while(!feof(fp))
????{
????p=(struct?st?*)malloc(sizeof(struct?st));
????fscanf(fpAC);
????printf(“學號??姓名??性別??年齡??成績“);
????printf(“\n“);
????printf(AB);
????printf(“\n“);
????p=p->next;
????}
?????fclose(fp);
getchar();getchar();
return?head;
}
void??inquire()???????????????/*查詢信息*/
{
????FILE?*fp;
????long??num;
????int??choice;
????char?name[20];
????struct?st?*p*head*q*f;
????q=head=(struct?st?*)malloc(sizeof(struct?st));?
????if((fp=fopen(“信息.txt““r“))==NULL)
????{
??????printf(“\n***********文件不存在!!!**********\n??????????????請創建“);
??????getchar();
??????exit(1);
????}
????while(!feof(fp))
????{
????p=(struct?st?*)malloc(sizeof(struct?st));
????fscanf(fpAC);
????q->next=p;
????q=p;
????}????
????q->next=NULL;
????do
????{
printf(“\n1.按學號查詢“);
printf(“\n2.按姓名查詢“);
printf(“\n0.退出查詢“);
printf(“\n請選擇:“);
scanf(“%d“&choice);
switch(choice)
{
case?1:
??????????????printf(“\n請輸入要查詢的學號:“);
??????????????scanf(“%ld“&num);
??????????????for(p=head->next;p!=NULL;p=p->next)
?????????????????if(num==p->num)
??????????????????{
???????????????????printf(“學號??姓名??性別??年齡??成績“);
???????????????????printf(“\n“);
???????????????????printf(AB);
??????????????????}
???????????????break;
case?2:
??????????????printf(“\n請輸入要查詢的姓名:“);
??????????????scanf(“%s“name);
??????????????for(p=head->next;p->next!=NULL;p=p->next)
????????????????if(strcmp(namep->name)==0)
?????????????????{
??????????????????printf(“學號??姓名??性別??年齡??成績“);
??????????????????printf(“\n“);
?
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????10307??2012-06-15?01:46??學生信息管理系統.c
?????文件??????698775??2013-12-21?14:45??C語言?學生信息管理系統?課程設計實驗報告.doc
- 上一篇:黑白點配對問題
- 下一篇:如何利用VC++自動生成Excel表格
評論
共有 條評論