❶ c語言課程設計英漢詞典
你好!
這個不是一句兩句就能說清的,下面為你提供電子詞典,其它要你自己想哦!
#include <windows.h>
#include <stdio.h>
#include <malloc.h>
#include <winbase.h>
#include <process.h>
void Search()
{
 char ret;
 char temp[100];
 char buffer[2];
 char result[100];
 printf("請輸入要查詢的單詞:\n");
 scanf("%s",&temp);
 buffer[0]=temp[0];
 buffer[1]='\0';
 int ret=GetPrivateProfileString(buffer,temp,0,result,100,"./date.ini");
 if(ret>0)
 printf("%s\n\n\n\n\n",result);
 else
  printf("對不起,沒有您要查找的單詞.\n\n\n\n\n");
}
void InsertItem()
{
 char temp[100];
 char buffer[2];
 char result[100];
 printf("請輸入要插入的單詞:\n");
 scanf("%s",&temp);
 printf("請輸入單詞的解釋:\n");
 getchar();
 scanf("%s",&result);
 buffer[0]=temp[0];
 buffer[1]='\0';
 int ret=WritePrivateProfileString(buffer,temp,result,"./date.ini");
 if(ret=0)
  printf("插入失敗。\n\n\n\n\n");
 else
  printf("插入成功。\n\n\n\n\n");
}
int main(int argc, char* argv[])
{
 int index;
main:
 printf("**************MENU***************\n\n");
 printf("         1 英譯漢\n");
// printf("2 漢譯英\n");
 printf("         2 插入新的詞條\n");
// printf("         3 刪除已有詞條\n");
 printf("         3 清空屏幕\n");
 printf("         4 退出\n\n");
 printf("**********************************\n");
 do{
  printf("請選擇操作(1~4):\n");
        scanf("%d",&index); /*輸入選擇項*/
    }while(index<0||index>5); /*選擇項不在0~4之間重輸*/
 switch(index)
 {
 case 1:
  Search();
  goto main;
  break;
 case 2:
  InsertItem();
  goto main;
  break;
 case 3:
  system("cls");
  goto main;
  break;
 case 4:
  return 0;
  break;
 default:
  break;
 }
 return 0;
}
❷ c語言課程設計 學生成績管理系統
#include "stdio.h" 
#include "stdlib.h" 
#include "string.h" 
int shoudsave=0; /* */ 
struct student 
{ 
char num[10];/* 學號 */ 
char name[20]; 
char class[10];
char term[2];
int ygrade;
int cgrade; 
int mgrade; 
int egrade;
int totle;
int ave; 
char neartime[10];/* 最近更新時間 */ 
};
typedef struct node 
{ 
struct student data; 
struct node *next; 
}Node,*Link;
void menu() 
{ 
printf("********************************************************************************"); 
printf("\t1登記學生資料\t\t\t\t\t2刪除學生資料\n"); 
printf("\t3查詢學生資料\t\t\t\t\t4修改學生資料\n"); 
printf("\t5保存學生資料\t\t\t\t\t0退出系統\n"); 
printf("********************************************************************************\n"); 
}
void printstart() 
{ 
printf("-----------------------------------------------------------------------\n"); 
} 
void Wrong() 
{ 
printf("\n=====>提示:輸入錯誤!\n"); 
}
void Nofind() 
{ 
printf("\n=====>提示:沒有找到該學生!\n"); 
}
void printc() /* 本函數用於輸出中文 */ 
{ 
printf(" 學號\t 姓名 班級 學期 語文成績 英語成績 數學成績 C語言成績 總分 平均分\n");
}
void printe(Node *p)/* 本函數用於輸出英文 */ 
{ 
printf("%-12s%s\t%s\t\%s\t%d\t%d\t%d\t %d\t %d\n",p->data.num,p->data.name,p->data.class,p->data.term,p->data.ygrade,p->data.egrade,p->data.mgrade,p->data.cgrade,p->data.totle,p->data.ave);
}
Node* Locate(Link l,char findmess[],char nameornum[]) /* 該函數用於定位連表中符合要求的接點,並返回該指針 */ 
{ 
Node *r; 
if(strcmp(nameornum,"num")==0) /* 按學號查詢 */
{ 
r=l->next; 
while(r!=NULL) 
{ 
if(strcmp(r->data.num,findmess)==0) 
return r; 
r=r->next; 
} 
} 
else if(strcmp(nameornum,"name")==0) /* 按姓名查詢 */
{ 
r=l->next; 
while(r!=NULL) 
{ 
if(strcmp(r->data.name,findmess)==0) 
return r; 
r=r->next; 
} 
} 
return 0; 
}
void Add(Link l) /* 增加學生 */ 
{ 
Node *p,*r,*s; 
char num[10]; 
r=l; 
s=l->next; 
while(r->next!=NULL) 
r=r->next; /* 將指針置於最末尾 */ 
while(1) 
{ 
printf("請你輸入學號(以'0'返回上一級菜單:)");
scanf("%s",num);
if(strcmp(num,"0")==0)
break; 
while(s) 
{ 
if(strcmp(s->data.num,num)==0)
{ 
printf("=====>提示:學號為'%s'的學生已經存在,若要修改請你選擇'4 修改'!\n",num); 
printstart(); 
printc(); 
printe(s); 
printstart(); 
printf("\n"); 
return; 
} 
s=s->next; 
}
p=(Node *)malloc(sizeof(Node));
strcpy(p->data.num,num); 
printf("請你輸入姓名:"); 
scanf("%s",p->data.name); 
getchar(); 
printf("請你輸入班級:");
scanf("%s",p->data.class);
getchar(); 
printf("請你輸入學期:");
scanf("%s",p->data.term);
getchar(); 
printf("請你輸入語文成績:");
scanf("%d",&p->data.ygrade);
getchar(); 
printf("請你輸入c語言成績:"); 
scanf("%d",&p->data.cgrade); 
getchar(); 
printf("請你輸入數學成績:"); 
scanf("%d",&p->data.mgrade); 
getchar(); 
printf("請你輸入英語成績:"); 
scanf("%d",&p->data.egrade); 
getchar(); 
p->data.totle=p->data.ygrade+p->data.egrade+p->data.cgrade+p->data.mgrade;
p->data.ave=p->data.totle / 3; 
/* 信息輸入已經完成 */ 
p->next=NULL; 
r->next=p; 
r=p; 
shoudsave=1;
} 
}
void Qur(Link l) /* 查詢學生 */ 
{ 
int sel; 
char findmess[20]; 
Node *p;
if(!l->next) 
{ 
printf("\n=====>提示:沒有資料可以查詢!\n"); 
return;
} 
printf("\n=====>1按學號查找\n=====>2按姓名查找\n"); 
scanf("%d",&sel); 
if(sel==1)/* 學號 */ 
{ 
printf("請你輸入要查找的學號:"); 
scanf("%s",findmess); 
p=Locate(l,findmess,"num"); 
if(p) 
{ 
printf("\t\t\t\t查找結果\n"); 
printstart(); 
printc(); 
printe(p); 
printstart(); 
} 
else 
Nofind(); 
} 
else if(sel==2) /* 姓名 */ 
{ 
printf("請你輸入要查找的姓名:"); 
scanf("%s",findmess); 
p=Locate(l,findmess,"name"); 
if(p) 
{ 
printf("\t\t\t\t查找結果\n"); 
printstart(); 
printc(); 
printe(p); 
printstart(); 
} 
else 
Nofind(); 
} 
else 
Wrong();
}
void Del(Link l) /* 刪除 */ 
{ 
int sel; 
Node *p,*r; 
char findmess[20]; 
if(!l->next) 
{ 
printf("\n=====>提示:沒有資料可以刪除!\n"); 
return; 
} 
printf("\n=====>1按學號刪除\n=====>2按姓名刪除\n"); 
scanf("%d",&sel); 
if(sel==1) 
{ 
printf("請你輸入要刪除的學號:"); 
scanf("%s",findmess); 
p=Locate(l,findmess,"num"); 
if(p) 
{ 
r=l; 
while(r->next!=p) 
r=r->next; 
r->next=p->next; 
free(p); 
printf("\n=====>提示:該學生已經成功刪除!\n"); 
shoudsave=1; 
} 
else 
Nofind(); 
} 
else if(sel==2) 
{ 
printf("請你輸入要刪除的姓名:"); 
scanf("%s",findmess); 
p=Locate(l,findmess,"name"); 
if(p) 
{ 
r=l; 
while(r->next!=p) 
r=r->next; 
r->next=p->next; 
free(p); 
printf("\n=====>提示:該學生已經成功刪除!\n"); 
shoudsave=1; 
} 
else 
Nofind(); 
} 
else 
Wrong(); 
}
void Modify(Link l) 
{ 
Node *p; 
char findmess[20]; 
if(!l->next) 
{ 
printf("\n=====>提示:沒有資料可以修改!\n"); 
return; 
} 
printf("請你輸入要修改的學生學號:"); 
scanf("%s",findmess); 
p=Locate(l,findmess,"num"); 
if(p) 
{ 
printf("請你輸入新學號(原來是%s):",p->data.num); 
scanf("%s",p->data.num);
printf("請你輸入新姓名(原來是%s):",p->data.name);
scanf("%s",p->data.name); 
getchar(); 
printf("請你輸入新班級(原來是%s):",p->data.class);
scanf("%s",p->data.class);
getch();
printf("請你輸入新學期(原來是%s):",p->data.term);
scanf("%s",p->data.term);
getchar();
printf("請你輸入新的語文成績(原來是%d分):",p->data.ygrade);
scanf("%d",&p->data.ygrade);
getchar(); 
printf("請你輸入新的c語言成績(原來是%d分):",p->data.cgrade); 
scanf("%d",&p->data.cgrade); 
getchar(); 
printf("請你輸入新的數學成績(原來是%d分):",p->data.mgrade); 
scanf("%d",&p->data.mgrade); 
getchar(); 
printf("請你輸入新的英語成績(原來是%d分):",p->data.egrade); 
scanf("%d",&p->data.egrade); 
p->data.totle=p->data.egrade+p->data.cgrade+p->data.mgrade; 
p->data.ave=p->data.totle/3; 
printf("\n=====>提示:資料修改成功!\n"); 
shoudsave=1; 
} 
else 
Nofind();
}
void Disp(Link l) 
{ 
int count=0; 
Node *p; 
p=l->next;
if(!p) 
{ 
printf("\n=====>提示:沒有資料可以顯示!\n"); 
return; 
} 
printf("\t\t\t\t顯示結果\n"); 
printstart(); 
printc(); 
printf("\n"); 
while(p) 
{ 
printe(p); 
p=p->next; 
} 
printstart(); 
printf("\n"); 
}
void Tongji(Link l) 
{ 
Node *pm,*pe,*pc,*pa; /* 用於指向不及格學生的接點 */
Node *r=l->next; 
if(!r) 
{ 
printf("\n=====>提示:沒有資料可以統計!\n"); 
return ; 
} 
pm=pe=pc=pa=r;
while(r!=NULL) 
{ 
if(r->data.ygrade<60)
pa=r;
if(r->data.cgrade<60)
pc=r; 
if(r->data.mgrade<60)
pm=r; 
if(r->data.egrade<60)
pe=r; 
r=r->next;
} 
printf("------------------------------統計結果--------------------------------\n"); 
printf("語文不及格:\t%s %d分\n",pe->data.name,pe->data.ygrade);
printf("英語不及格:\t%s %d分\n",pe->data.name,pe->data.egrade);
printf("數學不及格:\t%s %d分\n",pm->data.name,pm->data.mgrade);
printf("c語言不及格:\t%s %d分\n",pc->data.name,pc->data.cgrade);
printstart(); 
}
void Sort(Link l) 
{ 
Link ll; 
Node *p,*rr,*s;
ll=(Link)malloc(sizeof(Node)); /* 用於做新的連表 */ 
ll->next=NULL;
if(l->next==NULL) 
{ 
printf("\n=====>提示:沒有資料可以排序!\n"); 
return ; 
} 
p=l->next; 
while(p) 
{ 
s=(Node*)malloc(sizeof(Node)); /* 新建接點用於保存信息 */ 
s->data=p->data; 
s->next=NULL;
rr=ll; 
while(rr->next!=NULL && rr->next->data.totle>=p->data.totle) 
rr=rr->next; 
if(rr->next==NULL) 
rr->next=s; 
else 
{ 
s->next=rr->next; 
rr->next=s; 
} 
p=p->next; 
} 
free(l); 
l->next=ll->next; 
printf("\n=====>提示:排序已經完成!\n"); 
}
void Save(Link l) 
{ 
FILE* fp; 
Node *p; 
int flag=1,count=0; 
fp=fopen("c:\\student","wb"); 
if(fp==NULL) 
{ 
printf("\n=====>提示:重新打開文件時發生錯誤!\n"); 
exit(1); 
} 
p=l->next;
while(p) 
{ 
if(fwrite(p,sizeof(Node),1,fp)==1) 
{ 
p=p->next; 
count++; 
} 
else 
{ 
flag=0; 
break; 
} 
} 
if(flag) 
{ 
printf("\n=====>提示:文件保存成功.(有%d條記錄已經保存.)\n",count); 
shoudsave=0; 
} 
fclose(fp); 
}
void main() 
{ 
Link l;/* 連表 */ 
FILE *fp; /* 文件指針 */ 
int sel; 
char ch; 
char jian;
int count=0; 
Node *p,*r;
l=(Node*)malloc(sizeof(Node)); 
l->next=NULL; 
r=l;
fp=fopen("C:\\student","rb"); 
if(fp==NULL) 
{ 
printf("\n=====>提示:文件還不存在,是否創建?(y/n)\n"); 
scanf("%c",&jian); 
if(jian=='y'||jian=='Y') 
fp=fopen("C:\\student","wb"); 
else 
exit(0); 
} 
printf("\n=====>提示:文件已經打開,正在導入記錄......\n");
while(!feof(fp)) 
{ 
p=(Node*)malloc(sizeof(Node)); 
if(fread(p,sizeof(Node),1,fp)) /* 將文件的內容放入接點中 */ 
{ 
p->next=NULL; 
r->next=p; 
r=p; /* 將該接點掛入連中 */ 
count++; 
} 
}
fclose(fp); /* 關閉文件 */ 
printf("\n=====>提示:記錄導入完畢,共導入%d條記錄.\n",count);
while(1) 
{ 
menu(); 
printf("請你選擇操作:"); 
scanf("%d",&sel);
if(sel==0) 
{ 
if(shoudsave==1) 
{ getchar(); 
printf("\n=====>提示:資料已經改動,是否將改動保存到文件中(y/n)?\n"); 
scanf("%c",&ch); 
if(ch=='y'||ch=='Y') 
Save(l); 
} 
printf("\n=====>提示:你已經退出系統,再見!\n"); 
break; 
} 
switch(sel) 
{ 
case 1:Add(l);break; /* 增加學生 */ 
case 2:Del(l);break;/* 刪除學生 */ 
case 3:Qur(l);break;/* 查詢學生 */ 
case 4:Modify(l);break;/* 修改學生 */ 
case 5:Save(l);break;/* 保存學生 */ 
case 9:printf("\t\t\t==========幫助信息==========\n");break; 
default: Wrong();getchar();break; 
} 
} 
}
❸ c語言課程設計
字數受限,只能打這多了或看看這個http://wenku..com/view/92d3d138376baf1ffc4fad1a.html#include "stdio.h"    #include "stdlib.h"  #include "string.h"   #include "conio.h"   #include "mem.h"  #include "ctype.h"   /#include "alloc.h"  #define N 3      typedef struct z1   
{
   char no[11];
   char name[15];
   int score[N];
   float sum;
   float average;
   int order;
   struct z1 *next;
 }STUDENT;
STUDENT  *init();     
STUDENT *create();   
STUDENT *delete(STUDENT *h);  
void print(STUDENT *h);   /* 顯示所有記錄*/
void search(STUDENT *h);    /*查找*/
void save(STUDENT *h);     /*保存*/
STUDENT *load();        /*讀入記錄*/
void computer(STUDENT *h);  /*計算總分和均分*/
STUDENT *insert(STUDENT *h);   /*插入記錄*/
void append();            /*追加記錄*/
void ();            /*復制文件*/
STUDENT *sort(STUDENT *h);    /*排序*/
STUDENT *index(STUDENT *h);  /*索引*/
void total(STUDENT *h);       /*分類合計*/
int menu_select();            /*菜單函數*/
/******主函數開始*******/
main()
{
   int i;
   STUDENT *head;     /*鏈表定義頭指針*/
   head=init();          /*初始化鏈表*/
   clrscr();            /*清屏*/
   for(;;)             /*無限循環*/
   {
      switch(menu_select())     /*調用主菜單函數,返回值整數作開關語句的條件*/
      {                     /*值不同,執行的函數不同,break 不能省略*/
  case 0:head=init();break;   
case 1:head=create();break; 
  case 2:head=delete(head);break; 
  case 3:print(head);break;   /*顯示全部記錄*/
  case 4:search(head);break;  /*查找記錄*/
  case 5:save(head);break;  /*保存文件*/
  case 6:head=load(); break;  /*讀文件*/
  case 7:computer(head);break;  /*計算總分和均分*/
  case 8:head=insert(head);  break; /*插入記錄*/
  case 9:();break;    /*復制文件*/
  case 10:head=sort(head);break;  /*排序*/
  case 11:append();break;     /*追加記錄*/
  case 12:head=index(head);break;  /*索引*/
  case 13:total(head);break;   /*分類合計*/
  case 14:exit(0);       /*如菜單返回值為14程序結束*/
      }
   }
}
/*菜單函數,返回值為整數*/
menu_select()
{
   char *menu[]={"***************MENU***************",  /*定義菜單字元串數組*/
   " 0. init list",    /*初始化*/
   " 1. Enter list",   /*輸入記錄*/
   " 2. Delete a record from list",  /*從表中刪除記錄*/
   " 3. print list ",       /*顯示單鏈表中所有記錄*/
   " 4. Search record on name",   /*按照姓名查找記錄*/
   " 5. Save the file",          /*將單鏈表中記錄保存到文件中*/
   " 6. Load the file",        /*從文件中讀入記錄*/
   " 7. compute the score",    /*計算所有學生的總分和均分*/
   " 8. insert record to list ",   /*插入記錄到表中*/
   " 9.  the file to new file",   /*復制文件*/
   " 10. sort to make new file",   /*排序*/
   " 11. append  record to file",   /*追加記錄到文件中*/
   " 12. index on nomber",       /*索引*/
   " 13. total on nomber",      /*分類合計*/
   " 14. Quit"};              /*退出*/
   char s[3];       /*以字元形式保存選擇號*/
   int c,i;        /*定義整形變數*/
   gotoxy(1,25);        /*移動游標*/
   printf("press any key enter menu......\n");   /*壓任一鍵進入主菜單*/
   getch();                       /*輸入任一鍵*/
   clrscr();                     /*清屏幕*/
   gotoxy(1,1);             /*移動游標*/
   textcolor(YELLOW);   /*設置文本顯示顏色為黃色*/
   textbackground(BLUE);   /*設置背景顏色為藍色*/
   gotoxy(10,2);          /*移動游標*/
   putch(0xc9);        /*輸出左上角邊框┏*/
   for(i=1;i<44;i++)
      putch(0xcd);    /*輸出上邊框水平線*/
   putch(0xbb);            /*輸出右上角邊框  ┓*/
   for(i=3;i<20;i++)
   {
      gotoxy(10,i);putch(0xba);   /*輸出左垂直線*/
      gotoxy(54,i);putch(0xba);
   }   /*輸出右垂直線*/
   gotoxy(10,20);putch(0xc8);  /*輸出左上角邊框┗*/
   for(i=1;i<44;i++)
      putch(0xcd);      /*輸出下邊框水平線*/
   putch(0xbc);                 /*輸出右下角邊框┛*/
   window(11,3,53,19);       /* 製作顯示菜單的窗口,大小根據菜單條數設計*/
   clrscr();              /*清屏*/
   for(i=0;i<16;i++)       /*輸出主菜單數組*/
   {
      gotoxy(10,i+1);
      cprintf("%s",menu[i]);
   }
   textbackground(BLACK);   /*設置背景顏色為黑色*/
   window(1,1,80,25);       /*恢復原窗口大小*/
   gotoxy(10,21);       /*移動游標*/
   do{
      printf("\n  Enter you choice(0~14):");    /*在菜單窗口外顯示提示信息*/
      scanf("%s",s);           /*輸入選擇項*/
      c=atoi(s);            /*將輸入的字元串轉化為整形數*/
   }while(c<0||c>14);    /*選擇項不在0~14之間重輸*/
   return c;              /*返回選擇項,主程序根據該數調用相應的函數*/
}
STUDENT *init()
{
   return NULL;
}
/*創建鏈表*/
STUDENT *create()
{
   int i; int s;
   STUDENT *h=NULL,*info;  /* STUDENT指向結構體的指針*/
   for(;;)
   {
      info=(STUDENT *)malloc(sizeof(STUDENT));  /*申請空間*/
      if(!info)   /*如果指針info為空*/
      {
  printf("\nout of memory");   /*輸出內存溢出*/
  return NULL;           /*返回空指針*/
      }
      inputs("enter no:",info->no,11);   /*輸入學號並校驗*/
      if(info->no[0]=='@') break;    /*如果學號首字元為@則結束輸入*/
      inputs("enter name:",info->name,15); /*輸入姓名,並進行校驗*/
      printf("please input %d score \n",N);  /*提示開始輸入成績*/
      s=0;         /*計算每個學生的總分,初值為0*/
      for(i=0;i<N;i++)    /*N門課程循環N次*/
      {
  do{
     printf("score%d:",i+1);    /*提示輸入第幾門課程*/
     scanf("%d",&info->score[i]);    
     if(info->score[i]>100||info->score[i]<0) 
     printf("bad data,repeat input\n");
  }while(info->score[i]>100||info->score[i]<0);
  s=s+info->score[i]; 
      }
      info->sum=s;   
      info->average=(float)s/N; 
      info->order=0;    
      info->next=h;   
      h=info;       }
   return(h);   /*返回頭指針*/
}
/*輸入字元串,並進行長度驗證*/
inputs(char *prompt, char *s, int count)
{
   char p[255];
   do{
      printf(prompt);  /*顯示提示信息*/
      scanf("%s",p);        if(strlen(p)>count)printf("\n too long! \n");    }while(strlen(p)>count);
   strcpy(s,p); }
void print(STUDENT *h)
{
   int i=0;     /* 統計記錄條數*/
   STUDENT *p;  /*移動指針*/
   clrscr();     /*清屏*/
   p=h;      /*初值為頭指針*/
   printf("\n\n\n****************************STUDENT********************************\n");
   printf("|rec|nO        |      name     | sc1| sc2| sc3|   sum  |  ave  |order|\n");
   printf("|---|----------|---------------|----|----|----|--------|-------|-----|\n");
   while(p!=NULL)
   {
       i++;
       printf("|%3d |%-10s|%-15s|%4d|%4d|%4d| %4.2f | %4.2f | %3d |\n", i, p->no,p->name,p->score[0],p->score[1],
p->score[2],p->sum,p->average,p->order);
       p=p->next;
   }
   printf("**********************************end*********************************\n");
}
/*刪除記錄*/
STUDENT *delete(STUDENT *h)
{
   STUDENT *p,*q;  /*p為查找到要刪除的結點指針,q為其前驅指針*/
   char s[11];     /*存放學號*/
   clrscr();       /*清屏*/
   printf("please deleted no\n");      /*顯示提示信息*/
   scanf("%s",s);   /*輸入要刪除記錄的學號*/
   q=p=h;    /*給q和p賦初值頭指針*/
   while(strcmp(p->no,s)&&p!=NULL)   /*當記錄的學號不是要找的,或指針不為空時*/
   {
      q=p;       /*將p指針值賦給q作為p的前驅指針*/
      p=p->next;      /*將p指針指向下一條記錄*/
   }
   if(p==NULL)     /*如果p為空,說明鏈表中沒有該結點*/
      printf("\nlist no %s student\n",s);
   else       /*p不為空,顯示找到的記錄信息*/
   {
      printf("*****************************have found***************************\n");
      printf("|no        |      name     | sc1| sc2| sc3|   sum  |  ave  |order|\n");
      printf("|----------|---------------|----|----|----|--------|-------|-----|\n");
      printf("|%-10s|%-15s|%4d|%4d|%4d| %4.2f | %4.2f | %3d |\n", p->no,
       p->name,p->score[0],p->score[1],p->score[2],p->sum,
       p->average,p->order);
      printf("********************************end*******************************\n");
      getch();      /*壓任一鍵後,開始刪除*/
      if(p==h)    /*如果p==h,說明被刪結點是頭結點*/
  h=p->next;     /*修改頭指針指向下一條記錄*/
      else
  q->next=p->next; /*不是頭指針,將p的後繼結點作為q的後繼結點*/
      free(p);          /*釋放p所指結點空間*/
      printf("\n have deleted No %s student\n",s);
      printf("Don't forget save\n");/*提示刪除後不要忘記保存文件*/
   }
   return(h);      /*返回頭指針*/
}
/*查找記錄*/
void search(STUDENT *h)
{
   STUDENT *p;      char s[15];       clrscr();    
   printf("please enter name for search\n");
   scanf("%s",s);    /*輸入姓名*/
   p=h;    /*將頭指針賦給p*/
   while(strcmp(p->name,s)&&p!=NULL)  /*當記錄的姓名不是要找的,或指針不為空時*/
   p=p->next;     /*移動指針,指向下一結點*/
   if(p==NULL)         /*如果指針為空*/
      printf("\nlist no %s student\n",s);   /*顯示沒有該學生*/
   else           /*顯示找到的記錄信息*/
   {
      printf("\n\n*****************************havefound***************************\n");
      printf("|nO        |      name     | sc1| sc2| sc3|   sum  |  ave  |order|\n");
      printf("|----------|---------------|----|----|----|--------|-------|-----|\n");
      printf("|%-10s|%-15s|%4d|%4d|%4d| %4.2f | %4.2f | %3d |\n", p->no,
p->name,p->score[0],p->score[1],p->score[2],p->sum,p->average,p->order);
      printf("********************************end*******************************\n");
   }
}
/*插入記錄*/
STUDENT  *insert(STUDENT *h)
{
   STUDENT *p,*q,*info; /*p指向插入位置,q是其前驅,info指新插入記錄*/
   char s[11];  /*保存插入點位置的學號*/
   int s1,i;
   printf("please enter location  before the no\n");
   scanf("%s",s);   /*輸入插入點學號*/
   printf("\nplease new record\n");      /*提示輸入記錄信息*/
   info=(STUDENT *)malloc(sizeof(STUDENT));   /*申請空間*/
   if(!info)
   {
      printf("\nout of memory");   /*如沒有申請到,內存溢出*/
      return NULL;             /*返回空指針*/
   }
   inputs("enter no:",info->no,11); /*輸入學號*/
   inputs("enter name:",info->name,15); /*輸入姓名*/
   printf("please input %d score \n",N);  /*提示輸入分數*/
   s1=0;    /*保存新記錄的總分,初值為0*/
   for(i=0;i<N;i++)    /*N門課程循環N次輸入成績*/
   {
      do{        /*對數據進行驗證,保證在0~100之間*/
  printf("score%d:",i+1);
  scanf("%d",&info->score[i]);
  if(info->score[i]>100||info->score[i]<0)
     printf("bad data,repeat input\n");
      }while(info->score[i]>100||info->score[i]<0);
      s1=s1+info->score[i];    /*計算總分*/
   }
   info->sum=s1;    /*將總分存入新記錄中*/
   info->average=(float)s1/N;  /*計算均分*/
   info->order=0;         /*名次賦值0*/
   info->next=NULL;     /*設後繼指針為空*/
   p=h;               /*將指針賦值給p*/
   q=h;             /*將指針賦值給q*/
   while(strcmp(p->no,s)&&p!=NULL)    /*查找插入位置*/
   {
      q=p;                 /*保存指針p,作為下一個p的前驅*/
      p=p->next;          /*將指針p後移*/
   }
   if(p==NULL)      /*如果p指針為空,說明沒有指定結點*/
      if(p==h)      /*同時p等於h,說明鏈表為空*/
  h=info;   /*新記錄則為頭結點*/
      else
  q->next=info;     else
      if(p==h)           {
  info->next=p;   h=info;         }
      else
      {
  info->next=p;     q->next=info; 
      }
   printf("\n ----have inserted %s student----\n",info->name);    printf("---Don't forget save---\n");     /*提示存檔*/
   return(h);         /*返回頭指針*/
}
/*保存數據到文件*/
void save(STUDENT *h)
{
   FILE *fp;         /*定義指向文件的指針*/
   STUDENT *p;    /* 定義移動指針*/
   char outfile[10];  /*保存輸出文件名*/
   printf("Enter outfile name,for example c:\\f1\\te.txt:\n"); /*提示文件名格式信息*/
   scanf("%s",outfile);
   if((fp=fopen(outfile,"wb"))==NULL) /*為輸出打開一個二進制文件,如沒有則建立*/
   {
      printf("can not open file\n");
      exit(1);
   }
   printf("\nSaving file......\n");  /*打開文件,提示正在保存*/
   p=h;                    /*移動指針從頭指針開始*/
   while(p!=NULL)        /*如p不為空*/
   {
      fwrite(p,sizeof(STUDENT),1,fp);/*寫入一條記錄*/
      p=p->next;        /*指針後移*/
   }
   fclose(fp);      /*關閉文件*/
   printf("-----save success!!-----\n");  /*顯示保存成功*/
}
/* 從文件讀數據*/
STUDENT *load()
{
   STUDENT *p,*q,*h=NULL;    /*定義記錄指針變數*/
   FILE *fp;            /* 定義指向文件的指針*/
   char infile[10];       /*保存文件名*/
   printf("Enter infile name,for example c:\\f1\\te.txt:\n");   scanf("%s",infile);           /*輸入文件名*/
   if((fp=fopen(infile,"rb"))==NULL)   /*打開一個二進制文件,為讀方式*/
   {
      printf("can not open file\n");    /*如不能打開,則結束程序*/
      exit(1);
   }
   printf("\n -----Loading file!-----\n");
   p=(STUDENT *)malloc(sizeof(STUDENT));   /*申請空間*/
   if(!p)
   {
      printf("out of memory!\n");    /*如沒有申請到,則內存溢出*/
      return h;       /*返回空頭指針*/
   }
   h=p;         /*申請到空間,將其作為頭指針*/
   while(!feof(fp))  /*循環讀數據直到文件尾結束*/
   {
      if(1!=fread(p,sizeof(STUDENT),1,fp))
  break;  /*如果沒讀到數據,跳出循環*/
      p->next=(STUDENT *)malloc(sizeof(STUDENT));  /*為下一個結點申請空間*/
      if(!p->next)
      {
  printf("out of memory!\n");   return h;
      }
      q=p;        p=p->next;    }
   q->next=NULL;   /*最後一個結點的後繼指針為空*/
   fclose(fp);       /*關閉文件*/
   printf("---You have success read data from file!!!---\n");
   return h;   /*返回頭指針*/
}
/*追加記錄到文件*/
void append()
{
   FILE *fp;      /*定義指向文件的指針*/
   STUDENT *info;    /*新記錄指針*/
   int s1,i;
   char infile[10];    /*保存文件名*/
   printf("\nplease new record\n");
   info=(STUDENT *)malloc(sizeof(STUDENT));   /*申請空間*/
   if(!info)
   {
      printf("\nout of memory");   /*沒有申請到,內存溢出本函數結束*/
      return ;
   }
   inputs("enter no:",info->no,11);    /*調用inputs輸入學號*/
   inputs("enter name:",info->name,15); /*調用inputs輸入姓名*/
   printf("please input %d score \n",N);   /*提示輸入成績*/
   s1=0;
   for(i=0;i<N;i++)
   {
      do{
  printf("score%d:",i+1);
  scanf("%d",&info->score[i]);  /*輸入成績*/
  if(info->score[i]>100||info->score[i]<0)printf("bad data,repeat input\n");
      }while(info->score[i]>100||info->score[i]<0); /*成績數據驗證*/
      s1=s1+info->score[i];      /*求總分*/
   }
   info->sum=s1;      /*保存總分*/
   info->average=(float)s1/N;  /*求均分*/
   info->order=0;      /*名次初始值為0*/
   info->next=NULL;  /*將新記錄後繼指針賦值為空*/
   printf("Enter infile name,for example c:\\f1\\te.txt:\n");    scanf("%s",infile);         /*輸入文件名*/
   if((fp=fopen(infile,"ab"))==NULL)  /*向二進制文件尾增加數據方式打開文件*/
   {
      printf("can not open file\n");   /*顯示不能打開*/
      exit(1);             /*退出程序*/
   }
   printf("\n -----Appending record!-----\n");
   if(1!=fwrite(info,sizeof(STUDENT),1,fp))   /*寫文件操作*/
   {
      printf("-----file write error!-----\n");
      return;              /*返回*/
   }
   printf("-----append  sucess!!----\n");
   fclose(fp);       /*關閉文件*/
}
/*文件拷貝*/
void ()
{
   char outfile[10],infile[10];
   FILE *sfp,*tfp;        /*源和目標文件指針*/
   STUDENT *p=NULL;   /*移動指針*/
   clrscr();    /*清屏*/
   printf("Enter infile name,for example c:\\f1\\te.txt:\n");
   scanf("%s",infile);         /*輸入源文件名*/
   if((sfp=fopen(infile,"rb"))==NULL)   /*二進制讀方式打開源文件*/
   {
      printf("can not open input file\n");
      exit(0);
   }
   printf("Enter outfile name,for example c:\\f1\\te.txt:\n");   /*提示輸入目標文件名*/
   scanf("%s",outfile);  /*輸入目標文件名*/
   if((tfp=fopen(outfile,"wb"))==NULL)  /*二進制寫方式打開目標文件*/
   {
      printf("can not open output file \n");
      exit(0);
   }
   while(!feof(sfp))   /*讀文件直到文件尾*/
   {
      if(1!=fread(p,sizeof(STUDENT),1,sfp))
  break; /*塊讀*/
      fwrite(p,sizeof(STUDENT),1,tfp);   /*塊寫*/
   }
   fclose(sfp);    /*關閉源文件*/
   fclose(tfp);   /*關閉目標文件*/
   printf("you have success   file!!!\n");   /*顯示成功拷貝*/
}
/*排序*/
STUDENT *sort(STUDENT *h)
{
   int i=0;                  /*保存名次*/
   STUDENT *p,*q,*t,*h1;   /*定義臨時指針*/
   h1=h->next;           /*將原表的頭指針所指的下一個結點作頭指針*/
   h->next=NULL;        /*第一個結點為新表的頭結點*/
   while(h1!=NULL)    /*當原表不為空時,進行排序*/
   {
      t=h1;            /*取原表的頭結點*/
      h1=h1->next;     /*原表頭結點指針後移*/
      p=h;           /*設定移動指針p,從頭指針開始*/
      q=h;         /*設定移動指針q做為p的前驅,初值為頭指針*/
      while(t->sum<p->sum&&p!=NULL)  /*作總分比較*/
      {
  q=p;            /*待排序點值小,則新表指針後移*/
  p=p->next;
      }
      if(p==q)      /*p==q,說明待排序點值大,應排在首位*/
      {
  t->next=p;     /*待排序點的後繼為p*/
  h=t;         /*新頭結點為待排序點*/
      }
      else    /*待排序點應插入在中間某個位置q和p之間,如p為空則是尾部*/
      {
  t->next=p;   /*t的後繼是p*/
  q->next=t;    /*q的後繼是t*/
      }
   }
   p=h;               /*已排好序的頭指針賦給p,准備填寫名次*/
   while(p!=NULL)  /*當p不為空時,進行下列操作*/
   {
      i++;       /*結點序號*/
      p->order=i;   /*將名次賦值*/
      p=p->next;   /*指針後移*/
   }
   printf("sort sucess!!!\n");   /*排序成功*/
   return h;      /*返回頭指針*/
}
/*計算總分和均值*/
void computer(STUDENT *h)
{
   STUDENT *p;   /*定義移動指針*/
   int i=0;  /*保存記錄條數初值為0*/
   long s=0;   /*總分初值為0*/
   float average=0;  /*均分初值為0*/
   p=h;        /*從頭指針開始*/
   while(p!=NULL)    /*當p不為空時處理*/
   {
      s+=p->sum;    /*累加總分*/
      i++;         /*統計記錄條數*/
      p=p->next;   /*指針後移*/
   }
   average=(float)s/i;/* 求均分,均分為浮點數,總分為整數,所以做類型轉換*/
   printf("\n--All students sum score is:%ld  average is %5.2f\n",s,average);
}
/*索引*/
STUDENT *index(STUDENT *h)
{
   STUDENT *p,*q,*t,*h1;  /*定義臨時指針*/
   h1=h->next;    /*將原表的頭指針所指的下一個結點作頭指針*/
   h->next=NULL;   /*第一個結點為新表的頭結點*/
   while(h1!=NULL)  /*當原表不為空時,進行排序*/
   {
      t=h1;        /*取原表的頭結點*/
      h1=h1->next;   /*原表頭結點指針後移*/
      p=h;   /*設定移動指針p,從頭指針開始*/
      q=h;   /*設定移動指針q做為p的前驅,初值為頭指針*/
      while(strcmp(t->no,p->no)>0&&p!=NULL)  /*作學號比較*/
      {
  q=p;             p=p->next;
      }
      if(p==q)   /*p==q,      {
  t->next=p;    h=t;          }
      else           {
  t->next=p;    /*t的後繼是p*/
  q->next=t;     /*q的後繼是t*/
      }
   }
   printf("index sucess!!!\n");  /*索引排序成功*/
   return h;    /*返回頭指針*/
}
/*分類合計*/
void total(STUDENT *h)
{
   STUDENT *p,*q;   /*定義臨時指針變數*/
   char sno[9],qno[9],*ptr;    /*保存班級號的*/
   float s1,ave;        /*保存總分和均分*/
   int i;          clrscr();    /*清屏*/
   printf("\n\n  *******************Total*****************\n");
   printf("---class---------sum--------------average----\n");
   p=h;          while(p!=NULL)  
   {
      memcpy(sno,p->no,8);  /*從學號中取出班級號*/
      sno[8]='\0';          /*做字元串結束標記*/
      q=p->next;        /*將指針指向待比較的記錄*/
      s1=p->sum;      /*當前班級的總分初值為該班級的第一條記錄總分*/
      ave=p->average;  /*當前班級的均分初值為該班級的第一條記錄均分*/
      i=1;          /*統計當前班級人數*/
      while(q!=NULL)   /*內循環開始*/
      {
  memcpy(qno,q->no,8);   /*讀取班級號*/
  qno[8]='\0';     /*做字元串結束標記*/
  if(strcmp(qno,sno)==0)  /*比較班級號*/
  {
     s1+=q->sum;     /*累加總分*/
     ave+=q->average; /*累加均分*/
     i++;         /*累加班級人數*/
     q=q->next;   /*指針指向下一條記錄*/
  }
  else
     break;       }
      printf("%s     %10.2f           %5.2f\n",sno,s1,ave/i);
      if(q==NULL)
  break;         else
  p=q;     }
   printf("---------------------------------------------\n");
}
❹ c語言課程設計實例
#include<iostream.h>
void main()
{
 char a[12][9]={{'j','a','n','u','a','r','y'},{'F','e','b','r','u','a','r','y'},{'m','a','r','c','h'},{'a','p','r','i','l'},{'m','a','y'},{'j','u','n','e'},{'j','u','l','y'},{'a','u','g','u','s','t'}, {'s','e','p','t','e','m','b','e','r'},{'o','c','t','o','b','e','r'},{'n','o','v','e','m','b','e','r'},{'D','e','c','e','m','b','e','r'}},(*p)[9]=a;
 int b;
 cout<<"輸入月份:";
 cin>>b;
 cout<<"該月的英文單詞是:"<<*(p+b-1)<<endl;
}
程序寫到這分上,我都想自殺了.......用字元串應該會簡單些,可是我沒想好..只能這樣了..
❺ 請問「C語言程序設計課程設計」用英文怎麼說
c programming
❻ C語言課設:英文文章編輯
這么多條件,至少給100分吧,就寫
❼ C語言課程設計,打字訓練游戲,只訓練英文單詞,隨機讀取文章到屏幕上,單擊回車結束。
大部分功能都實現了,顯示計時和隨機讀取如果你想寫的話,你可以用getlocaltime顯示計時,隨機讀取可以隨機讀取文件或者隨機行等等
#include<stdio.h>
#include<windows.h>
#include<conio.h>
intmain()
{
FILE*fp;
chara[999]={0},b[999]={0};
inti,j,n=0,s=0;
fp=fopen("test.txt","r");
a[0]=fgetc(fp);
while(a[n]!=EOF)
{
n++;
a[n]=fgetc(fp);
}
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
printf("%c",a[j]);
printf(" ");
for(j=0;j<i;j++)
printf("%c",b[j]);
b[i]=getche();
if(a[i]==b[i])s++;
if(i!=n-1)system("cls");
}
printf(" 正確單詞個數:%d錯誤單詞個數:%d正確率:%d%% ",s,n-s,100*s/n);
fclose(fp);
return0;
}
❽ C語言課程設計
以下程序已在win-tc和tc2.0下運行通過,已加詳細注釋(本人所寫)。
/* 數據安全實用程序,加密解密簡單程序 */
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
int flag;
char encrypt(char ch,int key)/*加密函數,把字元循環移位*/
{
if(ch>='a' && ch<='z') /* 如果是小寫字母 */
    {
        ch=(ch-'a'+key%26)%26+'a'; /* 字母向後移key%26個位置,超過字母z則再從a開始向後移動 */
    }
    else if(ch>='A' && ch<='Z') /* 如果是大寫字母 */
    {  
        ch=(ch-'A'+key%26)%26+'A'; /* 字母向後移key%26個位置,超過字母Z則再從A開始向後移動 */
    }
    return ch;
}
char decrypt(char ch,int key)/*解密函數,把字元循環移位*/
{
if(ch>='a' && ch<='z') /* 如果是小寫字母 */
    {
        ch=(ch-'a'+26-key%26)%26+'a'; /* 字母向後移26-key%26個位置,超過字母z則再從a開始向後移動 */
    }
    else if(ch>='A' && ch<='Z') /* 如果是大寫字母 */
    {  
        ch=(ch-'A'+26-key%26)%26+'A'; /* 字母向後移26-key%26個位置,超過字母Z則再從A開始向後移動 */
    }
    return ch;
}
void menu()/*菜單,1.加密,2.解密,3.顯示文本文件內容*/
{
    clrscr();
    printf("\n=======================================================");
    printf("\n1.Encrypt the text file");  /* 加密文件 */
    printf("\n2.Decrypt the text file");  /* 解密文件 */
    printf("\n3.Display text file contents");/* 顯示加密或解密或未加密或解密的文件 */
    printf("\n4.Quit\n");
    printf("=========================================================\n");
    printf("Please select a item:");  /* 選擇一個菜單 */
}
void logo()/*顯示程序信息*/
{
    printf("\nwelcome to encrypt program \n ");
    return;
}
void encrypt_decrypt_File(char* infile,int key, char* outfile)  /* 加密或解密函數 */
{
    FILE *in,*out;
    char ch;
    clrscr(); /* 清屏 */
    if((in=fopen(infile,"r"))==NULL) /* 打開欲加密或解密的文件*/
    {
        printf("Can not open the infile!\n"); /* 如果打開文件失敗或文件不存在列印打開失敗信息 */
        printf("Press any key to exit!\n");
        getch();  /* 並等待任一按鍵然後退出程序 */
        exit(0);
}
    if((out=fopen(outfile,"w"))==NULL) /* 打開文件保存加密或解密後的內容*/
    {
        printf("Can not open the outfile!\n"); /* 如果打開文件失敗或文件不存在列印打開失敗信息 */
        printf("Press any key to exit!\n");  /* 並等待任一按鍵然後退出程序 */
        fclose(in);  /* 關閉輸入文件 */
        getch();     /* 等待按鍵,按任一鍵退出程序 */
        exit(0);
    }
    ch=fgetc(in); /*從文本文件中讀入字元*/
    while(ch!=EOF)/*加密或解密*/
    {
        /*如果是英文字元,則進行加密或解密,否則,不進行加密或解密處理*/
        if((ch>='a' && ch<='z' ) || (ch>='A' && ch<='Z'))
        {   if(flag==1)
                fputc(encrypt(ch,key),out);
            if(flag==2)
                fputc(decrypt(ch,key),out);
        }
        else
           fputc(ch,out);
        ch=fgetc(in);
    }
    /*關閉輸入及輸出文件*/
    fclose(in); 
    fclose(out);
}
void displayFile(char *infile) /*將文本文件的內容顯示在屏幕上*/
{
    FILE  *fp; 
    char string[81];
    if((fp=fopen(infile,"r"))==NULL) /* 以只讀方式打開文本文件 */
    {
        printf("cann't open file");exit(0); /* 如果文件不存在或打開失敗列印無法打開信息並退出程序 */
    }
    while(fgets(string,81,fp)!=NULL)
        fputs(string,stdout);     /*把所取字元串送到屏幕顯示*/
    fclose(fp); /* 關閉文件 */
}
int main()
{
    int i,n;
    char ch0,ch1;
    char infile[40],outfile[40];
    textbackground(LIGHTGRAY); /*設置背景顏色為淺灰色*/
    textcolor(BLACK); /*設置文字顏色為黑色*/
    clrscr();/*清除屏幕顯示*/
    logo(); /*顯示程序信息*/
    sleep(2); /* 延時2秒 */
    menu(); /*顯示屏幕菜單*/
    ch0=getche();/*等待用戶從鍵盤輸入,並把輸入顯示在屏幕上*/
    while(ch0!='4')
    {
        clrscr();
        if(ch0=='1') /*選擇加密功能*/
        {
            flag=1;
            printf("\nPlease input the infile to be encrypted:"); /* 輸入要加密的文件名 */
            scanf("%s",infile);  /* 該文件要和本程序放在同一個目錄下 */
            printf("Please input the encrypt key:");
            scanf("%d",&n);/*輸入加密密碼*/
            printf("Please input the outfile:"); /*輸入存放加密內容的文件名*/
            scanf("%s",outfile);                 /* 該文件可以自動創建 */
            encrypt_decrypt_File(infile,n,outfile);
            printf("\nEncrypt is over!\n");/* 加密成功 */
            sleep(1); /* 延時1秒 */
        }
        else if(ch0=='2') /*選擇解密功能*/
        {
            flag=2;
            printf("\nPlease input the infile to be decrypted:"); /* 輸入要解密的文件名 */
            scanf("%s",infile);                   /* 該文件要和本程序放在同一個目錄下 */
            printf("Please input the decrypt key:");
            scanf("%d",&n);/*輸入解密密碼,加密和解密密碼應相同*/
            printf("Please input the outfile:"); /*輸入存放解密內容的文件名*/
            scanf("%s",outfile); /* 該文件可以自動創建 */
            encrypt_decrypt_File(infile,n,outfile);
            printf("\nDecrypt is over!\n");
            sleep(1); /* 延時1秒 */
        }
        else if(ch0=='3') /*選擇顯示文本文件功能*/
        {
            printf("\nPlease input the infile to be displayed:"); /* 輸入要顯示的文件名 */
            scanf("%s",infile);
            displayFile(infile);/* 顯示文件 */
            getch();
        }
        else
        {         /*不合法輸入*/
            printf("\nplease input a valid number(1-4)\n");
            sleep(1); /* 延時1秒 */
        }
        menu();/*顯示程序菜單*/
        ch0=getche(); /*等待用戶下一次的功能選擇*/
    }
    system("cls");/*清除屏幕*/
    logo(); /*顯示程序信息*/
    printf("\nGood Bye!\n");
    sleep(2);/* 延時2秒 */
    system("pause"); /* 暫停,按任一鍵退出程序 */
    return 0;
}
❾ C語言課程設計任務書 題目:計算機輔助教學(CAI)軟體開發:教小學生學英語。 請大家幫幫忙啊,馬上要上
查收
❿ C語言課程設計—學生成績管理系統<急!!!!!>注意要求,謝謝
#include <time.h>
#include<stdio.h>
#include<conio.h>
#include <stdlib.h>
#include<string.h>
#define MAX 80
void input();
void sort();
void display();
void insert();
void del();
void average();
void find();
void save();
void read();
void del_file();
void average();
void modify();
int now_no=0;
struct student
{
 int no;
 char name[20];
 char sex[4];
 float score1;
 float score2;
 float score3;
 float sort;
 float ave;
 float sum;
};
struct student stu[MAX],*p;
main()/*主函數*/
{
 int as;
 start: printf("\n\t\t\t歡迎使用學生成績管理系統\n");
 /*一下為功能選擇模塊*/
 do
 {
  printf("\n\t\t\t\t1.錄入學員信息\n\t\t\t\t2.顯示學員信息\n\t\t\t\t3.成績排序信息\n\t\t\t\t4.添加學員信息\n\t\t\t\t5.刪除學員信息\n\t\t\t\t6.修改學員信息\n\t\t\t\t7.查詢學員信息\n\t\t\t\t8.從文件讀入學員信息\n\t\t\t\t9.刪除文件中學員信息\n\t\t\t\t10.保存學員信息\n\t\t\t\t11.退出\n");
  printf("\t\t\t\t選擇功能選項:");
  fflush(stdin);
  scanf("%d",&as);
  switch(as)
  {
   case 1:system("cls");input();break;
   case 2:system("cls");display();break;
   case 3:system("cls");sort();break;
   case 4:system("cls");insert();break;
   case 5:system("cls");del();break;
   case 6:system("cls");modify();break;
   case 7:system("cls");find();break;
   case 8:system("cls");read();break;
   case 9:system("cls");del_file();break;
   case 10:system("cls");save();break;
   case 11:system("exit");exit(0);
   default:system("cls");goto start;
  }
 }while(1);
 /*至此功能選擇結束*/
}
void input()/*原始數據錄入模塊*/
{
 int i=0;
 char ch;
 do
 {
  printf("\t\t\t\t1.錄入學員信息\n輸入第%d個學員的信息\n",i+1);
  printf("\n輸入學生編號:");
  scanf("%d",&stu[i].no);
  fflush(stdin);
  printf("\n輸入學員姓名:");
  fflush(stdin);
  gets(stu[i].name);
  printf("\n輸入學員性別:");
  fflush(stdin);
  gets(stu[i].sex);
  printf("\n輸入學員成績1:");
  fflush(stdin);
  scanf("%f",&stu[i].score1);
  printf("\n輸入學員成績2:");
  fflush(stdin);
  scanf("%f",&stu[i].score2);
  printf("\n輸入學員成績3:");
  fflush(stdin);
  scanf("%f",&stu[i].score3);
  printf("\n\n");
  i++;
  now_no=i;
  printf("是否繼續輸入?(Y/N)");
  fflush(stdin);
  ch=getch();
  system("cls");
 }
 while(ch!='n'&&ch!='N');
 system("cls");
}
void sort()/*排序數據函數*/
{
 struct student temp;
 int i,j;
 average();
 for(i=1;i<now_no;i++)
 {
  for(j=1;j<=now_no-i;j++)
  {
   if(stu[j-1].ave<stu[j].ave)
   {
 temp=stu[j];
    stu[j]=stu[j-1];
    stu[j-1]=temp;
   }
  }
 }
}
void display()/*顯示數據函數*/
{
 int i;
 char as;
 average();
 do
 {
  printf("\t\t\t班級學員信息列表\n");
  printf("\t編號\t姓名\t性別\t成績1\t成績2\t成績3\t平均值\n");
  for(i=0;i<now_no&&stu[i].name[0];i++)printf("\t%d\t%s\t%s\t%.2f\t%.2f\t%.2f\t%.2f\n",stu[i].no,stu[i].name,stu[i].sex,stu[i].score1,stu[i].score2,stu[i].score3,stu[i].ave);
  printf("\t\t按任意鍵返回主菜單.");
  fflush(stdin);
  as=getch();
 }
 while(!as);
 system("cls");
}
void insert()/*插入數據函數*/
{
 char ch;
 do
 {
  printf("\n\t\t輸入新插入學員隊信息\n");
  printf("\n輸入學生編號:");
  scanf("%d",&stu[now_no].no);
  fflush(stdin);
  printf("\n輸入學員姓名:");
  fflush(stdin);
  gets(stu[now_no].name);
  printf("\n輸入學員性別:");
  fflush(stdin);
  gets(stu[now_no].sex);
  printf("\n輸入學員成績1:");
  fflush(stdin);
  scanf("%f",&stu[now_no].score1);
  printf("\n輸入學員成績2:");
  fflush(stdin);
  scanf("%f",&stu[now_no].score2);
  printf("\n輸入學員成績3:");
  fflush(stdin);
  scanf("%f",&stu[now_no].score3);
  printf("\n\n");
  now_no=now_no+1;
  sort();
  printf("是否繼續輸入?(Y/N)");
  fflush(stdin);
  ch=getch();
  system("cls");
 }
 while(ch!='n'&&ch!='N');
}
void del()/*刪除數據函數*/
{
 int inum,i,j;
 printf("輸入要刪除學員的編號:");
 fflush(stdin);
 scanf("%d",&inum);
 for(i=0;i<now_no;i++)
 {
  if(stu[i].no==inum)
  {
   if(i==now_no)now_no-=1;
   else
   {
    stu[i]=stu[now_no-1];
    now_no-=1;
   }
   sort();
   break;
  }
 }
 system("cls");
}
void save()/*保存數據函數*/
{
 FILE *fp;
 int i;
 char filepath[20];
 printf("輸入要保存的文件路徑:");
 fflush(stdin);
 gets(filepath);
 if((fp=fopen(filepath,"w"))==NULL)
 {
  printf("\n保存失敗!");
  exit(0);
 }
 for(i=0;i<now_no;i++)
 {
  stu[i].sum=stu[i].score1+stu[i].score2+stu[i].score3;
  stu[i].ave=stu[i].sum/3;
  fprintf(fp,"\t%d\t%s\t%s\t%.2f\t%.2f\t%.2f\t%.2f\n",stu[i].no,stu[i].name,stu[i].sex,stu[i].score1,stu[i].score2,stu[i].score3,stu[i].ave);
 }
 fclose(fp);
  printf("學生信息已保存在%s中!\n",filepath);
 system("pause");
 system("cls");
}
void find()/*查詢函數*/
{
 int i;
 char str[20],as;
 do
 {
  printf("輸入要查詢的學生姓名:");
  fflush(stdin);
  gets(str);
  for(i=0;i<now_no;i++)
   if(!strcmp(stu[i].name,str))
     {
      printf("\t編號\t姓名\t性別\t成績1\t成績2\t成績3\t平均值\n");
      printf("\t%d\t%s\t%s\t%.2f\t%.2f\t%.2f\t%.2f\n",stu[i].no,stu[i].name,stu[i].sex,stu[i].score1,stu[i].score2,stu[i].score3,stu[i].ave);
     }
  printf("\t\t按任意鍵返回主菜單.");
  fflush(stdin);
  as=getch();
 }
 while(!as);
 system("cls");
}
void average()/*求平均數*/
{
 int i;
 for(i=0;i<now_no;i++)
  {
   stu[i].sum=stu[i].score1+stu[i].score2+stu[i].score3;
   stu[i].ave=stu[i].sum/3;
  }
}
void modify()/*修改數據函數*/
{
 int i;
 char str[20],as;
 printf("輸入要修改的學生姓名:");
 fflush(stdin);
 gets(str);
 for(i=0;i<now_no;i++)
 if(!strcmp(stu[i].name,str))
 {
  system("cls");
  printf("\n\t\t輸入新插入學員隊信息\n");
  printf("\n輸入學生編號:");
  fflush(stdin);
  scanf("%d",&stu[i].no);
  printf("\n輸入學員性別:");
  fflush(stdin);
  gets(stu[i].sex);
  printf("\n輸入學員成績1:");
  fflush(stdin);
  scanf("%f",&stu[i].score1);
  printf("\n輸入學員成績2:");
  fflush(stdin);
  scanf("%f",&stu[i].score2);
  printf("\n輸入學員成績3:");
  fflush(stdin);
  scanf("%f",&stu[i].score3);
  printf("\n\n");
  sort();
  break;
 }
 system("cls");
}
void read()
{
 FILE *fp;
 int i;
 char filepath[20];
 printf("輸入要讀入的文件路徑:");
 fflush(stdin);
 gets(filepath);
 if((fp=fopen(filepath,"r"))==NULL)
   {
    printf("找不到%s文件!\n",filepath);
    system("pause");
    exit(0);
    }
 now_no=0;
 for(i=0;i<MAX&&!feof(fp);i++)
   {
    fscanf(fp,"\t%d\t%s\t%s\t%f\t%f\t%f\t%f\n",&stu[i].no,stu[i].name,stu[i].sex,&stu[i].score1,&stu[i].score2,&stu[i].score3,&stu[i].ave);
    now_no++;
   }
 fclose(fp);
  printf("保存的在文件%s中的所有信息已經讀入!\n",filepath);
 system("pause");
 system("cls");
 }
void del_file()
{
 FILE *fp;
 char filepath[20];
 printf("輸入要刪除的文件路徑:");
 fflush(stdin);
 gets(filepath);
 fp=fopen(filepath,"w");
 fclose(fp);
 printf("保存的在文件%s中的所有信息已經刪除!\n",filepath);
 system("pause");
 system("cls");
 } 
自己改改就好了  謝謝  給分哦
