溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

Python函數(shù)模塊化程序設(shè)計(jì)的方法

發(fā)布時(shí)間:2022-04-06 16:53:35 來源:億速云 閱讀:295 作者:iii 欄目:編程語言

這篇文章主要介紹“Python函數(shù)模塊化程序設(shè)計(jì)的方法”的相關(guān)知識,小編通過實(shí)際案例向大家展示操作過程,操作方法簡單快捷,實(shí)用性強(qiáng),希望這篇“Python函數(shù)模塊化程序設(shè)計(jì)的方法”文章能幫助大家解決問題。

  1. #include <stdio.h>

  2. int main()  

  3. {  

  4.     int iChioce;  

  5.     do

  6.     {  

  7.         printf("*  1. 吃飯\n");  

  8.         printf("*  2. 睡覺\n");  

  9.         printf("*  3. 打豆豆\n");  

  10.         printf("*  0. 退出\n");  

  11.         printf("*  請選擇(0-3):");  

  12.         scanf("%d", &iChioce);  

  13.         //選擇后的處理

  14.         if (iChioce==1)  

  15.             printf("我吃吃吃...\n");  

  16.         else if (iChioce==2)  

  17.             printf("我睡覺覺...\n");  

  18.         else if (iChioce==3)  

  19.             printf("我打打打...\n");  

  20.         else if (iChioce==0)  

  21.             break;  

  22.         else

  23.         {  

  24.             printf("\007選擇錯誤!\n");  

  25.             continue;  

  26.         }  

  27.         printf("恭喜你完成了一項(xiàng)工作!\n");  

  28.     }  

  29.     while(1);  

  30.     return 0;  

  31. }  

  1. #include <stdio.h>

  2. int choose()  

  3.     void eat();  

  4.     void sleep();  

  5.     void hitdoudou();  

  6. int main()  

  7. {  

  8.     int iChioce;  

  9.     do

  10.     {  

  11.         iChioce=choose();  

  12.         if (iChioce==1)  

  13.             eat();  

  14.         else if (iChioce==2)  

  15.             sleep();  

  16.         else if (iChioce==3)  

  17.             hitdoudou();  

  18.         else if (iChioce==0)  

  19.             break;  

  20.         else

  21.         {  

  22.             printf("\007選擇錯誤!\n");  

  23.             continue;  

  24.         }  

  25.         printf("恭喜你完成了一項(xiàng)工作!\n");  

  26.     }  

  27.     while(1);  

  28.     return 0;  

  29. }  



  30. int choose()  

  31. {  

  32.     int i;  

  33.     printf("\n*  1. 吃飯\n");  

  34.     printf("*  2. 睡覺\n");  

  35.     printf("*  3. 打豆豆\n");  

  36.     printf("*  0. 退出\n");  

  37.     printf("*  請選擇(0-3):");  

  38.     scanf("%d", &i);  

  39.     return i;  

  40. }  



  41. void eat()  

  42. {  

  43.     printf("我吃吃吃... ...\n");  

  44. }  



  45. void sleep()  

  46. {  

  47.     printf("我睡覺覺... ...\n");  

  48. }  



  49. void hitdoudou()  

  50. {  

  51.     printf("我打打打... ...\n");  

  52. }  


關(guān)于“Python函數(shù)模塊化程序設(shè)計(jì)的方法”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識,可以關(guān)注億速云行業(yè)資訊頻道,小編每天都會為大家更新不同的知識點(diǎn)。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI