Nthawi zina, tingafunike kupanga code yomweyi nthawi zambiri. Kawirikawiri, mawu a pulogalamu amachitidwa motsatizana: chiganizo choyamba mu ntchito chimachitika poyamba, chotsatira chachiwiri, ndi zina zotero.
Zilankhulo zopanga mapulogalamu zimapereka njira zingapo zowongolera njira zovuta zochitira.
Mawu a loop amatilola kunena kapena gulu la ziganizo kangapo, ndipo zotsatirazi ndi ndondomeko ya mawu opita m'zinenero zambiri:
machitidwe ozungulira
Chilankhulo cha C chimapereka mitundu yotsatirayi. Dinani ulalo kuti muwone mtundu uliwonse kuti mumve zambiri.
machitidwe ozungulira | kufotokoza |
pamene kubwereza | Bwerezani mawu kapena gulu la ziganizo pamene chikhalidwe choperekedwa chiri chowona. Imayesa momwe zinthu zilili musanagwiritse ntchito loop host. |
za kubwereza | Kuchita ziganizo zingapo kangapo, kufewetsa kachidindo komwe kamayang'anira kusintha kwa loop. |
kuchita...pamene kubwereza | zofanana ndi mawu a panthawiyo kupatula kuti zimayesa mkhalidwe kumapeto kwa mutu wa loop. |
nest loop | Gwiritsani ntchito lupu limodzi kapena angapo mu lupu kwa kanthawi, kapena kuchita... |
Chidziwitso cha loop control
Dongosolo la loop-control limasintha dongosolo lomwe codeyo imachitidwa. Ndi izo mukhoza kulumpha mu code.
C chilankhulo chimapereka ziganizo zotsatirazi zowongolera kuzungulira. Dinani ulalo kuti muwone tsatanetsatane wa chiganizo chilichonse.
mawu control | kufotokoza |
kuswa chiganizo | Kuthetsa lupu kapenakusinthamawu, pulogalamu yotsatsira ikupitilizabe kunena mawu otsatirawa omwe amatsatira kuzungulira kapenakusintha. |
pitilizani Statement | Uzani gulu la loop kuti liyimitse kuzungulirako nthawi yomweyo ndikuyambanso kuzunguliranso. |
goto sentensi | Tumizani zowongolera ku mawu olembedwa. Koma musalimbikitse kugwiritsa ntchito mawu a goto mu pulogalamu. |
lupu wopandamalire
Ngati mikhalidweyo sibodza, ndiye kuti lupuyo imakhala loop yopanda malire. The for cycle itha kugwiritsidwa ntchito kuzindikira mikombero yopanda malire mwachikhalidwe. Popeza kuti mawu aliwonse mwa atatuwa omwe amapanga lupu siwofunika, mutha kusiya mawu ena opanda kanthu kuti apange loop yopanda malire.
chitsanzo chamoyo
Mawu okhazikika amaganiziridwa kuti ndi oona pamene palibe. Mutha kukhazikitsanso mtengo woyambira komanso mawu owonjezera, koma nthawi zambiri, wopanga mapulogalamu wa C amakonda kugwiritsa ntchito (;;) mawonekedwe kuti aimirire lupu lopanda malire.
A pamwamba C mkombero ndi wa Shenzhen HDV Photoelectron Technology co., LTD., mapulogalamu luso ntchito., Ndipo kampani wabweretsa pamodzi gulu lamphamvu mapulogalamu zida maukonde okhudzana (monga: ACONU/ kulumikizanaONU/ wanzeruONU/ fiberONU/XPONONU/GPONONUetc.). Kwa kasitomala aliyense sinthani zomwe mukufuna, komanso mulole kuti zinthu zathu zikhale zanzeru komanso zapamwamba.