c语言switch语句中break的用法
英文屋
人气:2.49W
在C语言中break的意思就是执行到这一步下面的都不执行了。比如从case 1开始执行,如果没break,则下面的语句都会执行,直到遇到下一个break或者当前代码块运行完毕。下面小编就来为大家介绍c语言switch语句中break的用法。 #include<stdio.h>intmain(){intge,shi,bai,qian,wan,num,place; printf("输入一个0-99999的正整数:n");scanf("%d",&num);if(num>9999)place=5;elseif(num>999)place=4;elseif(num>99)place=3;elseif(num>9) place=2; elseplace=1; printf("这个数一共%d位。n",place);wan=num/10000; qian=(num-wan*10000)/1000; bai=(num-wan*10000-qian*1000)/100;shi=(num-wan*10000-qian*1000-bai*100)/10;ge=num-wan*10000-qian*1000-bai*100-shi*10;switch(place) { case5:printf("万位数为%d;n",wan);case4:printf("千位数为%d;n",qian);case3:printf("百位数为%d;n",bai);case2:printf("十位数为%d;n",shi);case1:printf("个位数为%d;n",ge);/*case1:printf("个位数为%d;n",ge);//break;case2:printf("十位数为%d;n",shi);//break;case3:printf("百位数为%d;n",bai);//break;case4:printf("千位数为%d;n",qian);//break;case5:printf("万位数为%d;n",wan);*/} switch(place) { case1:printf("反序数为%d.n",ge);break; case2:printf("反序数为%d%d.n",ge,shi);break; case3:printf("反序数为%d%d%d.n",ge,shi,bai);break; case4:printf("反序数为%d%d%d%d.n",ge,shi,bai,qian);break;case5:printf("反序数为%d%d%d%d%d.n",ge,shi,bai,qian,wan);}return0; }
相关文章:
- 蒋健棠英语实用句子(81):She was decked out in her nicest&nbs
- c语言中continue和break的用法
- c语言switch的用法
- The english we speak(BBC教学)第176期:Corporate speak 企业用语
- 蒋健棠英语实用句子(103):I think it will catch on quickly
- c语言中break的用法
- c语言中switch的用法
- c语言break的用法
- c语言中getchar的用法函数用法
- The english we speak(BBC教学)第74期: throw the book at用规矩严惩
热门推荐
- 1c语言while的用法
- 2c语言中while的用法
- 3The english we speak(BBC教学)第196期:water off a duck's back 毫无影响
- 4The english we speak(BBC教学)第180期:Everything but the kitchen sink 带的东西太多了
- 5The english we speak(BBC教学)第23期:weather idioms 有关天气的谚语
- 6The english we speak(BBC教学)第291期:White collar worker/blue collar worker 白领和蓝领
- 7c语言里while的用法
- 8The english we speak(BBC教学)第243期:Social media words 社交媒体用语
- 9蒋健棠英语实用句子(85):His work has been dissected
- 10每日一句口语 第543期:brings you back down to earth回到现实 每日一句|bring|back|earth
猜你喜欢
- 1c语言中do while的用法
- 2bank deposits subject to withdrawal by check是什么意思、英文翻译及中文解释
- 3校园英语口语习惯用语第177期:know something backwards
- 4英语寓言故事 The Bitch and Her Whelps
- 5校园英语口语习惯用语 第177期:know something backwards
- 6The english we speak(BBC教学)第20期:what's his face 那个长相的人
- 7The english we speak(BBC教学)第143期:Baby Talk 儿童用语
- 8名人婚礼防泄密的那些招数 How Celebrities Keep Their Weddings a Secret
- 9蒋健棠英语实用句子(79):He withered away from overwork
- 10c语言do while的用法
- 11The english we speak(BBC教学)第194期:throw the baby out with the bathwater
- 12c语言getchar的用法
- 13The english we speak(BBC教学)第210期:Wow factor 令人惊叹的元素
- 14switch的用法和短语例句
- 15The english we speak(BBC教学)第139期:Two phrases about fatherhood 两个与父亲身份有关的短语
今日热门
- 1C语言的读书心得
- 2最新switch用法语句大全
- 3The english we speak(BBC教学)第202期:Internet speak 网络用语
- 4C语言switch语句
- 5bank loans which are based on funds which have been allocated by the state to the bank是什么意思、英文翻译及中文解
- 6每日一句口语 第2509期:The world may be full of cheating, however we never lack friends w
- 7文言文中而的用法
- 8蒋健棠英语实用句子(120):I have to pick up the slack
- 9初中语文文言文固定结构的用法
- 10bank loans which are based on funds which have been allocated by the state to the bank是什么意思、英文翻译及中文解