最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

C語言實現(xiàn)電話訂餐管理系統(tǒng)

 更新時間:2022年01月04日 14:36:00   作者:樂觀的阿斯頓  
這篇文章主要為大家詳細介紹了C語言實現(xiàn)電話訂餐管理系統(tǒng),文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了C語言實現(xiàn)電話訂餐管理系統(tǒng)的具體代碼,供大家參考,具體內(nèi)容如下

這是我C語言課程設(shè)計的題目。非常奇怪啊,下面的代碼能在C-Free中跑起來,卻沒辦法在vc++6.0中跑起來??赡苁蔷幾g器支持的標(biāo)準(zhǔn)不一樣。不管他,反正老師不會把我的代碼打一遍,然后放到vc中去運行。

實現(xiàn)了4個功能:添加、查找、修改、刪除,同時會把信息寫入到同一目錄下的customer.dat文件中。(這個文件需要手動建立,沒有建立的話程序會不運行。)。
能力有限,錯誤在所難免,歡迎指出。

代碼:

/*
?* 電話訂餐處理系統(tǒng)?
?* 第八組C語言課程設(shè)計
?* 佛祖保佑,永無 BUG
?*/?

#include<stdio.h>
#include<stdlib.h>
#include<windows.h>
#include<time.h>

void PrintMenu(); // 聲明主界面函數(shù)?
void AddCustomerInfo(); // 聲明添加顧客訂餐信息的函數(shù)?
void ModifyCustmoerInfo(); // 聲明修改顧客訂餐信息的函數(shù),記得加參數(shù)?
void DeleteCustomerInfo(); // 聲明刪除顧客訂餐信息的函數(shù),記得加參數(shù)
int searchdata();// 查找顧客訂餐信息并返回值?
void SearchCustomerInfo();// 聲明查詢顧客訂餐信息的函數(shù),記得加參數(shù)
void ViewAllInfo(); // 聲明預(yù)覽全部訂餐信息的函數(shù),記得加參數(shù)?
void ColorChange(int); // 聲明修改背景&字體顏色的函數(shù)?
void Cutline(); // 聲明分界線函數(shù)?
int Unix2Time();// 聲明時間戳轉(zhuǎn)換為普通時間的函數(shù)
void Time2Unix(time_t,char,char []);// 聲明普通時間轉(zhuǎn)換為時間戳的函數(shù) ?
void GetAllInfo();//獲取所有顧客的全部信息?
void SetConsolSize(int x,int y);//定義修改緩沖區(qū)大小的函數(shù)?
static int n=0;// 定義一個全局變量n用來獲取總共有多少顧客信息?


// 聲明一個顧客的結(jié)構(gòu)體變量?
struct Customer
{
?? ?char no[15];?
?? ?char name[20];
?? ?char phoneNumber[20];
?? ?char booktime[40];
?? ?int num;
?? ?char other[200];
?? ?char ordertime[40];
}customer[100],custmp;

int main()
{
?? ?int choice;
?? ?SetConsoleTitle("電話訂餐系統(tǒng)");
?? ?GetAllInfo();
?? ?system("mode con cols=150 lines=40");// 調(diào)用cmd命令修改窗口大小?
?? ?SetConsolSize(150,999);//修改緩沖區(qū)的大小?
?? ?printf("歡迎使用電話訂餐系統(tǒng)!\n");
?? ?printf("請輸入菜單前標(biāo)號以執(zhí)行操作\n");
?? ?PrintMenu:
?? ?PrintMenu();
?? ?//ColorChange(5);
?? ?GetChoice:
?? ?fflush(stdin);?
?? ?choice=-1;//重置choice的值?
?? ?printf("\n請輸入你的選項 >");
?? ?scanf("%d",&choice);?
?? ?fflush(stdin); // 清空緩沖區(qū),防止scanf接受多余的回車導(dǎo)致死循環(huán)?
?? ?switch(choice)
?? ?{
?? ??? ?case 1:AddCustomerInfo();break;
?? ??? ?case 2:ModifyCustmoerInfo();break;
?? ??? ?case 3:DeleteCustomerInfo();break;
?? ??? ?case 4:SearchCustomerInfo();break;
?? ??? ?case 5:ViewAllInfo();break;
?? ??? ?case 6:goto PrintMenu;break;
?? ??? ?case 0:exit(0);
?? ??? ?default:{
?? ??? ??? ?Cutline();
?? ??? ??? ?ColorChange(4);
?? ??? ??? ?printf("輸入錯誤!請重新輸入!\n");?
?? ??? ??? ?ColorChange(-1);
?? ??? ??? ?Cutline();
?? ??? ?}
?? ??? ??? ?
?? ?}
?? ?goto GetChoice;
}

void PrintMenu()//打印菜單函數(shù)?
{
?? ?printf("┏━━━━━━━━━━━━━━━━┓\n");?
?? ?printf("┃ 0. 退出本系統(tǒng) ?┃\n");
?? ?printf("┃ 1. 錄入訂餐信息┃\n");
?? ?printf("┃ 2. 修改訂餐信息┃\n");
?? ?printf("┃ 3. 刪除訂餐信息┃\n");
?? ?printf("┃ 4. 查詢訂餐信息┃\n");
?? ?printf("┃ 5. 預(yù)覽訂餐信息┃\n");
?? ?printf("┃ 6. 顯示菜單 ? ?┃\n");
?? ?printf("┗━━━━━━━━━━━━━━━━┛\n");?
}

void ColorChange(int color)//改變字體顏色函數(shù)?
{
?? ?HANDLE SELF = GetStdHandle(STD_OUTPUT_HANDLE);
?? ?
?? ?if(color==-1)
?? ??? ?SetConsoleTextAttribute(SELF,7);
?? ?SetConsoleTextAttribute(SELF,color);
}

void Cutline()//顯示一條分割線?
{
?? ?printf("————————————\n");
}

void AddCustomerInfo()//追加一條顧客的信息?
{
?? ?FILE *fp;
?? ?Cutline();
?? ?
?? ?//嘗試打開顧客數(shù)據(jù)文件 customer.dat?
?? ?if((fp=fopen(".\\customer.dat","rb"))==NULL)
?? ?{?
?? ??? ?ColorChange(4);
?? ??? ?printf("打開顧客數(shù)據(jù)文件失?。n");
?? ??? ?//printf("寫入顧客信息失??!");
?? ??? ?ColorChange(7);
?? ??? ?Cutline();
?? ??? ?return;
?? ?}
?? ?
?? ?//輸入顧客的訂餐信息?
?? ?printf("請輸入顧客姓名 >");
?? ?scanf("%[^\n]s",custmp.name);
?? ?fflush(stdin); //清空緩沖區(qū)?
?? ?printf("請輸入顧客電話 >");
?? ?scanf("%s",custmp.phoneNumber);
?? ?fflush(stdin);?
?? ?printf("請輸入顧客的預(yù)定時間 >");
?? ?scanf("%[^\n]s",custmp.booktime);
?? ?fflush(stdin);?
?? ?printf("請輸入用餐的人數(shù) >");
?? ?scanf("%d",&custmp.num);
?? ?fflush(stdin);?
?? ?printf("請輸入顧客的備注 >");
?? ?scanf("%[^\n]s",custmp.other);
?? ?fflush(stdin);?
?? ??
?? ?// 生成以時間為編號的顧客編號?
?? ?time_t rawtime;
?? ?time(&rawtime);?
?? ?Time2Unix(rawtime,'t',custmp.ordertime);
?? ?Time2Unix(rawtime,'n',custmp.no);
?? ??? ?
?? ?fclose(fp);
?? ?
?? ?//將顧客的數(shù)據(jù)文件寫入到 customer.dat中去?
?? ?fp=fopen(".\\customer.dat","ab");
?? ?fwrite(&custmp,sizeof(struct Customer),1,fp);
?? ?fclose(fp);
?? ?Cutline();
}

void ModifyCustmoerInfo()//修改顧客訂餐信息?
{
?? ?char target[40];
?? ?int no,choice;
?? ?long int movesize;
?? ?no=searchdata();
?? ?printmenu:
?? ?printf("\n查詢到下列顧客信息:\n");
?? ?printf("\n編號\t\t姓名\t\t電話\t\t用餐人數(shù) ? 預(yù)定日期\t\t\t下單日期\t\t\t備注\n");
?? ?ColorChange(240);
?? ?printf("%-16s",customer[no].no);
?? ?printf("%-16s",customer[no].name);
?? ?printf("%-16s",customer[no].phoneNumber);
?? ?printf("%-11d",customer[no].num);
?? ?printf("%-30s",customer[no].booktime);
?? ?printf("%-31s",customer[no].ordertime);
?? ?printf("%-39s\n",customer[no].other);
?? ?ColorChange(-1);
?? ?printf("┏━━━━━━━━━━━━━━┓\n");
?? ?printf("┃0.結(jié)束修改 ? ?┃\n");?
?? ?printf("┃1.姓名 ? ? ? ?┃\n");
?? ?printf("┃2.電話 ? ? ? ?┃\n");
?? ?printf("┃3.用餐人數(shù) ? ?┃\n");
?? ?printf("┃4.預(yù)定日期 ? ?┃\n");
?? ?printf("┃5.備注 ? ? ? ?┃\n");
?? ?printf("┃6.重新選擇顧客┃\n");
?? ?printf("┗━━━━━━━━━━━━━━┛\n");
?? ?GetModifiedInfo:
?? ?Cutline();
?? ?printf("\n請選擇你要修改的項目 >");
?? ?scanf("%d",&choice);
?? ?//菜單分支?
?? ?switch(choice)
?? ?{
?? ??? ?
?? ??? ?case 1:{
?? ??? ??? ?printf("請輸入更正后的內(nèi)容 >");
?? ??? ??? ?scanf("%s",customer[no].name);
?? ??? ??? ?goto WriteCustData;?
?? ??? ?}break;
?? ??? ?
?? ??? ?case 2:{
?? ??? ??? ?printf("請輸入更正后的內(nèi)容 >");
?? ??? ??? ?scanf("%s",customer[no].phoneNumber);?
?? ??? ??? ?goto WriteCustData;
?? ??? ?}break;
?? ??? ?
?? ??? ?case 3:{
?? ??? ??? ?printf("請輸入更正后的內(nèi)容 >");
?? ??? ??? ?scanf("%d",&customer[no].num);?
?? ??? ??? ?goto WriteCustData;
?? ??? ?}break;
?? ??? ?
?? ??? ?case 4:{
?? ??? ??? ?printf("請輸入更正后的內(nèi)容 >");
?? ??? ??? ?scanf("%s",customer[no].booktime);?
?? ??? ??? ?goto WriteCustData;
?? ??? ?}break;
?? ??? ?
?? ??? ?case 5:{
?? ??? ??? ?printf("請輸入更正后的內(nèi)容 >");
?? ??? ??? ?scanf("%s",customer[no].other);?
?? ??? ??? ?goto WriteCustData;
?? ??? ?}break;
?? ??? ?
?? ??? ?case 6:{?
?? ??? ??? ?no=searchdata();
?? ??? ??? ?goto printmenu;
?? ??? ?}
?? ??? ?
?? ??? ?case 0:return;
?? ??? ?
?? ??? ?default:{
?? ??? ??? ?ColorChange(4);
?? ??? ??? ?printf("輸入錯誤!");
?? ??? ??? ?ColorChange(-1);
?? ??? ??? ?goto GetModifiedInfo;
?? ??? ?}break;
?? ?}?
?? ?
?? ?//將要修改的顧客信息定點在customer.dat文件中覆蓋修改?
?? ?WriteCustData:
?? ?movesize=no*sizeof(struct Customer);
?? ?printf("movesize is %d\n",movesize);
?? ?FILE *fp;
?? ?fp=fopen(".\\customer.dat","r+");
?? ?rewind(fp);
?? ?fseek(fp,1L*(movesize),0);
?? ?fwrite(&customer[no],sizeof(struct Customer),1,fp);
?? ?fclose(fp);
?? ?goto GetModifiedInfo;
}

void DeleteCustomerInfo()
{
?? ?int i,no;
?? ?no=searchdata();
?? ?char choice;
?? ?FILE *fp;
?? ?
?? ?printf("\n查詢到下列顧客信息:\n");
?? ?printf("\n編號\t\t姓名\t\t電話\t\t用餐人數(shù) ? 預(yù)定日期\t\t\t下單日期\t\t\t備注\n");
?? ?ColorChange(240);
?? ?printf("%-16s",customer[no].no);
?? ?printf("%-16s",customer[no].name);
?? ?printf("%-16s",customer[no].phoneNumber);
?? ?printf("%-11d",customer[no].num);
?? ?printf("%-30s",customer[no].booktime);
?? ?printf("%-31s",customer[no].ordertime);
?? ?printf("%-39s\n",customer[no].other);
?? ?ColorChange(-1);
?? ?ColorChange(4);
?? ?
?? ?printf("\n是否刪除這個用戶的數(shù)據(jù)?(y/n) >");
?? ?fflush(stdin);
?? ?scanf("%c",&choice);?
?? ?ColorChange(7);
?? ?if(choice=='n'||choice=='N')
?? ?{
?? ??? ?printf("\n返回主菜單...\n");
?? ??? ?return;
?? ?}
?? ?
?? ?if(choice=='y'||choice=='Y')
?? ?{
?? ??? ?GetAllInfo();
?? ??? ?fp=fopen(".\\customer.dat","wb");
?? ??? ?fclose(fp);
?? ??? ?fp=fopen(".\\customer.dat","ab");
?? ??? ?printf("%d,%d",n,no);
?? ??? ?for(i=0;i<=(n-1);i++)
?? ??? ?{
?? ??? ??? ?if(i==no)
?? ??? ??? ??? ?continue;
?? ??? ??? ??? ?
?? ??? ??? ?fwrite(&customer[i],sizeof(struct Customer),1,fp);
?? ??? ??? ?
?? ??? ?}
?? ??? ?fclose(fp);
?? ?}
?? ?
}

int searchdata()//根據(jù)所給的條件尋找對應(yīng)的顧客i?
{
?? ?GetAllInfo();
?? ?char target[100];
?? ?printf("\n請輸入用戶任意單項信息 >");
?? ?scanf("%s",target);
?? ?int i,res1,res2,res3;
?? ?for(i=0;i<=(n-1);i++)
?? ?{
?? ??? ?res1=memcmp(target,customer[i].no,strlen(customer[i].no));
?? ??? ?res2=memcmp(target,customer[i].name,strlen(customer[i].name));
?? ??? ?res3=memcmp(target,customer[i].phoneNumber,strlen(customer[i].phoneNumber));
?? ??? ?if(!(res1&&res2&&res3))
?? ??? ??? ?return i;?
?? ?}
?? ?return -1;
}

void SearchCustomerInfo()
{
?? ?int no=searchdata();
?? ?printf("\n查詢到下列顧客信息:\n");
?? ?printf("\n編號\t\t姓名\t\t電話\t\t用餐人數(shù) ? 預(yù)定日期\t\t\t下單日期\t\t\t備注\n");
?? ?ColorChange(240);
?? ?printf("%-16s",customer[no].no);
?? ?printf("%-16s",customer[no].name);
?? ?printf("%-16s",customer[no].phoneNumber);
?? ?printf("%-11d",customer[no].num);
?? ?printf("%-30s",customer[no].booktime);
?? ?printf("%-31s",customer[no].ordertime);
?? ?printf("%-100s\n",customer[no].other);
?? ?ColorChange(-1);
}

void GetAllInfo()//獲取所有顧客的全部信息函數(shù)?
{
?? ?n=0;
?? ?FILE *fp;
?? ?fp=fopen(".\\customer.dat","rb");
?? ?do
?? ?{
?? ??? ?fread(&customer[n],sizeof(struct Customer),1,fp);
?? ??? ?//if(customer[n].no[0]=='\0')
?? ??? ?//?? ?break;
?? ??? ?n++;
?? ?}while(feof(fp)==0);
?? ?n=n-1;
?? ?fclose(fp);
}

void ViewAllInfo()
{
?? ?GetAllInfo();?
?? ?printf("n is %d",n);
?? ?int i=0,flag=1;
?? ?printf("\n編號\t\t姓名\t\t電話\t\t用餐人數(shù) ? 預(yù)定日期\t\t\t下單日期\t\t\t備注\n");?
?? ?while(i<=(n-1))
?? ?{
?? ??? ?if(flag)
?? ??? ?{
?? ??? ??? ?ColorChange(240);
?? ??? ??? ?flag=0;
?? ??? ?}else{
?? ??? ??? ?ColorChange(7);
?? ??? ??? ?flag=1;
?? ??? ?}
?? ??? ?printf("%-16s",customer[i].no);
?? ??? ?printf("%-16s",customer[i].name);
?? ??? ?printf("%-16s",customer[i].phoneNumber);
?? ??? ?printf("%-11d",customer[i].num);
?? ??? ?printf("%-30s",customer[i].booktime);
?? ??? ?printf("%-31s",customer[i].ordertime);
?? ??? ?printf("%-100s\n",customer[i].other);
?? ??? ?++i;
?? ?}
?? ?ColorChange(-1);
?? ?putchar('\n');
}

/* 將時間戳轉(zhuǎn)換為原時間的函數(shù) */?
void Time2Unix(time_t Timestamp,char transfer_type,char Transfer_Time[])
{
?? ?char Time1[40];//聲明原時間
?? ?struct tm* timeinfo;
?? ?
?? ?if(transfer_type=='t')//如果 transfer_type 為 x,則返回的時間格式為易閱讀的?
?? ?{
?? ??? ?timeinfo=localtime(&Timestamp);
?? ??? ?strftime(Time1,sizeof(Time1),"%Y年%m月%d日%H時%M分%S秒",timeinfo);
?? ?}
?? ?
?? ?if(transfer_type=='n')// //如果 transfer_type 為 n,則返回的時間格式為純數(shù)字?
?? ?{
?? ??? ?timeinfo=localtime(&Timestamp);
?? ??? ?strftime(Time1,sizeof(Time1),"%Y%m%d%H%M%S",timeinfo);
?? ?}
?? ?strcpy(Transfer_Time,Time1);//將轉(zhuǎn)換后的時間格式復(fù)制到傳遞過來的數(shù)組當(dāng)中去?
}

void SetConsolSize(int x,int y)// 設(shè)置緩沖區(qū)的大小?
{
?? ?SMALL_RECT winPon={0,0,25,10};
?? ?HANDLE con=GetStdHandle(STD_OUTPUT_HANDLE);
?? ?COORD buf={x,y};// 緩沖區(qū)長10000,高25?
?? ?SetConsoleScreenBufferSize(con,buf);
}

每個功能的測試:

1、錄入選項

2、刪除選項

3、查詢選項

4、修改選項

5、 預(yù)覽全部信息

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

相關(guān)文章

  • 淺談C/C++ 語言中的表達式求值

    淺談C/C++ 語言中的表達式求值

    下面小編就為大家?guī)硪黄獪\談C/C++ 語言中的表達式求值。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2016-07-07
  • C++類模板與模板類深入詳解

    C++類模板與模板類深入詳解

    這篇文章主要介紹了C++類模板與模板類深入詳解,需要的朋友可以參考下
    2014-07-07
  • c++中的兩種getline用法詳解

    c++中的兩種getline用法詳解

    c++中有2種getline函數(shù),一種在頭文件 <istream> 中,是istream類的成員函數(shù);另一種是在頭文件 <string> 中,是普通函數(shù)。這篇文章主要介紹了c++中的兩種getline用法,需要的朋友可以參考下
    2020-02-02
  • C語言線性表順序存儲結(jié)構(gòu)實例詳解

    C語言線性表順序存儲結(jié)構(gòu)實例詳解

    這篇文章主要介紹了C語言線性表順序存儲結(jié)構(gòu)實例詳解的相關(guān)資料,需要的朋友可以參考下
    2017-06-06
  • linux下c語言中隱藏進程命令行參數(shù)(例如輸入密碼等高危操作)

    linux下c語言中隱藏進程命令行參數(shù)(例如輸入密碼等高危操作)

    啟動程序很多時候用命令行參數(shù)可以很方便,做到簡化一些配置,但是輸入用戶名密碼等操作,如果通過進程查看工具直接看到密碼就太不安全了,這里就為大家分享一下方法
    2021-01-01
  • 利用C語言繪制一個正方體

    利用C語言繪制一個正方體

    這篇文章主要為大家詳細介紹了如何利用C語言繪制一個正方體,文中的示例代碼講解詳細,具有一定的學(xué)習(xí)和借鑒價值,感興趣的小伙伴可以學(xué)習(xí)一下
    2023-01-01
  • C語言實現(xiàn)簡單電子通訊錄

    C語言實現(xiàn)簡單電子通訊錄

    這篇文章主要為大家詳細介紹了C語言實現(xiàn)簡單電子通訊錄,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2020-06-06
  • 用c語言實現(xiàn)一個電話薄(附完整代碼)

    用c語言實現(xiàn)一個電話薄(附完整代碼)

    大家好,本篇文章主要講的是用c語言實現(xiàn)一個電話?。ǜ酵暾a),感興趣的同學(xué)趕快來看一看吧,對你有幫助的話記得收藏一下,方便下次瀏覽
    2022-01-01
  • ?C++模板template原理解析

    ?C++模板template原理解析

    這篇文章主要介紹了C++模板template原理,函數(shù)模板代表了一個函數(shù)家族,該函數(shù)模板與類型無關(guān),在使用時被參數(shù)化,根據(jù)實參類型產(chǎn)生函數(shù)的特定類型版本
    2022-07-07
  • Visual Studio Code運行程序時輸出中文成亂碼問題及解決方法

    Visual Studio Code運行程序時輸出中文成亂碼問題及解決方法

    這篇文章主要介紹了解決Visual Studio Code運行程序時輸出中文成亂碼問題,本文通過圖文并茂的形式給大家介紹的非常詳細,對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2020-03-03

最新評論

安多县| 灵宝市| 沁源县| 阳原县| 彰化县| 鸡东县| 定边县| 鄱阳县| 和硕县| 枞阳县| 张家口市| 阿拉尔市| 井研县| 崇明县| 贵阳市| 锡林郭勒盟| 方城县| 沅江市| 阜新| 肥东县| 兴海县| 双鸭山市| 揭阳市| 中超| 华安县| 土默特左旗| 桃园县| 邵武市| 常熟市| 云霄县| 泽州县| 吴忠市| 保康县| 衡山县| 商水县| 东平县| 阳西县| 郸城县| 壶关县| 临湘市| 灌南县|