
#include <stdio.h>
int main() {
//while()
char CH;
int count=0;
while(count < 10){
CH = getchar();
if(CH != ' ')
continue;
putchar(CH);
count++;
}
printf("Hello, World!\n");
return 0;
}
#include <stdio.h>
int main() {
char ch;
int cunt;
int i;
for(cunt=0;cunt<10;cunt++){
ch = getchar();
for(i=0;i<5;i++){
if (ch != ' ')
continue;
putchar(ch);
printf("我是內層循環的---小可愛!!!\n");
}
printf("我是外層循環的---小可愛!!!\n");
printf("如果continue語句在嵌套循環內,則只會影響包含continue的內層循環,不影響外層循環!!!\n");
}
printf("Hello, World!\n");
return 0;
}

continue跳出本次循環,執行下一次循環。

break跳出整個循環
#include <stdio.h>
int main() {
//while()
char CH;
int count=0;
while(count < 10){
CH = getchar();
if(CH != ' ')
break;
putchar(CH);
count++;
}
printf("Hello, World!\n");
return 0;
}
#include <stdio.h>
int main() {
char ch;
int cunt;
int i;
for(cunt=0;cunt<10;cunt++){
ch = getchar();
for(i=0;i<5;i++){
if (ch != ' ')
break;
putchar(ch);
printf("我是內層循環的---小可愛!!!\n");
}
printf("我是外層循環的---小可愛!!!\n");
printf("如果continue語句在嵌套循環內,則只會影響包含continue的內層循環,不影響外層循環!!!\n");
}
printf("Hello, World!\n");
return 0;
}
#include <stdio.h>
int main() {
char ch;
int cunt;
int i;
for(cunt=0;cunt<10;cunt++){
ch = getchar();
for(i=0;i<5;i++){
if (ch != ' ')
break;
putchar(ch);
printf("我是內層循環的---小可愛!!!\n");
}
if (ch != ' ')
break;
printf("我是外層循環的---小可愛!!!\n");
printf("如果continue語句在嵌套循環內,則只會影響包含continue的內層循環,不影響外層循環!!!\n");
}
printf("Hello, World!\n");
return 0;
}
/* animals.c -- uses a switch statement */
#include <stdio.h>
#include <ctype.h>
int main(void)
{
char ch;
printf("Give me a letter of the alphabet, and I will give ");
printf("an animal name\nbeginning with that letter.\n");
printf("Please type in a letter; type # to end my act.\n");
while ((ch = getchar()) != '#')
{
if('\n' == ch)
continue;
if (islower(ch)) /* lowercase only */
switch (ch)
{
case 'a' :
printf("argali, a wild sheep of Asia\n");
break;
case 'b' :
printf("babirusa, a wild pig of Malay\n");
break;
case 'c' :
printf("coati, racoonlike mammal\n");
break;
case 'd' :
printf("desman, aquatic, molelike critter\n");
break;
case 'e' :
printf("echidna, the spiny anteater\n");
break;
case 'f' :
printf("fisher, brownish marten\n");
break;
default :
printf("That's a stumper!\n");
} /* end of switch */
else
printf("I recognize only lowercase letters.\n");
while (getchar() != '\n')
continue; /* skip rest of input line */
printf("Please type another letter or a #.\n");
} /* while loop end */
printf("Bye!\n");
return 0;
}

遇到break后跳出,繼續匹配switch。

順序執行每個case。
1.國產替代摸不著門兒?快來回看兆易創新直播課!
2.開源的RISC-V能否成為中國“缺芯”的解藥?
3.樹莓派Pico:僅4美元的MCU
4.MCU支持AI功能的多種原因~
5.2020年,我學習到的20條軟件工程準則~
6.狀態機思路在嵌入式開發中的應用~

免責聲明:本文系網絡轉載,版權歸原作者所有。如涉及作品版權問題,請與我們聯系,我們將根據您提供的版權證明材料確認版權并支付稿酬或者刪除內容。