freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內容

c程序設計經典300例1of(編輯修改稿)

2025-08-26 00:13 本頁面
 

【文章內容簡介】 //求輸入數(shù)字的所有真因子 int *zhen_yinzi = new int[shu]。//不知道真因子有多少個,所以用指針指向 int index = 0。//個數(shù)索引變量,初始化為0 int sum = 0。//所有真因子的總和 zhen_yinzi[0] = 1。//所有數(shù)字都有一個真因子為1 for (int i = 2。 i shu。 i++)//循環(huán)找所有因子 { if(shu % i == 0)//表示該因子為真因子 { index ++。 zhen_yinzi[index] = i。 } } for(int j = 0。 j = index。 j++)//將所有真因子加和 { sum += zhen_yinzi[j]。 } delete[] zhen_yinzi。//釋放內存 zhen_yinzi = NULL。 if(sum == shu)//如果真因子之和等于數(shù)字本身,即為完數(shù) cout數(shù)字shu是完數(shù)endl。 else cout數(shù)字shu不是完數(shù)endl。 return 0。}21******************************************************include iostreamusing namespace std。int main(){ int a = 9。 int result = 1。//結果 for(int i = 1。 i = 9。 i++)//循環(huán) { result *= a。 } cout9的9次方等于resultendl。 return 0。}22*********************************include iostreamusing namespace std。define Pi define code 1234int main(){ cout常量例子1:1endl。 cout常量例子2:trueendl。 cout常量例子3:3456endl。 cout常量例子4:Piendl。 cout常量例子5:codeendl。 const double Pi1 = 。 cout常量例子6:Pi1endl。 return 0。}23******************************************include iostreamusing namespace std。double capital=。//金額double cal(int num, double quantity){ switch(num) { case 0: return quantity*。 case 1: return quantity*。 case 2: return quantity*。 case 3: return quantity*。 case 4: return quantity*。 case 5: return quantity*。 case 6: return quantity*。 case 7: return quantity*。 }}int main(){ cout提示:本店提供8種水果,如下(左邊為水果編號及名稱,右邊為其單價)endl。 cout0西瓜 , 1木瓜 , 2哈密瓜 , \n 4梨 , 5柚子 , 6彌猴桃 , 7山楂 endl。 int num_choice=0。//幾種選擇 while(1) { int Y_N。 cout請輸入您要購買的種類數(shù)量:。 cinnum_choice。 if(num_choice==0)//不買東西 { cout您確定只是看看嗎?要不買點吧?繼續(xù)請按1,否則請按0,直接退出endl。 cinY_N。 if(Y_N==0) { cout退出成功!endl。 break。 } else if(Y_N==1) {} else cout不要搗亂,按規(guī)定輸,親endl。 } else { cout種類編號分別為:。 int *choice=new int[num_choice]。 double *quantity_choice=new double[num_choice]。 for(int i=0。inum_choice。i++) cinchoice[i]。//種類編號 cout請輸入對應購買種類的重量:。 for(int i=0。inum_choice。i++) cinquantity_choice[i]。 for(int j=0。jnum_choice。j++)//計算金額 { capital += cal(choice[j], quantity_choice[j])。 } cout繼續(xù)購物嗎?繼續(xù)請按1,否則請按0,開始結算endl。 cinY_N。 if(Y_N==0) { cout開始結算,請付capital元endl。 break。 } else if(Y_N==1) {} else cout不要搗亂,按規(guī)定輸,親endl。 } } delete[] choice。 choice=NULL。 delete[] quantity_choice。 quantity_choice=NULL。 return 0。}24******************************************************include iostreamusing namespace std。int main(){ bool switcher=false。//開關狀態(tài) bool switcher_ex=false。//前一時刻的開關狀態(tài) char ch。 while(1) { cout是否要響應命令?是:輸入Y,不是:輸入N,退出:Qendl。 cinch。 if(ch==39。Y39。) { switcher_ex=switcher。 switcher=true。 if(switcher_ex) cout繼續(xù)響應命令!endl。 else cout開始響應命令!endl。 } else if(ch==39。N39。) { switcher_ex=switcher。 switcher=false。 if(switcher_ex) cout暫停命令響應!endl。 else cout繼續(xù)等待命令響應!endl。 } else if(ch==39。Q39。) { cout退出成功!endl。 break。 } else { cout輸入錯誤!endl。 } } return 0。}25******************************************************include iostreamusing namespace std。int main(){ int number。 while(1) { cout請輸入一個整數(shù),必須在150之間endl。 cinnumber。 if((number=50) amp。amp。 (number=0)) { cout符合條件endl。 break。 } } return 0。}26********************************************************include iostreamusing namespace std。int main(){ int quantity_goods=10000。//總共的物品數(shù) int number_staff=189。//員工數(shù)目 int goods_remain。//剩余物品 goods_remain = quantity_goods % number_staff。 cout余下的物品數(shù):goods_remainendl。 return 0。}27*******************************************************include iostreamusing namespace std。int main(){ int a = 6。//一個整型變量 int int_size。//整型變量的字節(jié)大小 int_size = sizeof(a)。 cout變量a所占的字節(jié)大小為:int_sizeendl。 return 0。}28************************************************************include iostreamusing namespace std。//信號燈的狀態(tài)時亮時滅,現(xiàn)計數(shù),如果次數(shù)為偶則亮,如果次數(shù)為奇則不亮//需要注意++的位置int main(){ int count=1。 cout滅endl。 for(。count10。) { int a。 a = ++count。 if(a % 2 == 0)//偶數(shù) cout亮endl。 else cout滅endl。 } return 0。}29**********************************************include iostreaminclude stringusing namespace std。int main(){ cout請輸入一串數(shù)字,不能有空格等非數(shù)字字符endl。 string str。 int count_0=0。//0出現(xiàn)的次數(shù) cinstr。//輸入 cout數(shù)字0出現(xiàn)的次數(shù)為:。 for(int i=0。i()。i++)//判斷 { if(str[i]==39。039。)//如果等于0 count_0++。 else {} } coutcount_0endl。 return 0。}30*************************************************include iostreamusing namespace std。int main(){ int migong[5][5]={{0,0,1,1,1},{1,0,0,1,1},{1,1,0,1,1},{1,1,0,0,1},{1,1,1,0,2}}。//迷宮 int row,column。//行列 int path_row[25]。//通行路徑的行 int path_column[25]。//通行路徑的列 for(int i=0。i25。i++)//初始化 path_row[i]=path_column[i]=0。 row=0。 column=0。 int count=0。//次數(shù) do//按行循環(huán),先處理,后判斷 { column = 0。 do//按列循環(huán),先處理,后判斷 { switch(migong[row][column]) { case 0://可以通行 path_row[count]=row。 path_column[count]=column。 cout加油,快要找到出口了endl。 count++。 break。 case 1: cout不可通行endl。 break。 case 2: path_row[count]=row。 path_column[count]=column。 cout到達出口endl。 count++。 break。 } column += 1。 }while(column5)。 row += 1。 }while(row5)。 cout到達出口的路徑為:endl。 for(int j=0。j
點擊復制文檔內容
公司管理相關推薦
文庫吧 www.dybbs8.com
備案圖片鄂ICP備17016276號-1