文檔管理系統c課程設計
㈠ C語言課程設計 學生管理系統設計
學生管理系統設計
我幫你弄
保證能運行
Q我
㈡ c語言課程設計--班級檔案管理系統
//****************************************************************************
//**** 說明:密碼所在的文件位於c盤,文件名為1.txt。
//**** 學生基本信息最好保存在C盤,文件名為student.txt。
//****************************************************************************
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#define N 3
struct student
{
char name[10];
char no[10];
char sex;
int age;
char bnote[100];
};
void print(bool menu)//列印基本信息
{
if (!menu)
{
printf("學生基本信息錄入 ,press 1\n");
}
else
{
printf("學生基本信息顯示 ,press 2\n");
printf("學生基本信息保存 ,press 3\n");
printf("學生基本信息刪除 ,press 4\n");
printf("學生基本信息修改 ,press 5\n");
printf("學生基本信息查詢 ,press 6\n");
}
printf("退出學生信息系統 ,press 7\n");
}
bool Check(char pas[6])//密碼驗證
{
FILE *fp;
char ch;
char a[7]={" "};
int i = 0;
if ((fp=fopen("c:\\1.txt","r"))==NULL)
{
printf("打開文件失敗!\n");
exit(0);
}
ch=fgetc(fp);
while (ch!=EOF&&i<6)
{
a[i] = ch;
ch=fgetc(fp);
i++;
}
a[6] = '\0';
if (!strcmp(pas,a))
{
return true;
}
else
{
printf("密碼錯誤\n");
return false;
}
fclose(fp);
}
void GetInfo(struct student *arr,int n)//學生基本信息錄入
{
for (int i = 0;i<n;i++)
{
printf("輸入學生的基本信息:name no sex age bnote\n");
scanf("%s %s %c %d %s",arr[i].name,arr[i].no,&arr[i].sex,&arr[i].age,arr[i].bnote);
}
}
void Display(struct student* arr,int n)//學生基本信息顯示
{
printf("學生信息: Name NO Sex age Note\n");
for (int i = 0;i<n;i++)
{
printf("%15s%15s%15c%15d%15s\n",arr[i].name,arr[i].no,arr[i].sex,arr[i].age,arr[i].bnote);
}
}
void Save(struct student* arr,int n)//學生基本信息保存,保存在c:\\student.txt
{
FILE * fp;
fp= fopen("c:\\student.txt","w+");
if (fp == NULL)
{
printf("文件不存在!\n");
exit(0);
}
fwrite(arr,sizeof(struct student)*n,n,fp);
fclose(fp);
}
void Modfiy(struct student* arr,int n)//學生基本信息修改
{
char number[10];
bool flag=false;
char pass[6];
printf("請輸入密碼:\n");
scanf("%s",pass);
if (Check(pass))
{
printf("修改學生信息:\n");
printf("請輸入學號:\n");
scanf("%s",number);
for (int i =0;i<n;i++)
{
if (!strcmp(number,arr[i].no))
{
printf("infor: name no sex age note\n");
printf("%12s%12s%12c%12d%12s\n",arr[i].name,arr[i].no,
arr[i].sex,arr[i].age,arr[i].bnote);
printf("please input information:\n");
scanf("%s%s%c%d%s",arr[i].name,arr[i].no,&arr[i].sex,&arr[i].age,arr[i].bnote);
Save(arr,n);
flag = true;
}
}
if (flag == false)
{
printf("該學生不存在!:\n");
}
}
}
void Delete(struct student* arr,int n)//學生基本信息刪除
{
char number[10];
bool flag=false;
printf("Delete information:\n");
printf("please input the no:\n");
scanf("%s",number);
for (int i =0;i<n;i++)
{
if (!strcmp(number,arr[i].no))
{
strcpy(arr[i].name," ");
strcpy(arr[i].no," ");
strcpy(arr[i].bnote," ");
arr[i].sex = ' ';
arr[i].age = 0;
Save(arr,n);
flag = true;
}
}
if (flag == true)
{
printf("該學生不存在!:\n");
}
}
void Search(struct student* arr,int n)//學生基本信息查詢
{
int temp,i;
bool flag=false;
printf("---------------通過學號查詢,press 1-------------\n");
printf("---------------通過姓名查詢,press 2-----------\n");
printf("---------------通過性別查詢,press 3------------\n");
printf("---------------通過年齡查詢,press 4------------\n");
printf("---------------退出,press 5 ------------\n");
scanf("%d",&temp);
switch (temp)
{
case 1://按照學號查詢
{
char num[10];
printf("請輸入學號:\n");
scanf("%s",num);
for ( i =0;i<n;i++)
{
if (!strcmp(num,arr[i].no))
{
printf("%12s%12s%12c%12d%12s\n",arr[i].name,arr[i].no,
arr[i].sex,arr[i].age,arr[i].bnote);
flag = true;
}
}
if (!flag)
{
printf("該學生不存在.\n");
}
}
break;
case 2://按照名字查詢
{
char num[10];
printf("please input name:\n");
scanf("%s",num);
for ( i =0;i<n;i++)
{
if (!strcmp(num,arr[i].name))
{
printf("%12s%12s%12c%12d%12s",arr[i].name,arr[i].no,
arr[i].sex,arr[i].age,arr[i].bnote);
flag = true;
}
}
if (!flag)
{
printf("該學生不存在.\n");
}
}
break;
case 3://按照性別查詢
{
char ch;
printf("請輸入性別:\n");
//scanf("%c",&ch);
ch = getch();
for ( i =0;i<n;i++)
{
if (ch == arr[i].sex)
{
printf("%12s%12s%12c%12d%12s\n",arr[i].name,arr[i].no,
arr[i].sex,arr[i].age,arr[i].bnote);
flag = true;
}
}
if (!flag)
{
printf("t該學生不存在.\n");
}
}
break;
case 4://按照年齡查詢
{
char num_age;
printf("請輸入年齡:\n");
scanf("%d",&num_age);
for ( i =0;i<n;i++)
{
if (num_age == arr[i].age)
{
printf("%12s%12s%12c%12d%12s\n",arr[i].name,arr[i].no,
arr[i].sex,arr[i].age,arr[i].bnote);
flag = true;
}
}
if (!flag)
{
printf("該學生不存在.\n");
}
}
break;
default:
break;
}
}
void main()
{
struct student arr[N];
char ps[6];
bool flag =false;
printf("請輸入密碼:\n");
scanf("%s",ps);
flag = Check(ps);
if (flag)
{
int select;
print(false);
scanf("%d",&select);
while (0<select && select <7 )
{
switch (select)
{
case 1:
GetInfo(arr,N);
print(true);
break;
case 2:
Display(arr,N);
print(true);
break;
case 3:
Save(arr,N);
print(true);
break;
case 4:
Delete(arr,N);
print(true);
break;
case 5:
Modfiy(arr,N);
print(true);
break;
case 6:
Search(arr,N);
print(true);
break;
default:
break;
}
printf("請選擇:\n");
scanf("%d",&select);
}
}
}
㈢ c語言課程設計:圖書管理系統設計的基本思路是什麼
圖書管理系統主要要求可以錄入書籍,添加書目,查找書本信息,刪除或修改信息,有的還要求顯示是否被借閱等。
一般採用結構體數組,鏈表,文件操作和自定義函數。主要是需要對基礎知識掌握牢固。
先定義結構體,然後對結構體的成員進行定義,選擇數組存儲書本各種信息。錄入信息可以用for和do while循環等來做。
存放信息需要文件操作函數,比如fopen,fwrite等。
刪除和添加可以刪除節點或者增加節點。
查找之類的可以用字元串操作的各種函數實現。
附上參考源代碼
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<conio.h>
#definebooks"f:\books.txt"
#definebooksbak"f:\booksbak.txt"
structbookinfo
{
charisbn[20];
chartitle[30];
charauthor[20];
intcount;
};
structbook
{
structbookinfoonebook;
structbook*next;
};
structbook*searchBook(structbook*listptr,charisbn[])
{
while(listptr!=(structbook*)0)
if(strcmp(listptr->onebook.isbn,isbn)==0)
returnlistptr;
else
listptr=listptr->next;
return(structbook*)0;
}
voidMainSearchbook(structbook*firstptr)
{
structbook*ptr;
charisbnno[20];
printf("請輸入ISBN:");
scanf("%s",&isbnno);
ptr=searchBook(firstptr,isbnno);
if(ptr!=(structbook*)0)
{
printf("找到了!!! ");
printf("ISBN:%s ",ptr->onebook.isbn);
printf("Title:%s ",ptr->onebook.title);
printf("Author:%s ",ptr->onebook.author);
}
else
printf("sorry,notfound!!! ");
}intaddBook(structbook*listptr,structbookinfonote)
{
while(listptr->next!=0)
listptr=listptr->next;
listptr->next=(structbook*)malloc(sizeof(structbook));
listptr->next->onebook=note;
listptr->next->next=0;
return0;
}
voidMainAdd(structbook*listptr,FILE*fp)
{
intok;
structbookinfonote;
printf("請輸入ISBN:");
scanf("%s",¬e.isbn);
printf("請輸入Title:");
scanf("%s",¬e.title);
printf("請輸入Author:");
scanf("%s",¬e.author);
ok=addBook(listptr,note);
if(ok==0)
{
//將加入的圖書寫到文件中保存
fprintf(fp," %s%s%s%d",note.isbn,note.title,note.author,0);
printf("添加圖書成功!!! ");
}
else
printf("添加圖書失敗!!! ");
}
intremoveBook(structbook*listptr,charisbn[])
{
while(listptr->next!=(structbook*)0)
{
if(strcmp(listptr->next->onebook.isbn,isbn)==0)
{
listptr->next=listptr->next->next;
return0;
}
else
listptr=listptr->next;
}
return-1;
}
voidMainRemove(structbook*listptr,FILE*fp)
/************************************************************************/
/*刪除書籍函數,通過ISBN刪除鏈表節點,同時刪除文件中對應信息*/
/*刪除文件中一行,用的是笨方法,把需要的信息寫到新文件,刪除舊文件,重命名..*/
/************************************************************************/
{
charisbnno[20];
intok;
structbookinfoonebook;
printf("請輸入ISBN:");
scanf("%s",&isbnno);
ok=removeBook(listptr,isbnno);
if(!ok)
{
FILE*fpbak;
if((fpbak=fopen(booksbak,"a+"))==NULL)
printf("文件打開失敗!!! ");
fseek(fp,0,SEEK_SET);//移到文件開始
while((fscanf(fp,"%s%s%s%d ",&onebook.isbn,&onebook.title,&onebook.author,&onebook.count))!=EOF)
{
if(strcmp(onebook.isbn,isbnno)!=0)
{
fprintf(fpbak,"%s%s%s%d ",onebook.isbn,onebook.title,onebook.author,onebook.count);
}
}
fclose(fp);
fclose(fpbak);
if(remove(books))//刪除失敗返回非0
{
printf("刪除文件失敗!!! ");
return;
}
else
if(rename(booksbak,books))//重命名失敗返回非0值
{
printf("重命名失敗!!! ");
return;
}
printf("刪除成功!!! ");
}
else
printf("查無此書!!!");
}
intchoice(void)
{
intc;
printf("1.查看圖書 ");
printf("2.添加圖書 ");
printf("3.刪除圖書 ");
printf("4.退出程序 ");
printf("請選擇序號:");
returnc=getchar();
//returnc=getche();
printf(" ");
}
intaddEntry(FILE*fp,structbook*firstptr)
/************************************************************************/
/*主要用來載入文件中存放的圖書信息*/
/************************************************************************/
{
structbookinfoonebook;
while((fscanf(fp,"%s%s%s%d ",&onebook.isbn,&onebook.title,&onebook.author,&onebook.count))!=EOF)
{
while(firstptr->next!=0)
firstptr=firstptr->next;
firstptr->next=(structbook*)malloc(sizeof(structbook));
firstptr->next->onebook=onebook;
firstptr->next->next=0;
}
return0;
}
intmain(intargc,char*argv[])
{
intch;
structbookfirst;
strcpy(first.onebook.isbn,"123456");
strcpy(first.onebook.title,"ProgrammingC");
strcpy(first.onebook.author,"yhb");
first.next=0;
structbook*firstptr=&first;//鏈表頭指針
FILE*fp;
if((fp=fopen(books,"a+"))==NULL)
printf("文件打開失敗!!!");
addEntry(fp,firstptr);
while(1)
{
system("CLS");//清屏
/************************************************************************/
/*想想這里為什麼要清空緩沖區?*/
/*由於上一次(choice函數)的getchar(),還有一個' '留在緩沖區....*/
/*可以把這句話注釋掉看看,沒有這句話會遇到麻煩*/
/*如果不用fflush,可以將上面的getchar()換成getche()*/
/*比較getchar(),getch(),getche()......*/
/************************************************************************/
fflush(stdin);
ch=choice()-48;
switch(ch)
{
case1:
MainSearchbook(firstptr);
break;
case2:
MainAdd(firstptr,fp);
break;
case3:
MainRemove(firstptr,fp);
break;
case4:
printf("謝謝使用... ");
exit(0);
default:
printf("請輸入正確序號!");
}
system("PAUSE");
}
return0;
}
㈣ c程序課程設計 圖書管理系統
c語言課程設計:
圖書管理系統設計,源代碼+說明書,安裝配置說明,一套,
㈤ 操作系統課程設計,C語言寫的文件管理系統
操作系統課程設計,C語言寫的文件管理系統 、。要求有沒,根據要求可以做的
㈥ 完整的c語言學生管理系統課程設計
10財富值就想要個完整的,特么是窮瘋了吧,思路都不告訴你
㈦ C語言課程設計 設計題目管理系統
你好,源代碼,實現你所要求的,需要了就聊我