6_ѭ*ṹ(2 ѭbreakcontinue)

ʱ:2021-09-24 10:11:50

6 ѭ*ṹ ѭǶס ѭǶסbreak continueȣ continue

Ҫ
? ? ?

ǶѭӦþ break break continue continue

2

? ǶѭӦþ
һѭһѭ ѭУ͹Ƕѭ whiledo-whileforѭ Ƕףwhileѭdo-whileѭforѭ ڣذһѭ

3

˼ָеȤζѧ
30ˣˡŮ˺Сһҷ 30ˣˡŮ˺С Է50 ÿ˸3  Է50ÿ˸3ÿ Ů˸2ÿС1ˡ Ů˸2ÿС1ˡŮ ˺Смˣ ˺Смˣ ⷽ
? x + y + z = 30 ? ? 3 x + 2 y + z = 50 (1) (2)

ٷ

4

1: ѭx,y,z 1: ѭx,y,zȫܵ x,y,zȫܵ
#include <stdio.h> int main(void) { int man, woman, child; printf("Man \t Woman \t Child\n"); for (man=1; man<=30; man++) { for (woman=1; woman<=30; woman++) { for (child=1; child<=30; child++) { if (man + woman + child == 30 && 3*man+2*woman+child == 50) { printf("%3d \t %5d \t %8d\n", man, woman, child); } } } }

return 0; }
5

2 2Ľ㷨
#include <stdio.h> int main(void) { int man, woman, child; printf("Man \t Woman \t Child\n"); for (man=1; man<=16; man++) (man=1 man<=16; { for (woman=1; woman<=25; woman++) (woman=1 woman<=25; { child = 30 C man - woman; woman; if (3*man+2*woman+child == 50 && child > 0) *man+2 printf("%3d \t %5d \t %8d\n", man, woman, child); } } return 0; }
6

̵תƿ
goto goto break break continue continue exit() exit()

7

goto
gotoΪת䣬һʽΪ Ϊת䣬һʽΪ Ϊת

goto ţ ţ
˵ñʶʾ ˵ñʶʾ䶨 ͬĸֺ»ɣ ͬĸֺ»ɣһ ַΪĸ»ߡš ַΪĸ»ߡš 磺 Ϸ 磺goto label_1; Ϸ goto 123; Ϸ Ϸ

8

gotoӦþ Ӧþ
int main(void) { int i = 1, sum = 0; loopif (i <= 100) { sum = sum + i; i++; goto loop; } printf (%d, sum); return 0; }
9



break continue
break break
ã ã ѭѭ壬ǰѭ ѭѭ壬ǰѭִ ѭ䡣 ѭ䡣 ʹswitchṹִ ṹ ʹ ṹ ִswitchһ һ 䡣 䡣 һʽ һʽ break ; Ӧ÷Χ ֻѭ䣨 ֻѭ䣨whiledo-whileforswitch 䡣
10

continue
ã ã ѭ ѭѭδִ 䣬ŽһǷִѭж 䣬ŽһǷִѭж һʽ һʽ continue ;

11

breakcontinue
ʽ1 ʽ1

ʽ2 break

ʽ2 continue

ѭ һ

ѭ һ

12

˵break continue÷
#include <stdio.h> Please enter n:10L n:10L int main(void) main(void) n = 10 { int i, n; Please enter n: -10L 10L for (i=1; i<=5; i++) Program is over! { printf("Please enter n:"); scanf("%d", &n); if (n < 0) { break; break; } printf("n = %d\n", n); %d\ } printf("Program is over!\n"); over!\ return 0; }
13

˵breakcontinue ÷
#include <stdio.h> int main() main() { int i, n; for (i=1; i<=5; i++) { printf("Please enter n:"); scanf("%d", &n); if (n < 0) { continue; continue; } printf("n = %d\n", n); %d\ } printf("Program is over!\n"); over!\ return 0; }
14

Please enter n: 10L 10L n = 10 Please enter n: -10L 10L Please enter n: 20L 20L n = 20 Please enter n: -20L 20L Please enter n: 30L 30L n = 30 Program is over!

׼⺯exit() ׼⺯exit()
ã ã ִֹУǿƷزϵͳ ִֹУǿƷزϵͳøú ҪǶͷļ<stdlib.h> ҪǶͷļ<stdlib.h>

αP137 αP137

15


ĵ

  • 4_Ŀ*ṹ(ѭbreakcontinue)
  • 17.ѭ-breakcontinue
  • _Forѭṹbreak_continue(9)
  • Cѭṹ-breakcontinue
  • 11 breakcontinue ѭṹ1
  • 11 breakcontinue ѭṹ
  • c53ѭṹbreakcontinue
  • 6 breakcontinue ظṹӦ
  • 14ѭṹ(4)-breakcontinue
  • ϲ

  • ʡҵҵ(Ǽע)רⱨ2019
  • [ת]ھּϵͳо
  • ѧ νӽ̲ 22ʱ *ѧ(޴)ս̰
  • ҵ׸ô
  • ֲϽPVCʲô
  • Աܽ4ƪ
  • K12ѧ*ڶгɳСѧ꼶
  • 꼶ռǷģȵ600
  • ֹԱȽԽĵ-- ش ѱֵԱȽʵʵʹȥ
  • ˽Aѧ3.3.1.docx
  • ¡ʦ䡿߿ѧһָ*+ʱʱ*Ļʦ
  • ˽̰꼶ϲ 12СľżĹ(ѧ˼ʲο)СľżĹ ̰
  • ȫõ糣ʶ-PPTμ
  • 2020㶫ʡݸпѧϰ (89)
  • K12ѧ*꼶ϲᡶStorytimeѧս̰
  • Զԭ()50Զԭ
  • 2015ŮʱйѲݳ̷
  • ɹලƴڵĽ
  • жĸ
  • İ꼶ϲᡶ16ȻԡPPTμ (9)
  • 20127»ʿA
  • ƶ˶Ƶͨ-- ܹ
  • Ļ˵Ĺ淶
  • ӰƷͬģ
  • ϵȺ,ǿķʶ
  • 2019Ŀǰгб2
  • 2019У1-ר4ر̬(ѧ)
  • 001-ͳ2_ˮˮůռ¼
  • 2010-2011ѧȵһѧĩ԰רҵũƻѧ20111
  • ߿οѡppt
  • ˽̰Ӣȫ5Ӣﵥʻ-ȫ
  • ľϽ𸴺ϲĿо뱨淶
  • ׮ʩʱˮ»עҪ
  • Are invasive species the drivers of ecological change
  • ȼѹĿͶ
  • 2020ѧܽ͹ƻ
  • 2019꼶ѧ² 12.2 θʽij˳ѧ1(°)տư.doc
  • ٹ
  • ĵ̨ܻ
  • Сѧ״Բо
  • ԰