您的位置:首页 > 其它

运用switch语句实现选择效果

2013-02-12 17:44 253 查看
#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);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: