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)的语句,是不是当返回数据给函数时,就算函数调用完趁里?
展开
5个回答
展开全部
百度知道不支持缩进,看代码累
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++;
``````}
}
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++;
``````}
}
展开全部
不光是switch case。。。
遇到return 就是退出该函数了,如果是void的类型的函数,可以直接写"return;"
遇到return 就是退出该函数了,如果是void的类型的函数,可以直接写"return;"
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
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
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
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
是的 不管什么时候 遇到return 就表示函数调用结束了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
是的,执行到return函数就退出了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |