运用switch语句实现选择效果

#include <stdio.h>

int main()

{
  void act1(int,int),act2(int,int);
  char ch;
  int a=2013,b=52;
  ch=getchar();
  switch(ch)
  {
    case 'a':
    case 'A':act1(a,b);break;
    case 'b':
    case 'B':act2(a,b);break;
    default:putchar('\a'); //发出警告声音
  }
  return 0;
}

void act1(int x,int y)

{
  printf("%d\n",x+y);
}

void act2(int x,int y)

{
  printf("%d\n",x*y);
}

 

posted @ 2013-02-12 17:44  吾爱扣扣  阅读(371)  评论(1)    收藏  举报