switch case和return的用法
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了switch case和return的用法相关的知识,希望对你有一定的参考价值。
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)的语句,是不是当返回数据给函数时,就算函数调用完趁里?
百度知道不支持缩进,看代码累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++;
``````
参考技术A 不光是switch case。。。
遇到return 就是退出该函数了,如果是void的类型的函数,可以直接写"return;"本回答被提问者采纳 参考技术B 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 参考技术C 是的 不管什么时候 遇到return 就表示函数调用结束了 参考技术D 是的,执行到return函数就退出了
case语句用法
参考技术A switch(表达式)case 常量表达式1:语句1;
case 常量表达式2:语句2;
case 常量表达式3:语句3;
........
case常量表达式n:语句n;
default :语句n+1;//default为默认语句
例如要求按照考试成绩的等级输出百分制分数段,可以用switch语句实现
switch(grace)
case 'A':printf("85~100\n");
case 'B':printf("70~84\n");
case 'C':printf("60~69\n");
case 'D':printf("<60\n");
default :printf("error\n");
以上是关于switch case和return的用法的主要内容,如果未能解决你的问题,请参考以下文章