C语言while、do-while、for循环课程5
课程3中,提到C语言基本语句分为:数据定义语句,数据处理语句
数据处理语句又可分为:表达式语句,函数调用语句,空语句(;,复合语句,流程控制语句。
流程控制:指程序代码执行的顺序。流程的分类:顺序、选择、循环。
C语言的循环结构通过三种语句来实现,即while、do-while、forWhile语句的一般形式while(循环条件表达式循环体语句;
功能:当循环条件表达式为真,执行循环体语句,执行完了,再判断条件表达式是否为真,为真,则再执行,直到条件表达式为假时,退出while循环。
实例1:用while语句求1~100的累加和。
#include//C语言编译预处理命令,文件包含为stdio.h
voidmain(//至少有一个用main(命名的主函数,返回值为void无值类型{
inti=1,sum=0;/*初始化循环,定义变量i和累加器sum,定义和之前,累加器清零*/
while(i<=100
{
sum+=i;//sum+=i是一个复合赋值运算符,等价于sun=sun+i;i++;
}
printf("1+2+3+...+100=%d ",sum;//输出十进制数,1加到100累加器的和}
MicrosoftVisualC++6.0运行结果
使用while循环时,一定要对循环条件表达式中出现的变量提前赋值,并在循环体内修改有关变量的值,以使循环能趋于终止。
While循环为当型循环,do-while循环也叫直到型循环。
do-while语句的一般形式为:
do
{
循环体语句}while(
循环条件表达式
实例2:用do-while编制一个求n!的程序,n的值由键盘输入。
#include
voidmain(
{inti=1,n,p=1;
printf("请从键盘输入一个数,进行连乘积: ";
scanf("%d",&n;
do
{p=p*i;
i++;
}while(i<=n;
printf("连乘积的结果为p=n!:%d ",p;
}
分析:此程序,先定义三个变量i、n、p,p从p乘1开始执行,再i进行自增1,循环体中的语句执行完毕后,判断while的循环条件表达式,当i自增1为2时,看2是否<=输入的n值,若为真,则继续返回do循环,直到i自增的值比n大,则退出循环。
do-while主要用于人机交互,do-while循环是先执行后判断,do里面的循环体至少被执行一次。区别于while是先判断循环条件表达式,后执行。
for循环也叫步长型循环
一般格式:for(表达式1;表达式2;表达式3循环体语句;
功能:先执行表达式1,再执行表达式2,如果表达式2的值为真,就执行循环体语句,最后执行表达式3.完成一次循环后,从表达式2执行,直到表达式2为假,退出循环。
实例3:参考实例1,用while求1~100的累加和,现在用for语句求1~100的累
加和。
#include
intmain(void
{
inti;intsum=0;
/*初始化循环,定义变量i
和累加器sum,定义和之前,累加器清零*/
for(i=1;i<=100;i++
{
sum=sum+i;
}
printf("sum=%d ",sum;
return0;
}
实例4:爱因斯坦的`阶梯问题:有一个长阶梯,若每步上2阶,最后剩1阶;若每步上3阶,最后剩2阶;若每步上5阶,最后剩4阶;若每步上6阶,最后剩5阶;只有每步上7阶,最后刚好一阶也不剩。请问该阶梯至少有多少阶。编写一个C程序解决该问题。
#include
main(
{intx;
for(x=7;;x+=7
if(x%3==2&&x%5==4&&x%6==5
break;
printf("Thenumberoftheladdersis:%d ",x;
}
分析:发现x一定是7的整数倍,可以依次递增地求出7的整数倍的值(7*1、7*2、7*3……),每求出一值,就用该值与2、3、5、6进行取模运算,最先得到的满足上述5个方程式的x值即为本题的答案。
用while语句,简单快速实现爱因斯坦的阶梯问题
#include
intmain(
{
inti=1;/*i为所设的阶梯数*/
while(!((i%2==1&&(i%3==2&&(i%5==4&&(i%6==5&&(i%7==0
++i;/*满足一组同余式的判别*/
2、分类别:运用了··的说明方法。对事物的.特征有条理性。
3、作比较:运用了··的说明方法。把---和---加以比较,突出强调了---事物的特征-
4、作诠释:运用了··的说明方法。对事物的特征/事理加以具使说明更通俗易懂。
5、打比方:运用了··的说明方法。将__________比作__________,从而形象生动地说明了事物的特征/事理。
6、摹状貌:运用了··的说明方法。对事物的特征加以形象化的描摹,写出了说明对象---的特点。使说明更具体形象。
7、下定义:运用了··的说明方法。将---定义为---。用简明科学的语言对说明的对象/科学事理加以揭示,从而更科学、更本质、更概括地揭示事物的特征/事理。
8、列数字:运用了··的说明方法。用---等数据。据对事物的特征/事理加以说明,使说明更准确更有说服力。
9、列图表:运用了··的说明方法。用列图表的方式对事物的特征/事理加以说明,使说明更简明更直观。
10、引用说明:运用了··的说明方法。引用说明有以下几种形式—— 引用具体的事例;(作用同举例子)
引用具体的数据;(作用同列数字)
引用、格言、谚语;作用是使说明更有说服力。
引用神话传说、新闻报道、谜语、轶事趣闻等。作用是增强说明的趣味性。 (引用说明在文章开头,还起到引出说明对象的作用。)
1。 It is considered /thought that人们(有人,大家)认为
2。 It is generally /usually accepted /agreed/recognized that普遍(一般,通常)认为
3。 It is believed that有人(人们,大家)相信
4。 It is well—known that大家知道(众所周知)
5。 It is said that据说(有人说)
6。 It is learned that据闻(悉)
7。 It is supposed that据推测
8。 It is estimated/predicted/calculated that据估计(预计)
9。 It must be pointed that必须指出
10。 It is reported that据报道
11。 It must be admitted that必须承认
12。 It will be seen that可见(可以看出)
13。 It will be seen from this that由此可见
14。 It is understood that不用说(都知道)
15。 It can not be denied that无可否认
16。 It has been proved/demonstrated that已经证明
17。 It may be confirmed that可以肯定
18。 It may be safely said that可以有把握地说
19。 It is sometimes asked that人们有时会问
20。 It is expected that/hoped that人们希望
21。 When it comes to要说到,要谈及
1) Many nations have been faced with the problem of ……
2) Recently the problem has been brought into focus.
3) Recently the phenomenon has become a heated topic.
4) Recently the issue has aroused great concern among ……
5) Nowadays there is a growing concern over ……
6) Never in our history has the idea that …… been so popular.
7) Faced with ……, quite a few people argue that ……
8) According to a recent survey, ……
9) With the rapid development of ……,
10 When it comes to…, (当说到…
二、列举观点
I.Some people think/believe that…,
Other argue/claim that the opposite/reverse is true
1.Obviously television has both advantages and disadvantages.
2.Living in a city has both advantages and disadvantages.
3.Compared with cars,bikes have their advantages and disadvantages. ,
4.Although computers bring people a lot of convenience,they have many disadvantages.
5....has many advantages.For example,…
6. However,just as every coin has two sides,…has it’s disadvantages.
II…play(san important role/part in……
1.Computers play an important role in science and technology.
2.Computers play a more and more important role in our life.
3.Computers play an increasingly important role in our studies.
4.Education plays an important part in developing our mind.
5.Addiction to alcohol and drugs plays a role in homelessness.
6.Advertisement plays an informative role in our daily life.
7.In the past,letters played a decisive role in long-distance communication.But now,telephone,email,and fax have taken their place.
III.With the development of…
1.With the development of our economy,many Chinese families can afford a car.
2.With the development of our economy and society,pollution is more and more serious.
3.With the rapid development of Science and technology,people can get a college degree by taking online-courses at home.
4.With the current social and technological developments,employees with more knowledge and higher academic degrees are needed.
5.With the rapid increase of China's population,housing problem is becoming more and more serious.
6.With more and more women entering the society,people's attitude towards women is changing.
7.With the deepening of Chinese reform and opening up, an increasing number of (a growing number of,a significant number of
families can afford a car.
三、陈述自己观点
There is probably some truth in both arguments/statements,but…
四、批驳
1)It is true that ……, but one vital point is being left out.
2) There is a grain of truth in these statements, but they ignore a more important fact.
3) Some people say ……, but it does not hold water.
4) Many of us have been under the illusion that……
5) A close examination would reveal how ridiculous the statement is.
6) It makes no sense to argue for ……
7) Too much stress placed on …… may lead to ……
8) Such a statement mainly rests on the assumption that ……
9) Contrary to what is widely accepted, I maintain that ……
10) No one can deny the fact that ……
11) The idea is hardly supported by facts.
12) Unfortunately, none of the available data shows ……
13) Recent studies indicate that ……
14) There is sufficient evidence to show that ……
15) According to statistics proved by ……, it can be seen that ……
五、结尾句型 :
英语议论文多以简要总结全文或对所讨沦的问题提出解决办法来结尾。总结全文时除常用到in one/a word,generally speaking,to conclude等外,没有固定模式。提出解决办法时却常使用下一句型:
1) From what has been discussed above, we can draw the conclusion that ……
2) It is high time that strict measures were taken to stop ……
3). We should take measures to control the rapidly increasing world population.
4). We’d better take effective measures to prevent students from cheating on exams.
5). The government decided to take strong measures against drug abuse.
6). Urgent measures should be taken to prevent terrorists from carrying out further attacks.
7) It is necessary that steps should be taken to ……
8) In conclusion, it is imperative that ……
9) There is no easy method, but ……might be of some help.
10) To solve the above-mentioned problem, we must ……
11) In summary, if we continue to ignore the above-mentioned issue, more problems will crop up.
12) With the efforts of all parts concerned, the problem will be solved thoroughly.
13) We might do more than identify the cause ; it is important to take actions to ……
14) Taking all these into account, we ……
15) Whether it is good or not /positive or negative, one thing is certain/clear……
六、其他句型
I、There be结构
There+be+主语+(修饰成分,表示客观存在的\'人或事物。 There must be a lot of fuel in the tank.
There remains nothing more to be done.
There is no point in talking about it again.
There is something you don't know.
There is not enough time to do the work. .
II、名词化结构
名词化结构用以表明抽象思维的逻辑性和概念化,从而使语体更加正式、更加具有书面语风格。
1.由of连接主谓关系
That the earth revolves around the sun causes the changes of the seasons.
名词化:The revolution of the earth around the sun causes the changes of the seasons.
2.由0f连接动宾关系
One of the most important natural phenomena is that energy is transmitted from one point to another in waves.
名词化:One of the most important natural phenomena is the transmission of energy from one point to another in waves.
3.用of连接含有by的短语,把简单句转换成名词短语
朋友胜金钱。
2 Верному ругу цены нет.
忠实的朋友是无价之宝。
3 помогать ругу выйти из труного положения
帮助朋友摆脱困境
4 отать всё за ружу
为友谊奉献一切
5 уметь ружить с окружающими люьми
善于和周围的\'人交朋友
6 Дружа - это лизкие, оверительные отношения.
友谊就是亲近信任的关系。
与祖国共命运
2 связывать свою суьу с суьой Роины
将自己的命运与祖国的命运联系在一起
3 ити туа , куа Роина зовёт
到祖国召唤的地方去
4 Если потреуется , отать жизнь Роине ез минуты колеания.
如果需要的话,会毫不犹豫为祖国献出生命。
5 встать груью за Роину
挺起胸膛保卫祖国
6 оиваться процветания Роины
为祖国繁荣而努力
7 умножать славу Роины
为祖国增光添彩
8 ыть остойным сыном и гражанином Роины
做祖国合格的`儿子和公民
9 соственными руками созавать огатство и могущество Роины
用自己的双手创造祖国的富强昌盛
10 воспитывать кого в ухе патриотизма
培养……的爱国主义精神
11 горячо откликаться на призыв Роины .
热情地响应祖国的号召
12 ити по пути, указанному партией
沿着党指引的路线前进
13 Люовь к Роине олжна воплощаться в еле.
对祖国的爱应该体现在事业中。
14 Люовь к Роине проявляется везе н всега , и в великом, и в малом.
对祖国的爱谁是谁出能表现出来,不论在大事中还是在小事中都能表现出来。
15 Ге ни ыть - Роине служить.
不论在哪里都要为祖国服务。
16 Роина, такая, какая она есть сегоня - это Роина, которую наши отцы и еы завоевали в революционной орье.
今天的祖国是我们的父辈用生命斗争换来的。
17 Не ыло ы компартии, не ыло ы и нового Китая.
没有共产党就没有新中国。
18 Только социализм может сласти Китай.
只有社会主义才能救中国。
19 Благоаря нашему труу, лагоаря силе наших рук и нашего ума ует крепнуть и расцветать отечество.
祖国的盛大昌盛靠的是我们的劳动,我们的双手和智慧。
20 каким ы искренним чувством ни говорили мы о нашем патриотизме . всё-таки самым главным ля его проявления ует ля кажого из нас та практическая раота , которую он возьмет на свои соственные плечи.
不论我们是多么发自肺腑地谈论爱国主义,但对每一个人来说,爱国主义最主要的表现方式仍是自己承担的那份工作。
© 2022 xuexicn.net,All Rights Reserved.