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

C語(yǔ)言實(shí)現(xiàn)簡(jiǎn)單的抽獎(jiǎng)系統(tǒng)

 更新時(shí)間:2022年04月01日 09:11:26   作者:fastjson_  
這篇文章主要為大家詳細(xì)介紹了C語(yǔ)言實(shí)現(xiàn)簡(jiǎn)單的抽獎(jiǎng)系統(tǒng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了C語(yǔ)言實(shí)現(xiàn)簡(jiǎn)單的抽獎(jiǎng)系統(tǒng)的具體代碼,供大家參考,具體內(nèi)容如下

效果圖

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<conio.h>
#include<time.h>
#include <windows.h>
?
struct data{
?? ?char id[20];
?? ?char name[20];
};
?
int t1,t2,t3;
struct data information[110]; ? ? ? ? ? ? ?//普通人員信息
struct data prize1[110]; ? ? ? ? ? ? ? ? ? ?//總獲獎(jiǎng)人員信息
struct data prize2[110]; ? ? ? ? ? ? ? ? ? ?//總獲獎(jiǎng)人員信息
struct data prize3[110]; ? ? ? ? ? ? ? ? ? ?//總獲獎(jiǎng)人員信息
?
int people=0; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?//參與抽獎(jiǎng)總?cè)藬?shù)
int people1=0,people2=0,people3=0; ? ? ? ? //普通一等獎(jiǎng)、二等獎(jiǎng)、三等獎(jiǎng)的人數(shù)
char strid[20];
?
//從文件中讀取信息,放到普通人員信息中
void Read_information(); ??
?
//打印菜單
void Print_menu(); ? ? ?
?
//設(shè)置獎(jiǎng)項(xiàng)人數(shù)
void Set_awards();?
?
//開始抽獎(jiǎng) ? ?
void Begin_luck(); ?
?
//刪除該學(xué)號(hào)人員在普通人員中的信息
void Delet_information();
?
void main()
{
?? ?Read_information();
?? ?Print_menu();
}
?
void Read_information()//從文件中讀取信息
{
?? ?FILE *fp=fopen("抽獎(jiǎng)人員名單.txt","r");
?? ?while(!feof(fp))
?? ?{
?? ??? ?//存儲(chǔ)該信息到普通人員信息中,便于設(shè)置內(nèi)幕人員
?? ??? ?fscanf(fp,"%s%s",information[people].id,information[people].name);
?? ??? ?people++;
?? ?}
?? ?fclose(fp);
}
?
?
void Print_menu()
{
?? ?int choose;
?? ?while(1)
?? ?{
?? ??? ?system("cls");
?? ??? ?printf("\n\n");
?? ??? ?printf("\t\t\t*********************************************************\n");
?
?? ??? ?printf("\t\t\t*\t?? ?<-歡迎來到抽獎(jiǎng)系統(tǒng)->\t\t\t*\n");
?? ??? ?printf("\t\t\t*\t?? ?<-目前參與抽獎(jiǎng)的總?cè)藬?shù)為%d人->\t\t*\n", people);
?? ??? ?printf("\t\t\t*\t?? ?< ?一等獎(jiǎng)設(shè)置為%d人 ?>\t\t\t*\n",people1);
?? ??? ?printf("\t\t\t*\t?? ?< ?二等獎(jiǎng)設(shè)置為%d人 ?>\t\t\t*\n",people2);
?? ??? ?printf("\t\t\t*\t?? ?< ?三等獎(jiǎng)設(shè)置為%d人 ?>\t\t\t*\n",people3);
?? ??? ?printf("\t\t\t*\t\t\t\t\t\t\t*\n");
?
?? ??? ?printf("\t\t\t*\t\t開始抽獎(jiǎng)?wù)埌?\t\t\t\t*\n");
?? ??? ?printf("\t\t\t*\t\t設(shè)置獎(jiǎng)項(xiàng)人數(shù)2\t\t\t\t*\n");
?? ??? ?printf("\t\t\t*\t\t結(jié)束程序請(qǐng)按0\t\t\t\t*\n");
?? ??? ?printf("\t\t\t*\t\t\t\t\t\t\t*\n");
?? ??? ?printf("\t\t\t*********************************************************\n");
?
?? ??? ?printf("\n\n\t\t\t\t\t請(qǐng)輸入選項(xiàng):");
?? ??? ?scanf("%d",&choose);
?? ??? ?
?? ??? ?switch(choose)
?? ??? ?{
?? ??? ??? ?case 0:
?? ??? ??? ??? ?return;
?
?? ??? ??? ?case 1:
?? ??? ??? ??? ?Begin_luck();?
?? ??? ??? ??? ?break;
?
?? ??? ??? ?case 2:
?? ??? ??? ??? ?Set_awards();
?? ??? ??? ??? ?break;
?? ??? ?}?? ?
?? ?}
}
?
?
//設(shè)置獎(jiǎng)項(xiàng)人數(shù)
void Set_awards()
{
?? ?int choose;
?? ?while(1)
?? ?{
?? ??? ?system("cls");
?? ??? ?printf("請(qǐng)輸入三等獎(jiǎng)人數(shù)(正整數(shù)):\n");
?? ??? ?scanf("%d",&t3);
?? ??? ?if( t3<0 || t3>people)
?? ??? ?{
?? ??? ??? ?printf("輸入不合法,請(qǐng)輸入1到%d之內(nèi)的數(shù)字",people);
?? ??? ??? ?getch();
?? ??? ?}
?? ??? ?else
?? ??? ?{
?? ??? ??? ?people3=t3;
?? ??? ??? ?break;
?? ??? ?}
?
?? ?}
?? ?while(1)
?? ?{
?? ??? ?system("cls");
?? ??? ??? ?printf("請(qǐng)輸入二等獎(jiǎng)人數(shù):\n");
?? ??? ??? ?scanf("%d",&t2);
?? ??? ??? ?if( t2<0 || t2>people)
?? ??? ??? ?{
?? ??? ??? ??? ?printf("輸入不合法,請(qǐng)輸入1到%d之內(nèi)的數(shù)字",people);
?? ??? ??? ??? ?getch();
?
?? ??? ??? ?}
?? ??? ??? ?else
?? ??? ??? ?{
?? ??? ??? ??? ?people2=t2;
?? ??? ??? ??? ?break;
?? ??? ??? ?}
?
?
?? ?}
?? ?while(1)
?? ?{
?? ??? ?system("cls");
?? ??? ?printf("請(qǐng)輸入一等獎(jiǎng)人數(shù):\n");
?? ??? ?scanf("%d",&t1);
?? ??? ?if( t1<0 || t1>people)
?? ??? ?{
?? ??? ??? ?printf("輸入不合法,請(qǐng)輸入1到%d之內(nèi)的數(shù)字",people);
?? ??? ??? ?getch();
?? ??? ?}
?? ??? ?else
?? ??? ?{
?? ??? ??? ?people1=t1;
?? ??? ??? ?break;
?? ??? ?}
?? ?}
?? ?printf("設(shè)置完畢按任意鍵返回\n");
?? ?getch();
?? ?return;
}
?
?
void Begin_luck() ? //開始抽獎(jiǎng)
{
?? ?if(people1==0 || people2==0 || people3==0)
?? ?{
?? ??? ?printf("請(qǐng)?jiān)O(shè)置獎(jiǎng)項(xiàng)人數(shù)!!!!\n");
?? ??? ?printf("按任意鍵返回\n");
?? ??? ?getch();
?? ??? ?return;
?? ?}
?
?? ?if( (people1+people2+people3) > people )
?? ?{
?? ??? ?printf("中獎(jiǎng)人數(shù)超過總?cè)藬?shù),請(qǐng)重新設(shè)置!!!!\n");
?? ??? ?printf("按任意鍵返回\n");
?? ??? ?getch();
?? ??? ?return;
?? ?}
?
?? ?int i,j=0,choose,t;
?? ?system("cls");?? ? ?
?
/*******************三等獎(jiǎng)人員****************************/
?? ?printf("下面開始抽取三等獎(jiǎng)人員,按任意鍵繼續(xù)\n");
?? ?getch();
?? ?while(people3--)
?? ?{
?? ??? ?if(people3<0)
?? ??? ??? ?break;
?? ??? ?srand((unsigned)time(0));
?? ??? ?t=rand()%people;
?? ??? ?prize3[j++]=information[t];
?? ??? ?strcpy(strid,information[t].id);
?? ??? ?Delet_information();
?? ?}
?? ?printf("以下是三等獎(jiǎng)名單,按任意鍵繼續(xù)\n");
?? ?for(i=0;i<j;i++)
?? ??? ?printf("%s\n",prize3[i].name);
?? ?getch();
?
/*******************二等獎(jiǎng)人員****************************/
?? ?printf("下面開始抽取二等獎(jiǎng)人員,按任意鍵繼續(xù)\n");
?? ?getch();
?? ?while(people2--)
?? ?{
?? ??? ?if(people2<0)
?? ??? ??? ?break;
?? ??? ?srand((unsigned)time(0));
?? ??? ?t=rand()%people;
?? ??? ?prize2[j++]=information[t];
?? ??? ?strcpy(strid,information[t].id);
?? ??? ?Delet_information();
?? ?}
?? ?printf("以下是二等獎(jiǎng)名單,按任意鍵繼續(xù)\n");
?? ?for(;i<j;i++)
?? ??? ?printf("%s\n",prize2[i].name);
?? ?getch();
?
/*******************一等獎(jiǎng)人員****************************/
?? ?printf("下面開始抽取一等獎(jiǎng)人員,按任意鍵繼續(xù)\n");
?? ?getch();
?? ?while(people1--)
?? ?{
?? ??? ?if(people1<0)
?? ??? ??? ?break;
?? ??? ?srand((unsigned)time(0));
?? ??? ?t=rand()%people;
?? ??? ?prize1[j++]=information[t];
?? ??? ?strcpy(strid,information[t].id);
?? ??? ?Delet_information();
?? ?}
?? ?printf("以下是一等獎(jiǎng)名單,按任意鍵繼續(xù)\n");
?? ?for(;i<j;i++)
?? ??? ?printf("%s\n",prize1[i].name);
?? ?getch();
?
?? ?people=0;
?? ?Read_information();
?? ?people1=t1,people2=t2,people3=t3;
}
?
void Delet_information() ? //刪除該學(xué)號(hào)人員在普通人員中的信息
{
?? ?int i,j;
?? ?for(i=0;i<people;i++)
?? ??? ?if(strcmp(information[i].id,strid)==0)
?? ??? ?{
?? ??? ??? ?people--;
?? ??? ??? ?for(j=i;j<people;j++)
?? ??? ??? ??? ?information[j]=information[j+1];
?? ??? ??? ?return;
?? ??? ?}
}

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

相關(guān)文章

  • C++中的移動(dòng)構(gòu)造函數(shù)及move語(yǔ)句示例詳解

    C++中的移動(dòng)構(gòu)造函數(shù)及move語(yǔ)句示例詳解

    這篇文章主要給大家介紹了關(guān)于C++中移動(dòng)構(gòu)造函數(shù)及move語(yǔ)句的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用C++具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧。
    2017-10-10
  • C++超細(xì)致講解隊(duì)列queue的使用

    C++超細(xì)致講解隊(duì)列queue的使用

    隊(duì)列先進(jìn)先出,即只能在容器的末尾添加新元素,只能從頭部移除元素,下面這篇文章主要給大家介紹了關(guān)于C++中隊(duì)列queue用法的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2022-05-05
  • C語(yǔ)言中操作進(jìn)程信號(hào)的相關(guān)函數(shù)使用詳解

    C語(yǔ)言中操作進(jìn)程信號(hào)的相關(guān)函數(shù)使用詳解

    這篇文章主要介紹了C語(yǔ)言中操作進(jìn)程信號(hào)的相關(guān)函數(shù)使用詳解,分別是signal()函數(shù)和kill()函數(shù)的用法,需要的朋友可以參考下
    2015-09-09
  • C語(yǔ)言實(shí)現(xiàn)職工工資管理系統(tǒng)

    C語(yǔ)言實(shí)現(xiàn)職工工資管理系統(tǒng)

    這篇文章主要介紹了C語(yǔ)言實(shí)現(xiàn)職工工資管理系統(tǒng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-02-02
  • C++小利器之std::bind參數(shù)綁定包裝器的使用詳解

    C++小利器之std::bind參數(shù)綁定包裝器的使用詳解

    從 C++11 開始,標(biāo)準(zhǔn)庫(kù)提供了 std::bind 用于綁定函數(shù) f 和調(diào)用參數(shù),返回一個(gè)新可調(diào)用函數(shù)對(duì)象 fn,下面就跟隨小編一起深入了解一下std::bind的具體使用吧
    2023-12-12
  • C++中策略模式和工廠模式的區(qū)別

    C++中策略模式和工廠模式的區(qū)別

    這篇文章介紹了C++中策略模式和工廠模式的區(qū)別,文中通過示例代碼介紹的非常詳細(xì)。對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2022-07-07
  • C語(yǔ)言清楚了解指針的使用

    C語(yǔ)言清楚了解指針的使用

    C語(yǔ)言這門課程在計(jì)算機(jī)的基礎(chǔ)教學(xué)中一直占有比較重要的地位,然而要想突破C語(yǔ)言的學(xué)習(xí),對(duì)指針的掌握是非常重要的,本文將具體針對(duì)指針的基礎(chǔ)做詳盡的介紹
    2022-06-06
  • COLORREF,COLOR,RGB,CString的轉(zhuǎn)化總結(jié)分析

    COLORREF,COLOR,RGB,CString的轉(zhuǎn)化總結(jié)分析

    實(shí)際的軟件開發(fā)過程中,常需要用到非.net平臺(tái)的代碼。這時(shí)候就可能碰到ColorRef(也就是以int類型代表的顏色值或是以DWORD值表示的顏色)。這跟.net平臺(tái)下的顏色的相互轉(zhuǎn)換MS并沒有直接實(shí)現(xiàn)
    2013-09-09
  • C語(yǔ)言動(dòng)態(tài)內(nèi)存管理介紹

    C語(yǔ)言動(dòng)態(tài)內(nèi)存管理介紹

    大家好,本篇文章主要講的是C語(yǔ)言動(dòng)態(tài)內(nèi)存管理介紹,感興趣的同學(xué)趕快來看一看吧,對(duì)你有幫助的話記得收藏一下,方便下次瀏覽
    2021-12-12
  • C++對(duì)象模型和this指針詳解

    C++對(duì)象模型和this指針詳解

    這篇文章主要介紹了詳解C++對(duì)象模型和this指針,是C++入門學(xué)習(xí)中的基礎(chǔ)知識(shí),需要的朋友可以參考下,希望能夠給你帶來幫助
    2021-10-10

最新評(píng)論

揭西县| 辽阳市| 张家口市| 鹿邑县| 东城区| 禄劝| 陵川县| 凌源市| 海伦市| 法库县| 怀宁县| 溧水县| 乌什县| 饶平县| 高清| 延长县| 获嘉县| 滦南县| 玉环县| 锡林郭勒盟| 澄城县| 阳春市| 横山县| 富锦市| 沅江市| 隆德县| 元氏县| 当涂县| 钦州市| 邹城市| 高清| 科尔| 白水县| 东乡族自治县| 临汾市| 江山市| 辛集市| 天水市| 巴塘县| 普陀区| 新晃|