2022年小學(xué)數(shù)學(xué)運算游戲)_第1頁
2022年小學(xué)數(shù)學(xué)運算游戲)_第2頁
2022年小學(xué)數(shù)學(xué)運算游戲)_第3頁
2022年小學(xué)數(shù)學(xué)運算游戲)_第4頁
2022年小學(xué)數(shù)學(xué)運算游戲)_第5頁
已閱讀5頁,還剩17頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)

文檔簡介

1、精選學(xué)習(xí)資料 - - - 歡迎下載學(xué)校數(shù)學(xué)運算嬉戲 c+版 ( elementary school math games c+edition)#包含 iostream > <#包括<< ctime >#包括<文件 cstdlib >#包括<字符串 >#包括<<數(shù)學(xué);” 使用名稱空間;雙層(雙精氨酸);國際 table; 無效();無效 cut ;無效 mul ; 無效 div ;/ / .主函數(shù).精品學(xué)習(xí)資料精選學(xué)習(xí)資料 - - - 歡迎下載無效 mainint key = 1;/掌握下面而循環(huán)的鑰匙當(dāng)(鍵 = 1 )系統(tǒng)(“

2、cls”);table關(guān)鍵=;cout << “*退出*”<< endl ;/ / .界面函數(shù).國際 table /進(jìn)入界面及挑選(表函數(shù))cout << “歡迎進(jìn)入數(shù)學(xué)小嬉戲”<< endl ; / /挑選欄cout << “*”<< endl ;精品學(xué)習(xí)資料精選學(xué)習(xí)資料 - - - 歡迎下載cout << “* 加法:請輸入1 * ”<< endl ;cout << “*”<< endl ; cout << “* 減法:請輸入2 * ”<< end

3、l ; cout << “*”<< endl ; cout << “* 乘法:請輸入3 * ”<< endl ; cout << “*”<< endl ; cout << “* 除法:請輸入4 * ”<< endl ; cout << “*”<< endl ; cout << “* 退出:請輸入0 * ”<< endl ; cout << “*”<< endl ; int n;char的 3 ; / / 3 只能( 0;_;_)

4、或( _;0;_)或( _;_;0);而輸入正確就為( 0 / 1 / 2 / 3 / 4 / 0;_)cout << “請輸入你的挑選:”;cin;同時( s 1 )!=“0”) | |(s 1 = =“0”&的 0 != 0 ”&精品學(xué)習(xí)資料精選學(xué)習(xí)資料 - - - 歡迎下載的 0 != 1 ”&的 0 != 2 ”&的 0 != 3 ”&的 0 != 4 )/ 保證得到正確輸入( 0.1.2.3.4) cout <<“輸入錯誤!再次輸入:“;cin;假如( s 0 = = '0')返回 0; / /使用者要退

5、出,返回0 給關(guān)鍵,終止主要函數(shù)中的而循環(huán)每組的 0 - '0'; / /炭型轉(zhuǎn)化為 int型開關(guān)( n)/ 加減乘除運算的挑選 案例 1:();系統(tǒng)(“華彩”) ;休息; 案例 2: cut;系統(tǒng)(“華彩”) ;休息;案例 3: mul ;系統(tǒng)(“華彩”) ;休息; 案例 4: div;系統(tǒng)(“華彩”) ;休息;return 1; /從加.減.乘.除函數(shù)挑選n / n后退出加.減.乘.除函數(shù);再返回1 給關(guān)鍵,從而進(jìn)入主要中循環(huán)進(jìn)入界面函數(shù)精品學(xué)習(xí)資料精選學(xué)習(xí)資料 - - - 歡迎下載/ / .判定為否輸入 y 或 n / n及保證輸入 y 或 n /n .無效的 yn(ch

6、ar的 )cin;同時( s 1 )!=“0”) | |(s 1 = =“0”&的 0 != y 和 s 0 != y 和s 0 != n和 s 0 ! = n ) / 保證得到正確輸入( y.y.n.n) cout <<“輸入錯誤!再次輸入:“;cin>>s;/ / .判定正誤(雙型) .空那(雙.雙和.二重.計數(shù).焦呆子 )假如(總和 = n ) cout <<“答案正確;” << endl <<“連續(xù)新的題目請輸入y / y,精品學(xué)習(xí)資料精選學(xué)習(xí)資料 - - - 歡迎下載不連續(xù)請輸入 n / n :”;yn(呆子);其他

7、的計數(shù)+;/.得到正確輸入(你算得的答案)的函數(shù).(如輸入字母減字母或數(shù)字減字母就以后無論輸入什么都顯示為輸入錯誤?)雙 getrightinput字符 s 80 ;int k;做正確的輸入;k 1; cin;精品學(xué)習(xí)資料精選學(xué)習(xí)資料 - - - 歡迎下載對于( int = i 0;i < 80;i + +)假如( static_cast< >(int的 我 ) > 64 和 static_cast< >(int的 我 )< 91 )/ 曾用此方法限制其他字符輸入但不知為何結(jié)果出乎意料之外?cout << “輸入錯誤!再次輸入! :”;k

8、0;假如( static_cast < >(int 的 我 ) > 96 和 static_cast < >(int 的 我 )< 123 ) / 此方法也有瑕疵:輸入 n(n 3)個字母時后, 再輸入 0 至 n-2 個數(shù)字也報告錯誤?輸入 > = n-1 個數(shù)才算輸入正確!cout << “輸入錯誤!再次輸入! :”;k 0;假如( k0)精品學(xué)習(xí)資料精選學(xué)習(xí)資料 - - - 歡迎下載打破;當(dāng)( k 0);返回對( s); / /上面兩個假如語句保證輸入字母時報告錯誤,但輸入字符時不會報告錯誤,且對(s)返回 0(曾嘗試使電腦在輸入字符

9、時報告錯誤但失?。? / .加法函數(shù) .無效()焦仔 3 ;呆子 0 = y;而(呆子 0 = = y)| |(呆子 0 = = y)系統(tǒng)(“華彩”);/ /清屏srand ( time (0);精品學(xué)習(xí)資料精選學(xué)習(xí)資料 - - - 歡迎下載雙 n,m,和,計數(shù)0;n = rand % 100 + 1;/ /得到隨機(jī)數(shù)m = rand % 100 + 1;/ /得到隨機(jī)數(shù)cout << “請輸入結(jié)果“ << n << “+”<<我的<<“:”;getrightinput總和=;那( n + m,和計數(shù),打手) ;/ /假如(計數(shù) =

10、= 1 )/ 錯了一次時,計數(shù)才會為1,所以經(jīng)那判定錯誤后才進(jìn)入這里(上面正確者不進(jìn)入這里)cout << “答案錯誤,請再次輸入:”;getrightinput總和=;那( n + m,和計數(shù),打手) ;/ /錯了一次或再判定對錯假如(計數(shù) = = 2 )/ 錯了兩次時,計數(shù)才會為2,so、 afterthe ifright judgethe errorto enter heretheabove is not correct here精品學(xué)習(xí)資料精選學(xué)習(xí)資料 - - - 歡迎下載cout<< "the answer is wrong. please ente

11、r again:" sum=getrightinput ;ifright n+m、 sum、 count、 goon;if count=3 / wrong three times、 asking whether you want to continuecout<<"you'vebeen wrong threetimes、and thecorrectanswer is" <<n+m<<endl "cout<< "continuenewtopic、pleaseenter"y/y &q

12、uot;、do not continue、 please input n/n"yn goon;/rightor wrong isy/y toexittheadd、otherwisethe function returns the interface table function、 and then returned tonormal from the table function main function./ /. subtraction function.精品學(xué)習(xí)資料精選學(xué)習(xí)資料 - - - 歡迎下載void、 cut char goon3; /145 goon0='y&

13、#39;while goon0='y' | goon0='y'system "cls"srand time 0;double、 n、 m、 sum、 count=0; n=rand %100+1;m=rand %100+1;int t;cout<< "please、 input、 the、 of、 result、 <<n<<" - "<<m<<"":" sum=getrightinput ;ifright n-m、 sum、

14、 count、 goon; if count=1精品學(xué)習(xí)資料精選學(xué)習(xí)資料 - - - 歡迎下載cout<< "the answer is wrong. please enter again:" sum=getrightinput ;ifright n-m、 sum、 count、 goon;if count=2cout<< "the answer is wrong. please enter again:" sum=getrightinput ;ifright n-m、 sum、 count、 goon;if count=3cou

15、t<<"you'vebeen wrong threetimes、and thecorrectanswer is" <<n-m<<endl "cout<< "continuenewtopic、pleaseenter"y/y "、do notcontinue、 please input n/n"精品學(xué)習(xí)資料精選學(xué)習(xí)資料 - - - 歡迎下載yn goon;/177/ /. multiplication function. void、 mul char goon3;goon0

16、='y'while goon0='y' | goon0='y'system "cls"srand time 0;double、 n、 m、 sum、 count=0; n=rand %100+1;m=rand %100+1;精品學(xué)習(xí)資料精選學(xué)習(xí)資料 - - - 歡迎下載cout<< "please、 input、 the、 of、 result、 <<n<<、 *" <<m<<":" sum=getrightinput ;ifr

17、ight n*m、 sum、 count、 goon; if count=1cout<< "the answer is wrong. please enter again:" sum=getrightinput ;ifright n*m、 sum、 count、 goon;if count=2cout<< "the answer is wrong. please enter again:" sum=getrightinput ;ifright n*m、 sum、 count、 goon;精品學(xué)習(xí)資料精選學(xué)習(xí)資料 - - - 歡迎下

18、載if count=3cout<<"you'vebeen wrong threetimes、and thecorrectanswer is" <<n*m<<endl "cout<< "continuenewtopic、pleaseenter"y/y "、do not continue、 please input n/n"yn goon;/ /. divide function. if theinput2/3、althoughthe interfaceoutput0.66

19、6667、butactually not、 so when the user input 0.66666 7 時仍報告錯誤 . void div char goon 3; goon 0 = 'y'while goon 0 = = 'y' | | goon 0 = = 'y'精品學(xué)習(xí)資料精選學(xué)習(xí)資料 - - - 歡迎下載system "cls"srand hour 0;double n、 m、 sum、 count = 0; n = rand % 100 + 1;m = rand % 100 + 1;cout < < "please input the result of" < < n < < "/" < < m < <" 大于 5 位小數(shù)的舍去 5 位以后的數(shù) :"n = n / m * 100000; / /沒用這行和下面兩行時輸入0. 66666 7時報告錯誤但他給出答案時卻給0. 66666 7.我推測前面的 0. 666667 只為顯現(xiàn)出來的數(shù)而實際為0. 66666666666666666、

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論