当前位置:网站首页>Xiaobai's bald Road

Xiaobai's bald Road

2020-12-08 13:33:37 osc_ bwwgdzfr

The seventh study notes
switch Branch statement
switch ( Shaping expression )
{
Statement item ;
}
(switch You can nest )
Statement item
case Integral constant expression :
sentence ;
break;
// break Decide to export , When to let the program jump out and output the result
Only by matching can we make switch Statement implementation branch , But it doesn't have to be added
Columns such as
// {
case 1:
case 2:
case 3:
…printf("???");
case 4:
case 5:
…printf(".....");
break;
default:
printf("……");
break;
}
break In the last case Add a word to the sentence break; Develop good coding style and habits
/
default sentence
switch The value of does not match all with case When labeling ,default The following statement will be executed
Loop statement
while
grammar
while()
{
sentence ;
}
1.
#include<stdio.h>
int main()
{
int i=0;
while(i <10)
{
printf("%d ",i);
i++;
}
The result is 0 1 2 3 4 5 6 7 8 9
2.
#include<stdio.h>
int main()
{
int i=0;
while(i <10)
{
if(5 == i)
break; End cycle
printf("%d ",i);
i++;
}
The result is 0 1 2 3 4
3.
#include<stdio.h>
int main()
{
int i=0;
while(i <10)
{
if(5 == i)
continue;
printf("%d ",i);
i++;
}
The result is 0 1 2 3 4 With a flashing cursor
4.
#include<stdio.h>
int main()
{
int i=0;
while(i <10)
{
i++;
if(5 == i)
continue; Terminate the loop
printf("%d ",i);
}
result 1 2 3 4 6 7 8 9
/
EDF = end of file
























































































版权声明
本文为[osc_ bwwgdzfr]所创,转载请带上原文链接,感谢
https://chowdera.com/2020/12/20201208133311494f.html