搜档网
当前位置:搜档网 › break、continue和return的用法

break、continue和return的用法

break、continue和return的用法
break、continue和return的用法

break的用法和短语例句(最新)

【篇一】break的用法大全 break的用法1:break是一个常用词,基本意思是突然地施加一个力(压力或拉力等)使之“破”或“碎”(从一个裂纹到七零八落)。引申可指事物部分地或全部破坏、瓦解、崩溃。 break的用法2:break有时只表示“冲破”“开创”等过程意义,但更多的是强调了其破坏的物或事物的完整性、统一性或连续性。 break的用法3:break用作不及物动词时,可表示物体“破”,用于人,则可指身体或精神“垮”“崩溃”。 break的用法4:break用作及物动词时,除作“弄断”“弄碎”等解,还可作“透露”解(主要是美国口语),与agreement, promise, law, regulation, rule, vow, word等词搭配时,还可作“违背,违犯”解。可接简单宾语,也可接以形容词或介词短语充当补足语的复合宾语。 break的用法5:break用作不及物动词时,主动形式可表示被动意义,其主语通常是表示无生命的东西。 break的用法6:break用作名词的基本意思是“裂口,裂缝; 破裂”,用于时间可表示“间歇,休息时间”,也可指旧方式或生活习惯的“改变”或“中断”,是可数名词。 break的用法7:break作“休息”解时是不可数名词,用作单数形式需加不定冠词。 break的用法8:break在口语中有时作“机会”解,美国俚语中还作“运气”解,是可数名词。 break的用法9:break还可表示“奔跑,试图逃跑”。 【篇二】break的常用短语 用作动词 (v.) break away( v.+adv. ) break down( v.+adv. ) break in1( v.+adv. ) break in2( v.+prep. )

c语言continue的用法

c语言continue的用法 C语言是一门通用计算机编程语言,应用广泛。下面,为大家整理了c语言continue的用法,希望对你有帮助哦! continue 语句强制控制转移到最小的封闭、为或while 循环的控制表达式。将控制权传递给它所在的封闭迭代语句的下一次迭代。continue语句和break语句相似。所不同的是,它不是退出一个循环,而是开始循环的一次新迭代。 continue语句只能用在while语句、do/while语句、for语句、if语句的循环体内,在其它地方使用都会引起错误!换言之,continue 语句是执行流程语句跳过循环体的剩余部分而继续执行下一个循环。 continue的用法示例: 1、for(var i=1;i<=10;i++) { if(i==6) continue; document.write(i); } //输出结果:1234578910 2、在此示例中,计数器最初是从1 到10 进行计数,但通过将continue 语句与表达式(i < 9) 一起使用,跳过了continue 与for 循环体末尾之间的语句。

using System; class ContinueTest { static void Main() { for (int i = 1; i <= 10; i++) { if (i < 9) { continue; } Console.WriteLine(i); } } } 输出: 9 10 对比一break和continue的用法:break的用法: while(表达式1){

…… if(表达式2) break; …… } continue的用法: while(表达式1){ …… if(表达式2) continue; …… } 注意:continue与break语句区分 continue:作用为结束本次循环,即跳过循环体中下面尚未执行的语句,接着进行下一次是否执行循环的判定. break:可以用来从循环体内跳出循环体,即提前结束循环,接着执行循环下面的语句 .

break up 用法

break up 1.smash to pieces;divide into small pieces 打破;弄碎;拆开 She broke up the glass in her search for money.她在找钱时把玻璃打碎了。 He can break up that stone with his hand.他用手能打碎那块石头。 2.end for a holiday(学校期终)放假 The boys will break up for the Christmas vacation next week.孩子们下周放圣诞假。 When does the school break up for the summer holidays?学校什么时候放暑假? We break up on July 25th.我们7月25日放假。 3.end;stop 结束;停止 The party broke up at midnight.晚会在午夜结束。 What time is the meeting expected to break up?会议可望在几点钟结束? He broke up the fight between the two gangs.他制止了两伙人打架。 A fight started in that street last night,so the police were called in to break it up.昨晚在那条马路上发生了一起斗殴事件,人们把警察叫来制止。 4.lose or destroy spirit or self control精神崩溃(常用于被动语态) She was all broken up after her daughter's death,and did not go out of the house for two months.她在女儿死后精神崩溃了,有两个月没有出家门。 5.stop being friends;separate绝交 Mary and John were good friends,but then they had a quarrel and broke up.玛丽和约翰原来是好朋友,但后来吵了一架便绝交了。

短语break的用法

短语break的用法 请先看下面三道高考试题: 1. The computer system _____suddenly while he was searching for information on the Internet. (2006年辽宁卷) A. broke down B. broke out C. broke up D. broke in 解析:A由语境逻辑可以推出该空表示“坏了”,因此应填broke down。 2. To understand the grammar of the sentence,you must break it _____ into parts. (2005年湖北卷) A. down B. up C. off D. out 解析:A break... down在此意为“将……分解”,符合语境逻辑。 3. I was still sleeping when the fire _____ ,and then it spread quickly. (2006年广东卷) A. broke out B. put out C. came out D. got out 解析:A由the fire与spread之间的语境逻辑可以推出该空表示“(火灾)发生”,因此应填broke out。 以上三题都是考查break短语的用法,本文在此对其做一归纳。 1. break down (1)破坏,毁掉; Who broke down the doors of our classroom? 谁把我们教室的门打坏了?(2)破除; The old rules must be broken down. 这些陈旧的规章制度必须废除。 (3)制服; The police tried to break down the prisoners’ opposition.警方设法制服囚犯的反抗。 (4)坍塌,坏掉; Because of explosion the bridge broke down last night. 由于爆炸,昨夜这座桥倒塌了。 (5)(计划等)失败,破裂; Your plan has broken down. What a pity! 你的计划失败了,真遗憾! Why did the peace talks break down?为什么和谈失败了? (6)(健康、精神)崩溃; After a long time of hard work,he almost broke down. 长时间艰苦劳动之后,他的身体几乎垮了。 (7)分解 This matter will break down in water. 这种物质在水中会分解。 2. break up (1) 解散,驱散。如: The police broke up the crowd (the meeting). 警察驱散了人群(集会)。 (2) (学校等)放假。如: When do you break up for Christmas? 你们什么时候放圣诞节假?

for循环的简介及break和continue的区别

for循环的简介及break和continue的区别 1.for循环 for循环是更加简洁的循环语句,大部分情况下,for循环可以代替while循环、do-while循环。 for循环的格式为: for( 初始语句 ; 执行条件 ; 增量) { 循环体 } 执行顺序:1、初始语句2、执行条件是否符合?3、循环体4、增加增量 初始化语句只在循环开始前执行一次,每次执行循环体时要先判断是否符合条件,如果循环条件还会true,则执行循环体,在执行迭代语句。 所以对于for循环,循环条件总比循环体多执行一次。 注意:for循环的循环体和迭代语句不在一起(while和do-while是在一起的)所以如果使用continue来结束本次循 环,迭代语句还有继续运行,而while和do-while的迭代部分是不运行的。 来个例子:输入一个数n(n>1),输出n!的值。n!(n的阶层)=1*2*3*……*n #include void main() { long num=1; int n,i; printf("请输入n:");

scanf("%d",&n); for(i=1;i<=n;i++) num=num*i; printf("%d的阶层是%d\n",n,num); } 2.break和continue的区别和作用 break和continue都是用来控制循环结构的,主要是停止循环。 1.break 有时候我们想在某种条件出现的时候终止循环而不是等到循环条件为false才终止。 这是我们可以使用break来完成。break用于完全结束一个循环,跳出循环体执行循环后面的语句。 2.continue continue和break有点类似,区别在于continue只是终止本次循环,接着还执行后面的循环,break则完全终止循环。 可以理解为continue是跳过当次循环中剩下的语句,执行下一次循环。 例子: #include void main() { int sum,i; sum=0; for(i=1;i<=100;i++) { sum=sum+i; if(i==2) {

英语小词break的超级详细地用法

break 1使破裂,使破碎;使断裂 I had to break a window to get into the house. 我只得打破一扇窗户进屋。 break sth in half/two :He broke the biscuit in half and handed one piece to me. 他把饼干掰成两半,递了一块给我。 He kept pulling at the rope until it broke. 他一直拉到绳子,直到把它拉断。 The frames are made of plastic and they tend to break quite easily. 这些框架是塑料做的,很容易碎裂。 2.bones 骨头使骨折 She fell downstairs and broke her hip. 她从楼梯上摔下来,髋部骨折。 3.machines 机器弄坏,损坏〔机器〕〔机器〕损坏,失灵 Don’t mess about with my camera –you’ll break it. 别乱动我的照相机,你会把它弄坏的。 The washing machi ne’s broken again. 洗衣机又坏了。 4.rules/laws 规定/法律不遵守,违犯 ?If you break the rules , you will be punished. 违反规定要受到惩罚。 5.promise/agreement 诺言/协议违反,违背〔诺言或协议〕 ?I never break my promises . 我从不食言。 ?You betrayed me. You broke your word . 你出卖了我,你说话不算数。 He was worried that he might be breaking his contract. 他担心自己可能会违约。 6.stop/rest 停下来/休息 *+ for+?Shall we break for lunch now? 我们现在停下来吃午饭好吗? 7.end sth 结束某事物打断,中断 ?We need to break the cycle of poverty and crime in the inner cities. 我们需要打破旧城区里贫困和犯罪的恶性循环。 ?We took turns drivi ng, in order to try and break the monotony. 我们轮流开车,免得乏味。 ?New talks will begin on Monday in an effort to break the deadlock . 为打破僵局,星期一将重启会谈。 8.defeat sb 打垮某人 ?Losing his business nearly broke him. 生意亏本几乎将他击垮。 ?I won’t give in. I won’t be broken by him. 我决不服输,我不会被他击垮的。 9.destroy an organization 摧毁,瓦解〔组织〕 ?The government succeeded in breaking the unions. 政府成功地瓦解了工会。10.day/dawn (天)刚亮,破晓 ?Dawn was breaking by the time we arrived home. 我们到家的时候天蒙蒙亮。11.〔暴风雨〕来临,突然出现 ?We were keen to get back to the hotel before the storm broke. 我们急于赶在暴风雨来临之前回到宾馆。 12.〔天气〕突然变化 ?The following day the weather broke and we had ten days of solid rain. 第二天天气突变,一连下了十天的雨。 13.〔波浪〕迸溅,拍岸 ?We sat and watched the waves breaking on the shore 我们坐着看波涛拍击海岸。

continue的第三人称单数和例句

continue的第三人称单数和例句 continue做动词有继续;连续;维持;持续等意思,那么你知道continue的第三人称单数是什么吗?下面为大家带来continue的第三人称单数和用法例句,欢迎大家学习! continue的第三人称单数: continues continue的用法: continue的用法1:continue的基本意思是“继续”,指动作或状态的继续或持续不中断。可表示一件事一直在做,中间没有停歇; 也可以表示中间有一个中断,又接着做下去。 continue的用法2:continue可用作不及物动词,也可用作及物动词。用作及物动词时可接名词、动名词、动词不定式或that从句作宾语,也可以接as短语充当补足语的复合宾语。continue还可引出直接引语。 continue的用法3:continue还可用作系动词,接(to be+) adj. 或as+ n. 作表语, to be常可以省略。 continue第三人称单数例句: 1. But as other shops fold, the march of the superstores continues. 但在其他商店纷纷关门倒闭之时,大型超市的强劲扩张势头却依

旧不减。 2. He continues to insulate his country from the contagion of foreign ideas. 他继续使本国远离外来思想的侵袭。 3. The main road continues towards Viterbo before turning right to Bolsena. 大路一直延伸到维泰博,之后右转通向博尔塞纳。 4. The group said it continues to hold 1,774,687 Vons shares. 该集团称其继续持有1,774,687股冯氏公司的股份。 5. Life continues to be a terrible grind for the ordinary person. 生活对于平头百姓而言依然是理不清的琐事。 6. The balance continues to swing away from final examinations to continuous assessment. 期末考试渐渐被连续性评估所取代。 7. The old fable continues to echo down the centuries. 这则古老的寓言流传了数个世纪。 8. Our discussion in the previous chapter continues this line of thinking. 我们上一章的讨论延续了这一思路。 9. The main path continues through a tunnel of trees.

java中break用法

1、return 语句的作用 (1) return 从当前的方法中退出,返回到该调用的方法的语句处,继续执行 (2) return 返回一个值给调用该方法的语句,返回值的数据类型必须与方法的声明中的返回值的类型一致,可以使用强制类型转换来是数据类型一致 (3) return 当方法说明中用void声明返回类型为空时,应使用这种格式,不返回任 何值。 2、break语句的作用 (1) 只能在循环体内和switch语句体内使用break语句。 (2) 当break出现在循环体中的switch语句体内时,其作用只是跳出该switch语句体。 (3) 当break出现在循环体中,但并不在switch语句体内时,则在执行break后,跳出本层循环体。 (4) 在循环结构中,应用break语句使流程跳出本层循环体,从而提前结束本层循环3、continue语句作用 (1) continue语句continue语句的一般形式为:contonue; (2) 其作用是结束本次循环,即跳过本次循环体中余下尚未执行的语句,接着再一次 进行循环的条件判定。 (3) 注意:执行continue语句并没有使整个循环终止。在while和do-while循环中,continue语句使得流程直接跳到循环控制条件的测试部分,然后决定循环是否继续进行。 (4) 在for 循环中,遇到continue后,跳过循环体中余下的语句,而去对for语句 中的“表达式3”求值,然后进行“表达式2”的条件测试, 最后根据“表达式2”的值来决定for循环是否执行。在循环体内,不论continue是 作为何种语句中的语句成分,都将按上述功能执行,这点与break有所不同 class Test { public static void main(String[] args) { testBreak(); testContinue(); testReturn(); } static void testBreak() { for(int i=0;i<10;i++) { if(i%2==0)

break的用法和短语例句

break的用法和短语例句 【篇一】break的用法大全 break的用法1:break是一个常用词,基本意思是突然地施加一个力(压力或拉力等)使之“破”或“碎”(从一个裂纹到七零八落)。引申可指事物部分地或全部破坏、瓦解、崩溃。 break的用法2:break有时只表示“冲破”“开创”等过程意义,但更多的是强调了其破坏的物或事物的完整性、统一性或连续性。 break的用法3:break用作不及物动词时,可表示物体“破”,用于人,则可指身体或精神“垮”“崩溃”。 break的用法4:break用作及物动词时,除作“弄断”“弄碎”等解,还可作“透露”解(主要是美国口语),与agreement, promise, law, regulation, rule, vow, word 等词搭配时,还可作“违背,违犯”解。可接简单宾语,也可接以形容词或介词短语充当补足语的复合宾语。 break的用法5:break用作不及物动词时,主动形式可表示被动意义,其主语通常是表示无生命的东西。 break的用法6:break用作名词的基本意思是“裂口,裂缝; 破裂”,用于时间可表示“间歇,休息时间”,也可指旧方式或生活习惯的“改变”或“中断”,是可数名词。 break的用法7:break作“休息”解时是不可数名词,用作单数形式需加不定冠词。

break的用法8:break在口语中有时作“机会”解,美国俚语中还作“运气”解,是可数名词。 break的用法9:break还可表示“奔跑,试图逃跑”。 【篇二】break的常用短语 用作动词 (v.) break away( v.+adv. ) break down( v.+adv. ) break in1( v.+adv. ) break in2( v.+prep. ) break into( v.+prep. ) break of( v.+prep. ) break off( v.+adv. ) break one’s word break out( v.+adv. ) break out in( v.+adv.+prep. ) break out into( v.+adv.+prep. ) break out of( v.+adv.+prep. ) break over( v.+prep. ) break through1( v.+prep. ) break through2( v.+adv. ) break to( v.+prep. ) break up( v.+adv. )

continue的用法与搭配

continue的用法与搭配 1. 表示继续做某事,其后既可接动名词也可接不定式,且意义相同。如: They continued to meet [meeting] daily. 他们继续每天都见面。 He continued to write [writing] while in hospital. 他住院时他继续写作。 Prices continued to fall during April.价格在4月份继续下跌。 We continued talking till late.我们一直谈到很晚的时候。 2. 表示继续维持某一情况时,其后可直接跟名词作宾语,也可先接介词with 再接宾语。如:We will continue (with) the payments for another year. 我们这样的报酬还要维持1年。 We'll continue with our work.我们要继续做。 She did not continue with her explanation.她没有继续解释下去。 He continued with his reading as if nothing important had happened.他若无其事地又继续看他的书。 Please continue with what you were doing before I came in.请继续做我进来前你们所做的事。3. 按传统语法,表示中断以后再继续,其后通常只能是story, speech, journey, strike 这样的名词,而不能接不定式或动名词,但现代英语已打破此规则。如: We continued working [to work] after the break. 休息后我们继续工作。 4. 由于可用于及物或不及物动词,所以有时用主动语态和被动语态意思差不多。如: The story continues [is continued] in the next issue of the magazine. 这个故事在该杂志的下一期里继续刊载。 5.比较 continue doing sth 与 continue by doing sth:前者表示“继续做某事”,后者表示“接着做某事”。如: He continued reading (=to read) all night. 他通宵在看书。 He talked about Keats, and continued by reading us a poem. 他谈了济慈,接着给我们朗诵了一首诗。 6. continued on page 15与continued from page 15 所用介词不同,意思也不同:前者指“下续第15页”,后者指“上接第15页”。 7.可用作连系动词,其后可接形容词、介词短语等。如: We hope the weather will continue fine. 我们希望天气继续很好。 Mother continues in weak health. 母亲身体仍然很虚弱。

有关_break的短语

有关break的短语 1. break down破坏,毁掉;破除;制服;坍塌,坏掉;(计划等)失败,破裂;(健康、精神)崩溃;分解 Who broke down the doors of our classroom? 谁把我们教室的门打坏了?The old rules must be broken down. 这些陈旧的规章制度必须废除。 The police tried to break down the prisoners’ opposition.警方设法制服囚犯的反抗。 Because of explosion the bridge broke down last night. 由于爆炸,昨夜这座桥倒塌了。 Your plan has broken down. What a pity! 你的计划失败了,真遗憾! After a long time of hard work,he almost broke down. 长时间艰苦劳动之后,他的身体几乎垮了。 Why did the peace talks break down?为什么和谈失败了? This matter will break down in water.这种物质在水中会分解。 2. break in破门而入,打断 Last night a thief broke in and stole away his camera. 昨夜一个小偷闯了进来,偷走了他的相机。 He broke in with some ideas of his own. 他插了话,说了说自己的一些看法。 3. break into破门而入,突然……起来 They broke into the prison and set free all the prisoners. 他们冲进监狱,释放了所有的囚犯。 Hearing the sad news, the old woman broke into tears. 听到这个悲哀的消息,这位老年妇女突然哭了起来。 4. break out战争爆发,争吵爆发,(火灾)发生 When did the war break out? 这场战争是什么时候爆发的? I have heard that a quarrel broke out between them. 我听说他们之间爆发了争吵。 More than one hundred fires broke out in our city last year. 去年我市发生了一百多起火灾。 5. break away from打破陈规;奋力挣脱;放弃习惯 You must break away from these old customs. 你们必须破除这些旧风俗。The dog broke away from its owner and ran away. 狗挣脱了主人,跑了。You’d better break away from the habit of smoking. 你最好改掉吸烟的习惯。 6. break through出现,突破

continue与go-on用法区别复习进程

精品文档 精品文档continue与go on用法区别 两者均可表示“继续”,有时可互换。如: The rain went on [contiuned] for three days. 雨连续下了 3 天。 This state of things cannot continue [go on] forever. 这种状况不能继续下去了。 两者区别如下: 1. go on 属普通用词,而 continue 则较正式。如: Go on, please. 请说下去。 Now, the news continues in standard English. 现在用普通英语继续报告新闻。 2. continue 后可直接跟名词作宾语,而 go on 后需借助介词再接名词作宾语。如: He continued [went on with] the story. 他继续讲故事。 3. continue 后接不定式或动名词均可,含义大致相同,均表示“不停地做某事”;而 go on 后接不定式或动名词含义区别较大,即 go on doing sth 意为“不停地做某事”(不中断)或“继续做某事”(中断后继续),go on to do sth 意为“(做完某事后)接着或继续做某事”。比较: The baby contiuned to cry [crying] all night. 婴儿哭了一夜。 You can't go on working all night without a rest. 你不能通宵工作而不休息。(无中断) She nodded, smiled, and went on stitching. 她点了点头,笑了笑,又继续缝衣服。(中断后再继续) Go on to do the other exerciese after you have finished this one. 你做完这个练习后,请接着做其他的练习。

break词组

⑴break in ①突然进来,强行进入。如: He broke in and stole my money. 他闯进来偷了我的钱。 ②插嘴,打岔。如: He broke in with some ideas of his own. 他插话谈了自己的一些想法。 Please don’t break in on our conversation. 请不要打断我们的谈话。 The secretary broke in to say that a telegram had just arrived. 秘书插话说刚收到一个电报。 ③以上用法的break in 通常是不及物的,但有时也用作及物动词,带宾语,表示:训练某人/物,使某人/物适应。如: He is breaking in the new man as a machine operator. 我在训练那个新工人操作机器。 Two weeks in the new office should be enough to break you in. 在新办公室上两星期的班便足以让你适应了。 ⑵break off ①停止讲话。如: He broke off in the middle of a sentence. 他一句话没讲完就停住了。 ②暂停,休息。如: Let’s break up for a rest. 我们休息一会儿吧。 ③折断/使折断。如: The mast has (been) broken off. 桅杆折断了。 ⑶break out (火灾、战争等)突然发生或爆发。如: A fire broke out during the night. 夜间发生了火灾。 The 2nd World War broke out in September, 1939. 第二次世界大战爆发于1939年9月。Influenza usually breaks out in winter. 流感通常发生在冬季。 注:是不及物动词,所以不能带宾语,也不能用于被动语态。 ⑷break down ①(机器、车辆等)坏了。如: The car broke down after an hour’s driving. 车子开了一个小时就坏了。 ②(计划、谈判等)失败。如: Our plans have broken down. 我们的计划已失败了。 ③(谈话、通讯等)中断。如: He broke down as he was singing. 他没唱完就突然停住了。 ④(健康、精神等)变坏。如: Her health broke down under the pressure of work. 工作的压力把他的身体弄垮了。 ⑸break away (from) ①突然逃掉或离开。如: The thief broke away from the policeman. 小偷从警察那逃脱了。 ②断绝往来,脱离。如: He broke away from all his old friends. 他同他所有的老朋友断绝了往来。 ③改掉(旧习惯),破除(旧作法)。如: You must break away from such habits. 你必须改掉那些习惯。 ⑹break into ①强行进入。如: The thieves planned to break into a bank. 这些小偷计划闯银行。

continue与go-on用法区别

外教一对一 continue与go on用法区别 两者均可表示“继续”,有时可互换。如: The rain went on [contiuned] for three days. 雨连续下了 3 天。 This state of things cannot continue [go on] forever. 这种状况不能继续下去了。 两者区别如下: 1. go on 属普通用词,而 continue 则较正式。如: Go on, please. 请说下去。 Now, the news continues in standard English. 现在用普通英语继续报告新闻。 2. continue 后可直接跟名词作宾语,而 go on 后需借助介词再接名词作宾语。如: He continued [went on with] the story. 他继续讲故事。 3. continue 后接不定式或动名词均可,含义大致相同,均表示“不停地做某事”;而 go on 后接不定式或动名词含义区别较大,即 go on doing sth 意为“不停地做某事”(不中断)或“继续做某事”(中断后继续),go on to do sth 意为“(做完某事后)接着或继续做某事”。比较: The baby contiuned to cry [crying] all night. 婴儿哭了一夜。 You can't go on working all night without a rest. 你不能通宵工作而不休息。(无中断) She nodded, smiled, and went on stitching. 她点了点头,笑了笑,又继续缝衣服。(中断后再继续) Go on to do the other exerciese after you have finished this one. 你做完这个练习后,请接着做其他的练习。 注:按传统语法,continue doing sth 只能表示不停地做某事,不能表示中断后继续做某事,但现代英语似乎已不完全遵循此规则。如 1995 年出版的《朗文当代英语辞典》就有这样一句: They contiuned talking after the meal. 吃了饭后他们又继续谈。 4. continue 可用作连系动词,go on 不可这样用。如: The weather continued fine. 天气一直很好。 The boat continued east. 船继续向东航行。

break和continue的区别

break和continue的区别 悬赏分:20 | 解决时间:2010-8-4 10:58 | 提问者:bluntd 这个程序求100到200之间所有素数并输出 #include #include void main() { int i=100,a=2,b; while (i<=200) { b=(int)sqrt(i); for(a=2;a<=b;a++) if (i%a==0) break; if (a>b) printf("%d\n",i); i++; } } 我用continue时候他会把100到200之间的每个数都输出 而用break就可以的到正确答案 continue不是结束本次循环不执行下面的语句么那用continue时候if (a>b) printf("%d\n",i);这句不是就应该不进行了么直接执行i++ 我写成这样 #include #include void main() { int i=100,a=2,b; while (i<=200) { b=(int)sqrt(i); for(a=2;a<=b;a++) {if (i%a==0) break; if (a>b) printf("%d\n",i);} i++; } } 如果用continue依旧不能得到结果求详细的解释问题补充: 第二个程序刚发错了 是这样#include #include void main() { int i=100,a=2,b;

while (i<=200) { b=(int)sqrt(i); for(a=2;a<=b;a++) {if (i%a==0) continue; else if (a>b) printf("%d\n",i);} i++; } } 我这样写从197开始每个数字输出四遍直到200 这个又是怎么回事这个用break 的话就不能输出任何结果 最佳答案break 跳出本次循环,continue 进入下一循环,就这么简单!该例中的break只是跳出本次循环,而continue会继续做a++直到循环完毕,当满足a>b的上一条时候正好是最后一条。固然每次都只是输出i了。如果第一段程序中加上continue那是没有任何异议的。因为for循环中的条件终止是a<=b 只有最后一跳后才能满足a>b,这里的for循环也没有任何意义了。程序编译到最好就只有: while(i<=200){printf("%d",i);i++} 结果就是:100 101 102...10n...200了。 对于你的提问: "continue不是结束本次循环不执行下面的语句么那用continue时候if (a>b) printf("%d\n",i);这句不是就应该不进行了么直接执行i++" 你要明白这里的if语句不在for循环中,break或者continue后面的分号才是for循环语句的结束点。 就到这里吧!有需要再联系...希望能帮到你. 程序短2中你是乱写的:在多加一个else if (a>b) printf("%d%d\n",i,b);}看看效果,屋子里没有tc,自己分析了.要逐个分析了.

C语言——continue和break的应用举例

C语言——Continue和break的作用举例Continue的作用是终止本次循环,break的作用是终止整个循环体。 例1: 输入一批考试分数,用-1作为结束标志,若输入大于100,\n则提示重新输入。然后计算最高分、最低分和平均值。 #include void start() { printf("*******<<<<<<<<<<<*********>>>>>>>>>>>>>>***********\n"); } main() { int mark,n=0,sum=0,max=0,min=100; float average; start(); printf("输入一批考试分数,用-1作为结束标志,若输入大于100,\n则提示重新输入。然后计算最高分、最低分和平均值。\n"); start(); for(;;) { scanf("%d",&mark); if(mark>100) { printf("Please reinput:\n"); continue; } if(mark==-1) break; n++; sum=sum+mark; if(mark>max) max=mark; if(mark

#include void main() { int mark,n=0,sum=0,max=0,min=100; float average; for(;;) { scanf("%d",&mark); //输入学生成绩 if(mark>100) //如果输入的成绩大于100,则重新输入 { printf("Please reinput:\n"); continue; //结束本次循环,返回for循环} if(mark==-1) //-1表示输入学生成绩结束 break; //终止整个循环,跳出循环体 n++; sum=sum+mark; if(mark>max) max=mark; //max存放最大的成绩 if(mark #define PI 3.14159265 void main() { int r; float s; for(r=1;r<=20;r++) { s=PI*r*r; if(s>200) break; printf("r=%d,s=%.2f\n",r,s); } }

相关主题