欧美大屁股bbbbxxxx,狼人大香伊蕉国产www亚洲,男ji大巴进入女人的视频小说,男人把ji大巴放进女人免费视频,免费情侣作爱视频

歡迎來到入門教程網(wǎng)!

C語言

當前位置:主頁 > 軟件編程 > C語言 >

C語言實現(xiàn)班檔案管理系統(tǒng)課程設(shè)計

來源:本站原創(chuàng)|時間:2020-01-10|欄目:C語言|點擊: 次

本文實例為大家分享了C語言班檔案管理系統(tǒng)的具體代碼,供大家參考,具體內(nèi)容如下

做的挺長時間的課程設(shè)計,當作參考吧 

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define N 20
struct student
{
 long num;
 char name[20];
 char sex[10];
 int age;
 char bz[40];
 struct student *next;
};
int i,j,n,num2,num3,age3,k,m;
char name3[20],sex3[20],bz3[20],ch;
FILE *fp;
int login() //登陸函數(shù)
{
 char key[20];
 printf("	  ********************請輸入系統(tǒng)密碼********************
");
 do
 {
 scanf("%s",key);
 if((strcmp("a",key))==0)
 {
 printf("	        password correct ,welcome !
");
 return 1; //當密碼正確時,返回1,進入系統(tǒng)
 }
 printf("	        password incorrect,please input again!
");
 }while(key!=1);//當返回值不為1時,重新輸入密碼,直到輸入真確為止
 system("cls");
}
int menu() //菜單
{
 int c;
 printf("		**********歡迎進入通訊客戶端!************

");
 printf("		|—————1.錄入學(xué)生的基本信息—————|
");
 printf("		|----------2.顯示學(xué)生的基本信息----------|
");
 printf("		|----------3.保存學(xué)生的基本信息----------|
");
 printf("		|----------4.刪除學(xué)生的基本信息----------|
");
 printf("		|----------5.修改學(xué)生的基本信息----------|
");
 printf("		|----------6.查詢學(xué)生的基本信息----------|
");
 printf("		|—————7.退出系統(tǒng)——————————|
");
 printf("		請選擇您要進行的功能(0~7) ");
 scanf("%d",&c);
 return c;
}
struct student *creat() //錄入信息函數(shù)
{
 struct student *head,*p1,*p2;
 n=0;
 p1=p2=(struct student *)malloc(sizeof(struct student));
 head=NULL;
 printf("請輸入學(xué)生信息學(xué)號,姓名,性別,年齡,備注(鍵入學(xué)生學(xué)號為0時結(jié)束)
");
 while(1) //為1表真,p2->next不為0;
 {
 scanf("%d",&p1->num);
 if(p1->num==0) //判斷學(xué)生的學(xué)號是否為0,如果為0則停止輸入數(shù)據(jù);
 {
  break;
 }
 scanf("%s%s%d%s",p1->name,p1->sex,&p1->age,p1->bz);
 n=n+1;
 if(n==1)
 {
  head=p1;
 }
 else
 {
  p2->next=p1;
 }
 p2=p1;
 p1=(struct student *)malloc(sizeof(struct student));
 }
 p2->next=NULL;
 system("cls");
 return(head);
}
void print(struct student *head) //輸出信息函數(shù)
{
 struct student *p;
 printf("		這里有 %d 個學(xué)生的數(shù)據(jù)信息
",n);
 p=head;
 if(head!=NULL)
 {
 do
 {
 printf("		學(xué)號:%d	姓名:%s	性別:%s	年齡:%d	備注:%s
",p->num,p->name,p->sex,p->age,p->bz);
 p=p->next;
 }while(p!=NULL);
 }
 else
 {
 return 0;
 }
 printf("
");
}
int save(struct student *p) //保存信息函數(shù)
{
 FILE *fp;
 if((fp=fopen("keshe.txt","wb"))==NULL)
 {
 printf("open file fail
");
 }
 fp=fopen("stud","wb");
 do
 {
 fwrite(p,sizeof(struct student),1,fp);
 p=p->next;
 }while(p!=NULL);
 printf("			保存成功!
");
 fclose(fp);
 return 0;
}
struct student *del(struct student *head)
{
 struct student *p1,*p2;
 printf("		請輸入要刪除學(xué)生的學(xué)號
");
 scanf("%d",&num2);
 p1=head;
 if(head->num==num2)
 {
 head=head->next;
 free(p1);
 n--;
 }
 else
 {
 
 p2=head;
 while(p2->num!=num2&&p2->next!=NULL)
 {
  p1=p2;
  p2=p2->next;
 }
 if(p2->num==num2)
 {
  p1->next=p2->next;
  n--;
 }
 printf("delete:%ld
",num2);
 }
 return (head);
}
int mod(struct student *head); //修改信息函數(shù)
struct student *modify(struct student *head)
{
 if(login()==0)
 {
 return 0;
 }
 else
 {
 struct student *p1;
 j=0;
 p1=(struct student *)malloc(sizeof(struct student));
 printf("			請輸入你要更改的學(xué)號
");
 scanf("%d",&num2);
 printf("			學(xué)號
");
 scanf("%d",&num3);
 printf("			姓名
");
 scanf("%s",name3);
 printf("			性別
");
 scanf("%s",sex3);
 printf("			年齡
");
 scanf("%d",&age3);
 printf("			備注
");
 scanf("%s",bz3);
 p1=head;
 if(head->num==num2)
 {
  head->num=num3;
  strcpy(head->name,name3);
  strcpy(head->sex,sex3);
  head->age=age3;
  strcpy(head->bz,bz3);
  j=1;
 }
 else
 {
  p1=head->next;
  if(p1!=NULL)
  {
  while(p1->num!=num2)
  {
   p1=p1->next;
  }
  p1->num=num2;
  strcpy(p1->name,name3);
  strcpy(p1->sex,sex3);
  p1->age=age3;
  strcpy(p1->bz,bz3);
  j=1;
  }
 }
 if(j==0)
 {
  printf("			更改失敗
");
 }
 else
 {
  printf("			更改成功
");
 }
 }
 system("cls");
 mod(head);
}
int mod(struct student *head)
{
 printf("			請選擇
");
 printf("			1:按學(xué)號修改學(xué)生信息
");
 printf("			2:輸出修改后的學(xué)生信息
");
 printf("			3:返回主菜單
");
 scanf("%d",&m);
 switch(m)
 {
 case 1:head=modify(head);break;
 case 2:print(head);break;
 case 3:menu();break;
 default:printf("			input error!
");
 mod(head);
 }
}
int find(struct student *head);
int find1(struct student *head) //以學(xué)號方式查找
{
 struct student *p1;
 p1=(struct student *)malloc(sizeof(struct student));
 printf("			請輸入你要查詢的學(xué)生學(xué)號
");
 scanf("%d",&num2);
 p1=head;
 while(p1!=NULL)
 {
 if(p1->num==num2)
 {
  k=1;
  printf("			學(xué)號:%d	姓名:%s	性別:%s	年齡:%d	備注:%s

",p1->num,p1->name,p1->sex,p1->age,p1->bz);
  break;
 }
 p1=p1->next;
 }
 if(k==0)
 {
 printf("			沒有查詢到您要找的學(xué)生信息

");
 }
 else
 {
 printf("			這就是您要找的學(xué)生信息

");
 }
 find(head);
}
int find2(struct student *head) //以姓名方式查找
{
 struct student *p1;
 p1=(struct student *)malloc(sizeof(struct student));
 printf("			請輸入您要查詢的學(xué)生姓名
");
 scanf("%s",name3);
 p1=head;
 while(p1!=NULL)
 {
 if((strcmp(p1->name,name3))==0)
 {
  k=1;
  printf("			學(xué)號:%d	姓名:%s	性別:%s	年齡:%d	備注:%s

",p1->num,p1->name,p1->sex,p1->age,p1->bz);
  break;
 }
 p1=p1->next;
 }
 if(k==0)
 {
 printf("			沒有找到該學(xué)生信息

");
 }
 else
 {
 printf("			這就是您要查詢的學(xué)生信息

");
 }
 find(head);
}
int find3(struct student *head) //以性別方式查找
{ 
 struct student *p1;
 p1=(struct student *)malloc(sizeof(struct student));
 printf("			請輸入你要查詢的學(xué)生的性別
");
 scanf("%s",sex3);
 p1=head;
 while(p1!=NULL)
 {
 if((strcmp(p1->sex,sex3))==0)
 {
  k=1;
  printf("			學(xué)號:%d	姓名:%s	性別:%s	年齡:%d	備注:%s

",p1->num,p1->name,p1->sex,p1->age,p1->bz);
  break;
 }
 p1=p1->next;
 }
 if(k==0)
 {
 printf("			沒有找到該學(xué)生信息

");
 }
 else
 {
 printf("			這就是您要查詢的學(xué)生的信息

");
 }
 find(head);
}
int find4(struct student *head) //以年齡方式查找
{
 struct student *p1;
 p1=(struct student *)malloc(sizeof(struct student));
 printf("			請輸入您要查詢的學(xué)生的年齡
");
 scanf("%d",&age3);
 p1=head;
 while(p1!=NULL)
 {
 if(p1->age==age3)
 {
  k=1;
  printf("			學(xué)號:%d	姓名:%s	性別:%s	年齡:%d	備注:%s

",p1->num,p1->name,p1->sex,p1->age,p1->bz);
  break;
 }
 p1=p1->next;
 }
 if(k==0)
 {
 printf("			沒有找到該學(xué)生的信息

");
 }
 else
 {
 printf("			這就是您要找的學(xué)生的信息

");
 }
 find(head);
}
int find(struct student *head)
{
 printf("			請選擇您要查詢學(xué)生信息的方式
");
 printf("			1:按學(xué)生學(xué)號查詢
");
 printf("			2:按學(xué)生姓名查詢
");
 printf("			3:按學(xué)生性別查詢
");
 printf("			4:按學(xué)生年齡查詢
");
 printf("			5:返回主菜單
");
 scanf("%d",&m);
 switch(m)
 {
 case 1:find1(head);break;
 case 2:find2(head);break;
 case 3:find3(head);break;
 case 4:find4(head);break;
 case 5:system("cls");menu();break;
 default:printf("			input error,please input again
");
 }
}
int main() //主函數(shù)
{
 struct student *phead;
 if(login()==0)
 {
 return 0;
 }
 
 printf("
");
 while(1)
 {
 switch(menu())
 {
 case 1:system("cls");phead=creat();break;
 case 2:system("cls");print(phead);break;
 case 3:system("cls");save(phead);break;
 case 4:system("cls");phead=del(phead);break;
 case 5:system("cls");mod(phead);break;
 case 6:system("cls");find(phead);break;
 case 7:system("cls");printf("			歡迎使用,再見!
");return 0;
 default:printf("			輸入有錯,請重新輸入
");
 }
 }
}

更多學(xué)習(xí)資料請關(guān)注專題《管理系統(tǒng)開發(fā)》。

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持我們。

網(wǎng)頁制作CMS教程網(wǎng)絡(luò)編程軟件編程腳本語言數(shù)據(jù)庫服務(wù)器

如果侵犯了您的權(quán)利,請與我們聯(lián)系,我們將在24小時內(nèi)進行處理、任何非本站因素導(dǎo)致的法律后果,本站均不負任何責(zé)任。

聯(lián)系QQ:835971066 | 郵箱:835971066#qq.com(#換成@)

Copyright © 2002-2020 腳本教程網(wǎng) 版權(quán)所有