#include<iostream> #include<cstring> #include<string> #include<vector> #include<stdlib.h> #include<time.h> #include<Windows.h> #include<fstream> using namespace std; string QuestionBank[3][1000];//分為3個難度,每個有1000個單詞。 int QuestionNum[3] = { 0 };//每個難度一共有幾道題 //user是出題人和答題人共同的基類 //擁有姓名 ID 密碼 等級四個屬性 以及這些私有類的讀入和輸出函數 class user { private: string name; string ID; string Password; int level = 0; public: void getName(string c) { //string c; name = c; } void getID(string c) { ID = c; } void getPassword(string c) { Password = c; } void getLevel(int a) { level = a; } string wrtName() { return name; } string wrtID() { return ID; } string wrtPassword() { return Password; } int wrtLevel() { return level; } user() {} ~user(){} }; //出題人是在user的基礎上 新增了出題數目 ,題庫序號的類 //多的函數:出題 升級 新的私有類的讀入和輸出 class TestMaker:public user{ private: string name; string ID; string Password; int level=0; int testnum=0; int testnumMod10; public: int PersonalBank[2][1000];//存儲出題的難度等級和序號。 void MakeTest(int hard,string test) {//出題時把這個單詞的難度一起讀入 int num; //length = test.length(); //if ((length >= 1) && (length <= 6))hard = 0; //else if (length <= 12)hard = 1; //else hard = 2; QuestionNum[hard]++; num = QuestionNum[hard]; QuestionBank[hard][num] = test; testnum++; testnumMod10 = testnum; PersonalBank[0][testnum] = hard; PersonalBank[1][testnum] = num; } void getTestnum(int a) { testnum = a; } void levelup() {//每出十題升一級 level = testnum / 10; } void InforOut() { //cout << "姓名:"; //cout << name << endl; cout << "等級:" << level << endl; cout << "出題數目:" << testnum << endl; } /*void getPersonalBank(int a[2][1000]) { int i; for (i = 1; i <= testnum; i++) { PersonalBank[1][i] = a[1][i]; PersonalBank[0][i] = a[0][i]; } }*/ int wrttestnum() { return(testnum); } TestMaker(const TestMaker &a) {//用於排序的拷貝構造函數 int i; name = a.name; ID = a.ID; Password = a.Password; level = a.level; testnum = a.testnum; testnumMod10 = a.testnumMod10; for (i = 1; i <= testnum; i++) { PersonalBank[0][i] = a.PersonalBank[0][i]; PersonalBank[1][i] = a.PersonalBank[1][i]; } } TestMaker() {} ~TestMaker(){} }; //玩家類多了等級 經驗值和答題成功數目 //多的函數:升級 新增屬性的讀入和輸出 class Player:public user{ private: string name; string ID; string Password; int level = 0; int experience = 0; int outpost = 0;//答題成功數目 public: void LevelUp(int a,int b) {//闖關成功后,a作為難度讀入,b作為時間讀入,獲得經驗和a,b都有關系 outpost++; experience = experience + ((a + 1) * 10) + ((3000 - b) / 50); while (experience > 100) { level++; experience = experience - 100; } } void getExperience(int a) { experience = a; } void getOutpost(int a) { outpost = a; } int wrtExperience() { return experience; } int wrtOutpost() { return outpost; } void InforOut() { //cout << "姓名:" << name << endl; cout << "等級:" << level << endl; cout << "經驗:" << experience << endl; cout << "答題數目:" << outpost << endl; } Player(const Player &a) { name = a.name; ID = a.ID; Password = a.Password; level = a.level; experience = a.experience; outpost = a.outpost; } Player(){} ~Player(){} }; TestMaker TestMakerList[100]; int TestMakerNum=0; Player PlayerList[100]; int PlayerNum=0; int yournum; //對於排行榜功能,用簡單的冒泡函數實現 void paixu() { int i, j; TestMaker t; if (TestMakerNum == 0)cout << "無出題人" << endl; else { for (i = 1; i <= TestMakerNum; i++) { for (j = i; j <= TestMakerNum; j++) { if (TestMakerList[i].wrttestnum() < TestMakerList[j].wrttestnum()) { t = TestMakerList[i]; TestMakerList[i] = TestMakerList[j]; TestMakerList[j] = t; } } } cout << "對出題人按出題數從高到低排序:" << endl; for (i = 1; i <= TestMakerNum; i++) { cout <<"姓名:"<< TestMakerList[i].wrtName() << " 出題數:" << TestMakerList[i].wrttestnum() << endl; } } if (PlayerNum == 0)cout << "無答題人" << endl; else { Player m; for (i = 1; i <= PlayerNum; i++) { for (j = i; j <= PlayerNum; j++) { if ((PlayerList[i].wrtLevel() < PlayerList[j].wrtLevel()) || ((PlayerList[i].wrtLevel() == PlayerList[j].wrtLevel()) && (PlayerList[i].wrtExperience() < PlayerList[j].wrtExperience()))) { m = PlayerList[i]; PlayerList[i] = PlayerList[j]; PlayerList[j] = m; } } } cout << "對答題人按等級經驗從高到低排序:" << endl; for (i = 1; i <= PlayerNum; i++) { cout <<"姓名:"<< PlayerList[i].wrtName() << " 等級:" << PlayerList[i].wrtLevel() << " 經驗值:" << PlayerList[i].wrtExperience() << endl; } } return; } //第一種出題模式:難度等級不變 void MakeTest1(int hard) { int max, length; string ans; int flag = 0; max = QuestionNum[hard]; while (1) { srand((unsigned)time(NULL)); int x; x = rand(); x = (x % max) + 1; while (1) { cout << QuestionBank[hard][x]; length = QuestionBank[hard][x].length(); Sleep(3000); for (int i = 1; i <= length; i++)cout << "\b"; cout << "輸入答案:"; cin >> ans; if (ans == QuestionBank[hard][x]) { cout << "答案正確!" << endl; PlayerList[yournum].LevelUp(hard,3000); break; } else cout << "worng answer!" << endl; } cout << "continue or not? 1 or 0" << endl; cin >> flag; if (flag == 0)break; } } //第二種出題模式:難度等級遞增 void MakeTest2() { int max, length,hard; string ans; int flag = 0, gamelevel = 0; while (1) { gamelevel++; if (((gamelevel % 9) <= 3)&&((gamelevel%9)>=1))hard = 0; else if (((gamelevel % 9) <= 6)&&((gamelevel%9)>=4))hard = 1; else hard = 2; cout << "當前關卡:" << gamelevel << " 當前難度:" << hard << endl; max = QuestionNum[hard]; srand((unsigned)time(NULL)); int x; x = rand(); x = (x % max) + 1; while (1) { cout << QuestionBank[hard][x]; length = QuestionBank[hard][x].length(); Sleep(3000); for (int i = 1; i <= length; i++)cout << "\b"; cout << "輸入答案: "; cin >> ans; if (ans == QuestionBank[hard][x]) { cout << "答案正確!" << endl; PlayerList[yournum].LevelUp(hard,3000); break; } else cout << "worng ans!" << endl; } cout << "continue or not? 1 or 0" << endl; cin >> flag; if (flag == 0)break; } } //第三種出題模式:進行輪數增多 void MakeTest3(int hard) { int max, length,Gametime=1; string ans; int flag = 0, gamelevel = 0; int i, j; max = QuestionNum[hard]; while (1) { gamelevel++; if ((gamelevel% 3) == 0)Gametime++;//設定是每三關之后,輪數加一 cout << "當前關卡:" << gamelevel << " 當前輪數:" << Gametime << endl; for (j = 1; j <= Gametime; j++) { srand((unsigned)time(NULL)); int x; x = rand(); x = (x % max) + 1; while (1) { cout << QuestionBank[hard][x]; length = QuestionBank[hard][x].length(); Sleep(3000); for (i = 1; i <= length; i++)cout << "\b"; cout << "輸入答案: "; cin >> ans; if (ans == QuestionBank[hard][x]) { cout << "答案正確!" << endl; PlayerList[yournum].LevelUp(hard,3000); break; } else cout << "worng ans!" << endl; } } cout << "continue or not? 1 or 0" << endl; cin >> flag; if (flag == 0)break; } } //第四種出題模式:答題時間縮短 void MakeTest4(int hard) { int max, length, waittime=3500; string ans; int flag = 0, gamelevel = 0; max = QuestionNum[hard]; while (1) { gamelevel++; if (waittime > 1000)waittime = waittime - 500;//每關等待時間減少0.5秒 1秒為下限 cout << "當前關卡:" << gamelevel << " 當前時長:" << waittime <<"ms"<< endl; srand((unsigned)time(NULL)); int x; x = rand(); x = (x % max) + 1; while (1) { cout << QuestionBank[hard][x]; length = QuestionBank[hard][x].length(); Sleep(waittime); for (int i = 1; i <= length; i++)cout << "\b"; cout << "輸入答案: "; cin >> ans; if (ans == QuestionBank[hard][x]) { cout << "答案正確!" << endl; PlayerList[yournum].LevelUp(hard,waittime); break; } else cout << "worng ans!" << endl; } cout << "continue or not? 1 or 0" << endl; cin >> flag; if (flag == 0)break; } } int main() { int i,j; string name,id, password; string pdid, pdpassword; int level = 0, testnum = 0, experience = 0, outpost = 0, gamelevel = 0; ifstream user_file; ifstream word_file; ofstream user_out; ofstream word_out; //先打開D盤中的讀入文件,讀入我們之前寫入的用戶信息 user_file.open("D:\\user.txt", ios::_Nocreate | ios::in); if (user_file) { //cout << "user_file succeed" << endl; user_file >> TestMakerNum; for (i = 1; i <= TestMakerNum; i++) { user_file >> name >> id >> password >> level >> testnum; TestMakerList[i].getID(id); TestMakerList[i].getName(name); TestMakerList[i].getPassword(password); TestMakerList[i].getTestnum(testnum); TestMakerList[i].getLevel(level); for (j = 1; j <= testnum; j++) { int a, b; user_file >> a >> b; TestMakerList[i].PersonalBank[0][j] = a; TestMakerList[i].PersonalBank[1][j] = b; } } user_file >> PlayerNum; //cout << "!:" << PlayerNum << endl; for (i = 1; i <= PlayerNum; i++) { user_file >> name >> id >> password >> level >> experience >> outpost; PlayerList[i].getID(id); PlayerList[i].getName(name); PlayerList[i].getPassword(password); PlayerList[i].getExperience(experience); PlayerList[i].getLevel(level); PlayerList[i].getOutpost(outpost); } } //然后關閉文件 if (user_file) { //cout << "user_file close!" << endl; user_file.close(); } //再打開之前的題庫文件,讀入出過的題目 word_file.open("D:\\word.txt", ios::_Nocreate | ios::in); //如果之前沒出過題目,則讀入自帶題庫 if (!word_file) {//如果沒有 系統自建一個文件庫 //Sleep(3000); //cout << "!word_file succeed" << endl; QuestionNum[0] = 11; QuestionNum[1] = 11; QuestionNum[2] = 11; QuestionBank[0][1] = "apple"; QuestionBank[0][2] = "chorus"; QuestionBank[0][3] = "facet"; QuestionBank[0][4] = "denial"; QuestionBank[0][5] = "black"; QuestionBank[0][6] = "wind"; QuestionBank[0][7] = "sheep"; QuestionBank[0][8] = "chaos"; QuestionBank[0][9] = "dazzle"; QuestionBank[0][10] = "gray"; QuestionBank[0][11] = "feast"; //1-6 QuestionBank[1][1] = "abandon"; QuestionBank[1][2] = "ambitious"; QuestionBank[1][3] = "bachelor"; QuestionBank[1][4] = "basement "; QuestionBank[1][5] = "biography"; QuestionBank[1][6] = "casualty"; QuestionBank[1][7] = "ceramic"; QuestionBank[1][8] = "degrade"; QuestionBank[1][9] = "denounce"; QuestionBank[1][10] = "disrupt"; QuestionBank[1][11] = "fixture"; //7-10 QuestionBank[2][1] = "apprehension"; QuestionBank[2][2] = "adolescent"; QuestionBank[2][3] = "bureaucracy"; QuestionBank[2][4] = "coincidence"; QuestionBank[2][5] = "declaration"; QuestionBank[2][6] = "descendant"; QuestionBank[2][7] = "destructive"; QuestionBank[2][8] = "forthcoming"; QuestionBank[2][9] = "masterpiece"; QuestionBank[2][10] = "mediterranean"; QuestionBank[2][11] = "metropolitan"; //11 } if (word_file) { //cout << "word_file succeed" << endl; for (i = 0; i <= 2; i++) { word_file >> QuestionNum[i]; } for (i = 0; i <= 2; i++) { for (j = 1; j <= QuestionNum[i]; j++) { word_file >> QuestionBank[i][j]; } } } if (word_file) { //cout << "word_file close" << endl; word_file.close(); } int c = 0; //因為沒能實現圖形化,黑框版本是要做到不斷地詢問客戶需求地 while (1) { c = 0; cout << "選擇您的需求:1:登陸 2:注冊 3:查詢玩家 4:查看排行榜 5:結束程序" << endl; cin >> c; //int cc = 0; //登陸的情況 if (c == 1) { int type = 0; int flag = 0; int dlflag = 0; cout << "您是出題人還是答題人,出題人請輸入1,答題人請輸入2:"; cin >> type; //此處需要加一點東西 if (type == 1) {//出題人 if (TestMakerNum == 0) { cout << "目前無出題人注冊!" << endl; flag = 0; } else { flag = 1; //int IDrepeat = 0; cout << "請輸入id,回車結束: "; cin >> id; cout << "請輸入密碼,回車結束: "; cin >> password; dlflag = 0; for (i = 1; i <= TestMakerNum; i++) { pdid = TestMakerList[i].wrtID(); pdpassword = TestMakerList[i].wrtPassword(); if (id.compare(pdid) == 0) { if (password.compare(pdpassword) == 0) { yournum = i; name = TestMakerList[i].wrtName(); testnum = TestMakerList[i].wrttestnum(); level = TestMakerList[i].wrtLevel(); dlflag = 1; break; } } } if (dlflag == 0)cout << "賬號或密碼錯誤。" << endl; } } if (type == 2) { if (PlayerNum == 0) { cout << "目前無答題人注冊!" << endl; flag = 0; } else { flag = 1; cout << "請輸入id,回車結束: "; cin >> id; cout << "請輸入密碼,回車結束: "; cin >> password; dlflag = 0; for (i = 1; i <= PlayerNum; i++) { if (id.compare(PlayerList[i].wrtID())==0) { if (password.compare(PlayerList[i].wrtPassword())==0) { yournum = i; name = PlayerList[i].wrtName(); experience = PlayerList[i].wrtExperience(); outpost = PlayerList[i].wrtOutpost(); level = PlayerList[i].wrtLevel(); dlflag = 1; break; } } } if (dlflag == 0)cout << "賬號或密碼錯誤。" << endl; } } if ((flag == 1)&&(dlflag==1)) {//登陸成功了 cout << "您的個人信息為:" << endl; if (type == 1) { cout << "出題人:" << endl; cout << "姓名:" << TestMakerList[i].wrtName() << endl; TestMakerList[yournum].InforOut(); } if (type == 2) { cout << "答題人:" << endl; cout << "姓名:" << PlayerList[i].wrtName() << endl; PlayerList[yournum].InforOut(); } string Npassword; string word; int a, b, pdsame = 0, length;//b:難度等級 pdsame:判斷是否為重復的單詞 int hard; int cc = 0; while (type == 1) { cout << "請選擇您的需求:" << endl; cout << "1.修改密碼 2.出題 3.登出" << endl; cin >> cc; if (cc == 1) { cout << "old password:" << endl; cin >> Npassword; if (Npassword != password)cout << "password worng!" << endl; else { cout << "new password:" << endl; cin >> Npassword; password = Npassword; TestMakerList[yournum].getPassword(password); cout << "修改成功!" << endl; } } while (cc == 2) { //cout << "請輸入難度等級(0,1,2,3,4):" << endl; //cin >> a; cout << "請輸入單詞" << endl; cin >> word; length = word.length(); if ((length >= 1) && (length <= 6))b = 0; else if (length <= 10)b = 1; else b = 2; for (i = 1; i <= QuestionNum[b]; i++) { if (QuestionBank[b][i] == word)pdsame = 1; } if (pdsame == 1) { cout << "單詞與詞庫中已有詞匯重復!" << endl; pdsame = 0; } else { TestMakerList[yournum].MakeTest(b, word); testnum++; //TestMakerList[i].getTestnum(testnum); TestMakerList[i].levelup(); cout << "出題成功!" << endl; } cout << "是否繼續出題?1:是 2:否" << endl; cin >> a; if (a == 2)break; } if (cc == 3) { yournum = 0; cout << "成功登出!" << endl; break; } } while (type == 2) { cout << "請選擇您的需求:" << endl; cout << "1.修改密碼 2.答題 3.登出" << endl; cin >> cc; if (cc == 1) { cout << "old password:" << endl; cin >> Npassword; if (Npassword != password)cout << "password worng!" << endl; else cout << "new password:" << endl; cin >> Npassword; password = Npassword; PlayerList[yournum].getPassword(password); cout << "修改成功!" << endl; } if (cc == 2) { cout << "請輸入游戲模式:" << endl; cout << "1、單詞難度不變 2、單詞難度遞增 3、進行輪數增多; 4、單詞顯示時間縮短" << endl; cin >> a; if (a == 1) { cout << "請輸入難度等級(0,1,2):" << endl; cin >> hard; MakeTest1(hard); } if (a == 2) { MakeTest2(); } if (a == 3) { cout << "請輸入難度等級(0,1,2):" << endl; cin >> hard; MakeTest3(hard); } if (a == 4) { cout << "請輸入難度等級(0,1,2):" << endl; cin >> hard; MakeTest4(hard); } } if (cc == 3) { yournum = 0; cout << "成功登出!" << endl; break; } } } } //注冊的情況 要注意判斷ID重復 if (c == 2) { int type = 0; cout << "您是出題人還是答題人,出題人請輸入1,答題人請輸入2:"; cin >> type; if (type == 1) { TestMakerNum++;//都是從1 開始的! yournum = TestMakerNum; int IDrepeat=0; while (1) { cout << "請輸入id(長度大於6),回車結束: "; cin >> id; while (id.length() <= 6) { cout << "請輸入長度大於6的id!" << endl; cin >> id; } for (i = 1; i <= TestMakerNum-1; i++) { if (TestMakerList[i].wrtID() == id) { IDrepeat = 1; } } if (IDrepeat == 0)break; else cout << "ID重復,請重新輸入!" << endl; } cout << "請輸入密碼(長度大於6),回車結束: "; cin >> password; while (password.length() <= 6) { cout << "請輸入長度大於6的密碼!" << endl; cin >> password; } cout << "請輸入姓名,回車結束:"; cin >> name; TestMakerList[yournum].getID(id); TestMakerList[yournum].getName(name); TestMakerList[yournum].getPassword(password); cout << "注冊完成!您的個人信息為:" << endl; if (type == 1) { cout << "出題人:" << endl; cout << "姓名:" << name << endl; TestMakerList[yournum].InforOut(); } } if (type == 2) { PlayerNum++; yournum = PlayerNum; //cout << "!:" << PlayerNum << endl; int IDrepeat=0; while (1) { cout << "請輸入id(長度大於6),回車結束: "; cin >> id; while (id.length() <= 6) { cout << "請輸入長度大於6的id!" << endl; cin >> id; } for (i = 1; i <= PlayerNum-1; i++) { if (PlayerList[i].wrtID() == id) { IDrepeat = 1; } } if (IDrepeat == 0)break; else cout << "ID重復,請重新輸入!" << endl; } cout << "請輸入密碼(長度大於6),回車結束: "; cin >> password; while (password.length() <= 6) { cout << "請輸入長度大於6的密碼!" << endl; cin >> password; } cout << "請輸入姓名,回車結束:"; cin >> name; PlayerList[yournum].getID(id); PlayerList[yournum].getName(name); PlayerList[yournum].getPassword(password); cout << "注冊完成!您的個人信息為:" << endl; if (type == 2) { cout << "答題人:" << endl; cout << "姓名:" << name << endl; PlayerList[yournum].InforOut(); } } } int accord; int find = 0; //查找功能 if (c == 3) { int type = 0; find = 0; cout << "您想查詢出題人還是答題人?1:出題人 2:答題人" << endl; cin >> type; if (type == 1) { cout << "您想按照1姓名 2等級 3出題數 查詢:" << endl; cin >> accord; if (accord == 1) { cout << "請輸入姓名:" << endl; cin >> name; for (i = 1; i <= TestMakerNum; i++) { if (name == TestMakerList[i].wrtName()) { cout << "用戶個人信息為:" << endl; name = TestMakerList[i].wrtName(); cout << "姓名:" << name << endl; TestMakerList[i].InforOut(); find = 1; //break; } } if (find == 0)cout << "用戶不存在!" << endl; } if (accord == 2) { cout << "請輸入等級:" << endl; cin >> level; for (i = 1; i <= TestMakerNum; i++) { if (level == TestMakerList[i].wrtLevel()) { cout << "用戶個人信息為:" << endl; name = TestMakerList[i].wrtName(); cout << "姓名:" << name << endl; TestMakerList[i].InforOut(); find = 1; //break; } } if (find == 0)cout << "用戶不存在!" << endl; } if (accord == 3) { cout << "請輸入出題數:" << endl; cin >> testnum; for (i = 1; i <= TestMakerNum; i++) { if (testnum == TestMakerList[i].wrttestnum()) { cout << "用戶個人信息為:" << endl; name = TestMakerList[i].wrtName(); cout << "姓名:" << name << endl; TestMakerList[i].InforOut(); find = 1; //break; } } if (find == 0)cout << "用戶不存在!" << endl; } } if (type == 2) { cout << "您想按照1姓名 2等級 3答題數 查詢:" << endl; cin >> accord; if (accord == 1) { cout << "請輸入姓名:" << endl; cin >> name; for (i = 1; i <= PlayerNum; i++) { if (name == PlayerList[i].wrtName()) { cout << "用戶個人信息為:" << endl; name = PlayerList[i].wrtName(); cout << "姓名:" << name << endl; PlayerList[i].InforOut(); find = 1; //break; } } if (find == 0)cout << "用戶不存在!" << endl; } if (accord == 2) { cout << "請輸入等級:" << endl; cin >> level; for (i = 1; i <= PlayerNum; i++) { if (level == PlayerList[i].wrtLevel()) { cout << "用戶個人信息為:" << endl; name = PlayerList[i].wrtName(); cout << "姓名:" << name << endl; PlayerList[i].InforOut(); find = 1; //break; } } if (find == 0)cout << "用戶不存在!" << endl; } if (accord == 3) { cout << "請輸入答題數:" << endl; cin >> outpost; for (i = 1; i <= PlayerNum; i++) { if (outpost == PlayerList[i].wrtOutpost()) { cout << "用戶個人信息為:" << endl; name = PlayerList[i].wrtName(); cout << "姓名:" << name << endl; PlayerList[i].InforOut(); find = 1; //break; } } if (find == 0)cout << "用戶不存在!" << endl; } } } //排行榜功能 查詢后直接輸出 if (c == 4)paixu(); if (c == 5)break; } //cout << "1" << endl; user_out.open("D:\\user.txt", ios::out); //cout << "2" << endl; if (user_out) { //cout << "user_out succeed" << endl; user_out << TestMakerNum << endl; /*user_file >> name >> id >> password >> level >> testnum; TestMakerList[i].getID(id); TestMakerList[i].getName(name); TestMakerList[i].getPassword(password); TestMakerList[i].getTestnum(testnum); TestMakerList[i].getLevel(level); for (j = 1; j <= testnum; j++) { int a, b; user_file >> a >> b; TestMakerList[i].PersonalBank[0][j] = a; TestMakerList[i].PersonalBank[1][j] = b; }*/ for (i = 1; i <= TestMakerNum; i++) { name = TestMakerList[i].wrtName(); id = TestMakerList[i].wrtID(); password = TestMakerList[i].wrtPassword(); level = TestMakerList[i].wrtLevel(); testnum = TestMakerList[i].wrttestnum(); user_out << name << ' ' << id << ' ' << password << endl; user_out << level << endl; user_out << testnum << endl; for (j = 1; j <= testnum; j++) { user_out << TestMakerList[i].PersonalBank[0][j] << ' ' << TestMakerList[i].PersonalBank[1][j] << endl; } } user_out << PlayerNum << endl; for (i = 1; i <= PlayerNum; i++) { name = PlayerList[i].wrtName(); id = PlayerList[i].wrtID(); password = PlayerList[i].wrtPassword(); level = PlayerList[i].wrtLevel(); experience = PlayerList[i].wrtExperience(); outpost = PlayerList[i].wrtOutpost(); user_out << name << ' ' << id << ' ' << password << endl; user_out << level << endl; user_out << experience << endl; user_out << outpost << endl; } } if (user_out) { //cout << "user_out close" << endl; user_out.close(); } word_out.open("D:\\word.txt", ios::out); if (word_out) { //cout << "word_out close" << endl; for (i = 0; i <= 2; i++) { word_out << QuestionNum[i] << endl; } for (i = 0; i <= 2; i++) { for (j = 0; j <= QuestionNum[i]; j++) { word_out << QuestionBank[i][j] << ' '; } word_out << endl; } } if (word_out) { //cout << "word_out close" << endl; word_out.close(); } return 0; }
以上為該大作業代碼加一部分注釋