亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

C語(yǔ)言程序打豆豆(函數(shù)版)

 更新時(shí)間:2019年02月19日 09:46:52   作者:迂者-賀利堅(jiān)  
今天小編就為大家分享一篇關(guān)于C語(yǔ)言程序打豆豆(函數(shù)版),小編覺(jué)得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來(lái)看看吧

【項(xiàng)目】

設(shè)計(jì)一個(gè)程序,能重復(fù)地在顯示下面的信息:

  • 1. 吃飯
  • 2. 睡覺(jué)
  • 3. 打豆豆
  • 0. 退出
  • 請(qǐng)選擇(0-3):

根據(jù)用戶輸入的選項(xiàng),輸出一句提示性的話語(yǔ)(將來(lái)會(huì)對(duì)應(yīng)實(shí)現(xiàn)某個(gè)功能)。輸入0,則退出。
要求將各功能定義專門的函數(shù)。

參考解答:

#include <stdio.h>
#define EAT '1'
#define SLEEP '2'
#define HITDOUDOU '3'
#define CRY '4'
#define WITHDRAW '0'
char getChoice();
void eat();
void sleep();
void hitdoudou();
void cry();
int main()
{
  char cChioce;
  while(1)
  {
    cChioce = getChoice();
    if (cChioce==EAT)
      eat();
    else if (cChioce==SLEEP)
      sleep();
    else if (cChioce==HITDOUDOU)
      hitdoudou();
    else if (cChioce==CRY)
      cry();
    else if (cChioce==WITHDRAW)
      break;
    else
    {
      printf("\007選擇錯(cuò)誤!\n");
    }
  }
  return 0;
}
char getChoice()
{
  char c;
  printf("\n ********************\n");
  printf(" * 1. 吃飯     *\n");
  printf(" * 2. 睡覺(jué)     *\n");
  printf(" * 3. 打豆豆    *\n");
  printf(" * 4. 找豆豆媽訴苦 *\n");
  printf(" * 0. 退出     *\n");
  printf(" ********************\n");
  printf(" 請(qǐng)選擇(0-4):");
  fflush(stdin);
  scanf("%c", &c);
  return c;
}
void eat()
{
  printf(" 我吃吃吃... ...\n");
}
void sleep()
{
  printf(" 我睡覺(jué)覺(jué)... ...\n");
}
void hitdoudou()
{
  printf(" 我打打打... ...\n");
}
void cry()
{
  printf(" 哇! 你家豆豆骨頭硬,害得我手疼... ...\n");
}

總結(jié)

以上就是這篇文章的全部?jī)?nèi)容了,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,謝謝大家對(duì)腳本之家的支持。如果你想了解更多相關(guān)內(nèi)容請(qǐng)查看下面相關(guān)鏈接

相關(guān)文章

最新評(píng)論