switch case和return的用法

intb(inta){case(1):a+=1;returna;case(2):a+=2;returna;case(3):a+=3;returna;}这段函数定义中当a=... int b(int a) { case(1):a+=1;return a; case(2):a+=2;return a; case(3):a+=3;return a; } 这段函数定义中当a=1时为社么只运行case(1)的语句,是不是当返回数据给函数时,就算函数调用完趁里? 展开
 我来答
召皎03k
2011-07-02 · TA获得超过1872个赞
知道小有建树答主
回答量:3040
采纳率:0%
帮助的人:0
展开全部
百度知道不支持缩进,看代码累

switch(a%3)
{
``case 0: //当(a%3)==0时执行下面的语句直到遇到break或return
````m++;
````break;
``case 1: //当(a%3)==1时执行下面的语句直到遇到break或return
````m++;
``````switch(b%2) // 此switch在m++执行后继续执行
``````{
````````case 0: //当b%2==0时执行下面的语句直到遇到break或return
``````````m++;
``````````break;
````````default: //当b%2 !=0时执行下面的语句直到遇到break或return或后面没语句了自然结束此switch
``````````m++;
``````}
}
icecoobe
推荐于2017-09-08 · TA获得超过1989个赞
知道小有建树答主
回答量:1058
采纳率:100%
帮助的人:1111万
展开全部
不光是switch case。。。
遇到return 就是退出该函数了,如果是void的类型的函数,可以直接写"return;"
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
匕禾页8541
2011-07-01 · TA获得超过6.4万个赞
知道大有可为答主
回答量:2.9万
采纳率:0%
帮助的人:1958万
展开全部
oh woahh, oh woahh, oh woahhh
you know you love me
i know you care
and i would never, not be there
you are my love
you are my heart
and we would never, ever, ever be apart
are we an item?
girl quit playin'
we're just friends,
what are you sayin'
take another look right in my eyes
my first love, broke my heart for the first time
and now
i'm like
baby, baby, baby noo
i'm like
baby, baby, baby noo
i'm like
baby, baby, baby noo
i thought you'd always be mine (mine)
baby, baby, baby noo
i'm like
baby, baby, baby noo
i'm like
baby, baby, baby noo
i thought you'd always be mine
for you, i would have done whatever
and no i can't believe we're not together
and i'm gonn' play it cool
while i'm losin you
i'll buy you anything
i'll buy you any ring
cause i'm in pieces
so come fix me
shake me til' you can wake me from this bad dream*
i'm goin down, down, dooown
i just can't believe my first love will be around
baby, baby, baby noo
i'm like
baby, baby, baby noo
i'm like
baby, baby, baby noo
i thought you'd always be mine (mine)
baby, baby, baby noo
i'm like
baby, baby, baby noo
i'm like
baby, baby, baby ohh
i thought you'd always be mine
When i was 13 i had my first love
Here was nobody to compare my baby
And nobody came between us or could ever come above
She had me goin crazy
Oh i was starstruck.
She woke me up daily dont need no starbucks
She made my heart pound
Asking for a beat when i see her in the street
And in the school on the playground
But i really wanna see her on the weekends
She knows she got me dazy
Cause she was so amazing and now my heart is breaking
But i just keep on sayin
baby, baby, baby noo
i'm like
baby, baby, baby noo
i'm like
baby, baby, baby noo
i thought you'd always be mine
baby, baby, baby noo
i'm like
baby, baby, baby noo
i'm like
baby, baby, baby noo
i thought you'd always be mine
i'm gone yeahh... i'm all gone
yeahh... now i'm all gone
yeahh... yeah now i'm all gone
, gone, gone, gone
i'm gonee
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
百度网友810698b
2011-06-30 · 超过12用户采纳过TA的回答
知道答主
回答量:69
采纳率:0%
帮助的人:38.1万
展开全部
是的 不管什么时候 遇到return 就表示函数调用结束了
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
wanfustudio
2011-06-30 · TA获得超过1万个赞
知道大有可为答主
回答量:5513
采纳率:100%
帮助的人:3777万
展开全部
是的,执行到return函数就退出了
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(3)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式