(C++)英語(yǔ)抽背點(diǎn)名器源程序-V1.4.2.1
#include<iostream>
#include<stdlib.h>
#include<windows.h>//庫(kù)?
using namespace std;//固定格式
int main(){
int a,b,c,miss;
long long key,linshi;//數(shù)據(jù)的類型聲明
SYSTEMTIME sys;
GetLocalTime(&sys);
printf("%d/%d/%d %02d:%02d:%02d.%d 星期%d",sys.wYear,sys.wMonth,sys.wDay,sys.wHour,sys.wMinute,sys.wSecond,sys.wMilliseconds,sys.wDayOfWeek);//本地時(shí)間的調(diào)用?
cout<<endl<<endl;
long long wDay=sys.wDay;
cout<<"密鑰為:";
key=sys.wMonth*100000000000+wDay*1000000000+sys.wHour*10000000+sys.wMinute*100000+sys.wSecond*1000+sys.wMilliseconds;
cout<<key<<endl;
cout<<"(如需查看更新日志,請(qǐng)?jiān)谳斎肴藬?shù)時(shí)輸入'0')"<<endl<<endl;
cout<<"輸入人數(shù)及姓名(≥3):";
cin>>a;
if(a==0){
system("cls");
cout<<"編譯器:Dev-C++ 5.11/TDM-GCC 4.9.2 64-bit Release"<<endl;
cout<<"現(xiàn)行版本:1.4.2.1"<<endl<<endl;
cout<<"更新日志:"<<endl;
cout<<"(2022-12-14)update-1.0.0:"<<endl;
cout<<"系統(tǒng)初步建立"<<endl<<endl;
cout<<"(2022-12-17)update-1.0.1:"<<endl;
cout<<"加入'中止抽背并統(tǒng)計(jì)'的功能" <<endl;
cout<<"將結(jié)尾等待時(shí)間從100秒改至99999秒"<<endl<<endl;
cout<<"(2023-1-15)update-1.1.0:"<<endl;
cout<<"引入'密鑰',通過(guò)一定算法(動(dòng)態(tài)數(shù)+常數(shù))在不更換名單順序的情況下實(shí)現(xiàn)不同次序,糾正偽隨機(jī)算法"<<endl;
cout<<"加入'更新日志',便于程序優(yōu)化更新"<<endl;
cout<<"將抽背完成后等待時(shí)間從99999秒改至999秒,減少非必要的內(nèi)存消耗,加入時(shí)間提示"<<endl;
cout<<"解決'特殊位置無(wú)法抽到'的問(wèn)題"<<endl;
cout<<"微量?jī)?yōu)化UI,在姓名間加入換行,使姓名更易讀取"<<endl<<endl;
cout<<"(2022-1-19)update-1.1.1:"<<endl;
cout<<"簡(jiǎn)化了簡(jiǎn)單計(jì)算的寫(xiě)法,減少運(yùn)行內(nèi)存"<<endl;
cout<<"將站立標(biāo)記的定義類型從int改為bool"<<endl<<endl;
cout<<"(此正式版未發(fā)布)update-1.2.0:"<<endl;
cout<<"完全改變數(shù)據(jù)的結(jié)構(gòu),用結(jié)構(gòu)體data整合原變量,使程序結(jié)構(gòu)更清晰,做好排序功能準(zhǔn)備"<<endl;
cout<<"抽背人數(shù)上限定為100人,減少存儲(chǔ)空間"<<endl<<endl;
cout<<"(2023-1-21)update-1.3.0:"<<endl;
cout<<"加入數(shù)據(jù)的排序功能(以分?jǐn)?shù)為依據(jù)冒泡排序),在輸出時(shí)按序輸出"<<endl;
cout<<"將程序.cpp的源文件中分段并加入注釋,便于理解和改寫(xiě)"<<endl<<endl;
cout<<"(2023-1-23)update-1.3.1:"<<endl;
cout<<"頭文件從bits/stdc++.h中拆解出兩條有效頭文件--iostream(基礎(chǔ)結(jié)構(gòu)頭文件)和stdlib.h(rand函數(shù)頭文件)"<<endl;
cout<<"加入windows.h頭文件,原'_sleep'非法等待函數(shù)調(diào)用出現(xiàn)的警告被修復(fù),改為合法的'Sleep'函數(shù),可在手機(jī)Dev編譯器上運(yùn)行等待函數(shù)"<<endl;
cout<<"補(bǔ)充了源文件注釋"<<endl<<endl;
cout<<"(2023-1-28)update-1.3.2:"<<endl;
cout<<"修改源文件注釋及少量使用說(shuō)明"<<endl;
cout<<"將數(shù)組定義板塊后置,使數(shù)組總量與需抽背人數(shù)相配,按需提高上限/減少運(yùn)行空間"<<endl;
cout<<"顯示每次開(kāi)始運(yùn)行時(shí)的系統(tǒng)時(shí)間,防止同時(shí)掛有多次運(yùn)行時(shí)的統(tǒng)計(jì)錯(cuò)誤"<<endl<<endl;
cout<<"(2023-2-15)update-1.4.0:"<<endl;
cout<<"密鑰隨系統(tǒng)時(shí)間動(dòng)態(tài)變化,無(wú)需手動(dòng)輸入,解決'手動(dòng)輸入密鑰相同'的問(wèn)題"<<endl;
cout<<"加入windows.h庫(kù)以支持系統(tǒng)時(shí)間調(diào)取"<<endl;
cout<<"將變量'linshi'的定義從int改為long long防止因密鑰過(guò)長(zhǎng)造成的錯(cuò)誤"<<endl<<endl;
cout<<"(2023-2-28)update-1.4.1:"<<endl;
cout<<"少量修改1.4.1版本以前的更新日志"<<endl;?
cout<<"用while的循環(huán)判定linshi是否等于上一次的抽背序號(hào)(miss),解決'特殊情況下多次抽背時(shí)序列相同'的問(wèn)題"<<endl;
cout<<"結(jié)構(gòu)體data從零開(kāi)始記錄,刪去了取隨機(jī)數(shù)時(shí)'防止取到空結(jié)構(gòu)體組'的冗余代碼(if(linshi==0){linshi=a;})"<<endl;
cout<<"在不影響抽背次序的情況下加入清屏功能(通過(guò)system( cls )實(shí)現(xiàn))"<<endl;
cout<<"彈出更新日志后的等待查看時(shí)間從120s變?yōu)?40s"<<endl;
cout<<"完善了使用說(shuō)明"<<endl<<endl;
cout<<"(2023-3-5)update-1.4.2.1:"<<endl;
cout<<"(此版本為最終版,此后的版本將停止加入新功能和進(jìn)行代碼優(yōu)化,只會(huì)對(duì)問(wèn)題進(jìn)行修復(fù))"<<endl;
cout<<"簡(jiǎn)化第一行printf輸出雙引號(hào)內(nèi)的格式"<<endl;
cout<<"結(jié)構(gòu)體總量從a+1改為a"<<endl;
cout<<"優(yōu)化UI"<<endl;
cout<<"加入'抽背過(guò)程中是否被點(diǎn)到的判斷'(將變量bj類型從bool改為int)"<<endl;
cout<<"補(bǔ)充了源文件注釋"<<endl<<endl;
cout<<"如有發(fā)現(xiàn)功能異常,請(qǐng)及時(shí)聯(lián)系作者"<<endl;
cout<<"(240秒后自動(dòng)關(guān)閉)";
Sleep(240000);
return 0;//結(jié)束
}//更新日志
struct test{
int total;
int bj;
string name;
}data[a];//結(jié)構(gòu)體
for(int i=0;i<a;i++){cin>>data[i].name;}
for(int i=0;i<a;i++){
data[i].total=0;
data[i].bj=1;}//批量定義結(jié)構(gòu)體數(shù)據(jù)?
cout<<endl<<"輸入抽背人數(shù):";
cin>>b;
cout<<"在決定分?jǐn)?shù)時(shí)按'0'以停止,按'2'以清空屏幕"<<endl;//輔助功能說(shuō)明?
Sleep(2000);//人數(shù),名字的輸入
for(int i=1;i<=b;i++){
linshi=(key/202+rand()%a+14+b*7)%a;//取隨機(jī)數(shù)
while(linshi==miss){linshi+=1;}
linshi=linshi%a;
cout<<endl;
cout<<i<<"."<<data[linshi].name<<endl;//抽背功能實(shí)現(xiàn)核心部分
cout<<"分?jǐn)?shù)決定(1或-1):";
cin>>c;
if(c==2){
system("cls");
cout<<endl;
cout<<i<<"."<<data[linshi].name<<endl;
cout<<"分?jǐn)?shù)決定(1或-1):";
cin>>c;}//按'2'時(shí)清屏后重新輸出并決定分?jǐn)?shù)
if(c==0){break;}//按'0'時(shí)break跳出循環(huán)
if(c==-1){data[linshi].bj=-1;b+=1;}//抽到并分?jǐn)?shù)為-1時(shí),個(gè)體int標(biāo)記為-1并增加抽背次數(shù)
if(c==1){data[linshi].bj=0;}//抽到并分?jǐn)?shù)為1時(shí),個(gè)體int標(biāo)記為0
data[linshi].total+=c;//總分計(jì)算
miss=linshi;}//miss令,去除連續(xù)抽背
for(int i=1;i<a;i++){
for(int j=1;j<a;j++){//冒泡排序?
if(data[j-1].total<data[j].total){
swap(data[j-1].name,data[j].name);//交換姓名
swap(data[j-1].bj,data[j].bj);//交換標(biāo)記狀態(tài)
swap(data[j-1].total,data[j].total);}}}//交換排序功能
cout<<endl<<endl<<"分?jǐn)?shù)統(tǒng)計(jì):"<<endl;
for(int i=0;i<a;i++){
if(data[i].bj==-1){cout<<"(站立中) ";}//如果標(biāo)記為-1,則代表在最后一次抽背時(shí)錯(cuò)誤
if(data[i].bj==1){cout<<"(未點(diǎn)到) ";}//如果標(biāo)記為1,則代表在全過(guò)程中未被點(diǎn)到?
if(data[i].bj==0){cout<<"? ? ? ? ?";}//標(biāo)記為0時(shí)補(bǔ)空
cout<<data[i].name<<" "<<data[i].total<<endl;}
cout<<endl<<"999秒后自動(dòng)關(guān)閉";
Sleep(999000);//按序輸出,結(jié)束
return 0;}