1. 首页 > 文化

第一句为什么用for,两句有什么不同? 用for语句求1到100的和

第一句为什么用for,两句有什么不同?用for语句求1到100的和

c语言中for()与for();有什么不同

对于问题1

我们只讨论循环:

开始

for (i=0; i<2; i++)

i=0 往下执行 for(j=0; j<2; j++)

j=0往下执行 for(k=0; k<2; k++)

k=0 往下执行 printf(“%d %d %d\n", i, j, k);

输出 i j k 显然输出的是 0 0 0

输出后执行 k++, k值变为1 与2比较 显然 k<2 继续执行 输出

此时 i=0 j=0 k=1 输出为 0 0 1

输出后执行 k++, k值变为2 与2比较 显然 2<2 为假,跳出k循环回到上一级循环执行 j++

j=1与2比较 显然1<2 往下执行(此时i=0 , j=1)再次执行k循环int k=0

将k值重新赋值为0 执行输出 此时 i=0 j=1 k=0 输出 0 1 0

执行输出后k++,k值为1与2比较 显然1<2 继续 k的循环 此时k=2,j=1 i=0

执行输出为 0 1 1

输出后k++ ,k值为2与2比较 2<2为假跳出k循环 返回j循环 返回时k=2,j=1 i=0 执行j++ ,j的值为 2显然 2<2为假 ,跳出j循环 返回i循环 此时k=2,j=2 i=0, 执行i++,i值为1 与2比较 显然1<2 往下执行

i=1,执行 j 循环 int j=0 j值变为0

j=0 向下执行 k循环 int jk=0 k值变为0

k=0 向下执行输出 此时 i=1 j=0 k=0 输出 1 0 0

(此时回到了i=0的开始情况 )

参照前面的分析继续执行 依次会 输出 1 0 1

1 1 0

1 1 1

当输出到 1 1 1 的 时候继续想下执行k++,k值变为2 与2比较 结果为假回到j循环此时 i=1,j=1 ,k=2 ;执行j 循环中的j++,j值为2与2比较 结果为假回到i循环此时 i=1,j=2 ,k=2 ;执行i 循环中的i++,i值为2与2比较 结果为假退出循环 此时i=2,j=2 ,k=2;退出循环后下下执行结束程序

对于问题2 while(1)就是条件为永真 你用while(3) while(2) 都可以 就是while()函数的语句不停的执行 ,此时只能用跳转或者break 语句来跳出循环

但是while(0)表示永假 即while()里面的不执行 当然do while()除外 它是先执行后判断,但是也仅仅执行席次就不在执行了for(;;)里面空的意思就是条件为永真,没有退出的判别条件也就是相当于while(1)(习惯用 1 0 表示真假) 当然也可以用break或者跳转退出循环,但是那和for(;;)的判断无关。 所以for(;;)简单的讲就是条件为永真 循环不断的执行 除非遇到函数内部的跳转 或者函数里面嵌套的判断退出为止

eg : 1>

int i=0;

int j=0;

for(;;) {i++;

j++ ;} //不停的死循环

2>int i=0;

int j=0;

for(;;) {i++;

j++ ;

if(i>10)break;

}

不停的循环直到i>10由内部判断退出循环

对于问题3 你只要将 1维理解 和for语句的一维理解透彻 再在此基础上扩展就行了

多维数组可以分解为多个一维数组的 多个for的嵌套同样可以分解为一个一个的循环

只要很清晰的知道 数组下标 与判断时候条件值的状态 就好分析了

对于初学者来数 数组画图分析 以表格的形式在纸上分析,而循环语句同样的将判断的条件分解来 在纸上模拟,一步一步的跟进状态 从简单的开始慢慢深入 ,不怕麻烦 仔细研究很如意理解的.

詳解几个英语知识

as for (至于,就……方面说)和 as to (至于;关于)这两个复合介词在含义上相当接近,但在用法上差别很多。下面谈它们的这些差别。

1.as for

1)用以转换话题:在有前文的情况下as for总是出现在下文的句首,用来引出另外一方或者新的谈话内容,但与前文内容也有一定的联系,起到补充前文又突出后文的作用,使之与前文形成对照,译作“至于”。例如:

①You van have a bed;as for him,he'll have to sleep on the floor.

②Much pasture land is underwater;and as for the grain, most of that has been ruined.

2)用以表现态度:as for还可以用来表示讲话人对某人或某物持有“轻蔑”或“冷淡”的态度,甚至有憎恶之感,讲话时要重读引出的词语并在其后稍作停顿,以示强调,口气上带有嘲讽意味,译作汉语的“至于……嘛”。例如:

①As for you,I never want to see you here in my home again.

②As for his songs,I suppose you've read the sarcastic reviews !

2.as to

1)表示涉及某点:as to常放于句中,表示“关于……方面”、“有关……之事”,但为了突出要提及的人或事之时,也可将as to置于句首,以示强调。但只涉及内容,而不涉及讲话人的态度。例如:

①His wife,an old teacher,has n0 complaint as to salary.

②As to your ability to overfulfil the target,I never had the slightest doubt.

2)用以重提旧事:as to引出的内容都是前文曾经提到过的或者谈话对方都有所了解的,表示“说到”之义。,例如:

①As to doing that,I haven't decided yet.

②As to the question you raised in your last letter,I think that it is

unanswerable.

3)用于提出问题:as to必须位于句中,前面出现的大都是表达某种心理活动的动词,形容词或名词,浜笠映鰓h-clause或who-to-v结构,表示“在……的问题上”、“就……问题来讲”,所引出的问题都有很强的针对性。但有人认为这里的罄to显得多余,去之亦通。所以,有时也不必译出。例如:

①There is some doubt as to whether the proposal is practicable.

②I enquired of the clerk as to which documents were needed.

4.引出做事的依据:as to还有“按照”、“根据”的含义,而as for则无此义。例如:

①The shoes are correctly placed on the shelf as to size and colour.

②The items on the agenda are listed as to order of importance.

综上所述,as for 和 as to在确切含义的表达和具体用法上都是有很大差别的,不能将二者混为一谈。

过去式was/were后面的动词要加ing

drop off to sleep就是瘫下睡觉。

这是过去完成时,表示过去已经完成的动作或者强调过去完成的动作对现在造成的影响。

仆は毎日お酒ばかり饮んでいます 仆は毎日お酒を饮んでばかりいます 请问这两句有什么不同。书上说第

第一个意思每天喝东西的时候喝的都是酒

请问 the same as for 跟 the same as 用法上有什么不同?

今天我们学习怎么用 the same, t-h-e s-a-m-e, the same 加上名词再加上 as, 比方: the same length as "长度跟什么什么一样", the same style as "款式跟什么什么一样" 等等.

首先我们还是听一段对话,内容是说 琳达到百货商店去给姐姐珍妮买生日礼物.

请你注意听英文老师的发音和语调.

M: May I help you?

F: Yes, I would like to buy a swimming suit for my older sister as a birthday present.

M: What size does she wear?

F: Medium. The same size as I do.

M: Would she like this style?

F: No, do you have something different from this one?

M: What about that one?

F: The style is fine, but the color is too dark, Do you have something brighter?

M: How about this one?

F: It's too expensive.Do you have something cheaper?

M: Yes, we do. There is a budget department on the first floor. Why don't you check there?

F: Okay. Thank you very much.

现在我请英文老师再把整段对话念一遍, 请你注意听.

M: May I help you?

F: Yes, I would like to buy a swimming suit for my older sister as a birthday present.

M: What size does she wear?

F: Medium. The same size as I do.

M: Would she like this style?

F: No, do you have something different from this one?

M: What about that one?

F: The style is fine, but the color is too dark, Do you have something brighter?

M: How about this one?

F: It's too expensive.Do you have something cheaper?

M: Yes, we do. There is a budget department on the first floor. Why don't you check there?

F: Okay. Thank you very much.

刚才那段对话里有些句子用了形容词比较级, 有些句子用了我们今天要学的语 法, 现在我把这些句子挑出来, 请老师再念一遍.

F: I would like to buy a swimming suit for my older sister.

F: The same size as I do.

F: Do you have something different from this one?

F: Do you have something brighter?

F: Do you have something cheaper?

二.THE SAME ... AS

首先请你听一句话: Linda isn't as tall as Jenny. 这句话换个方式也可以这样说:

Linda isn't the same height as Jenny. 现在我们用这两种说法把珍妮和琳达两个 姐妹作个比较. 在下面这组练习里有几个字你可能不太熟, 比方 "女用手提包" purse 和 "女衬衫" blouse. 这些字等一会儿我们还会重复练习. 现在我们开始 作语法练习. 请你注意听.

M: Linda isn't as tall as Jenny.

F: Linda isn't the same height as Jenny.

M: Linda isn't as old as Jenny.

F: Linda isn't the same age as Jenny.

M: Linda's swimming suit isn't as expensive as Jenny's.

F: Linda's swimming suit isn't the same price as Jenny's.

M: Linda's hair isn't as brown as Jenny's.

F: Linda's hair isn't the same color as Jenny's.

M: Linda's skirt isn't as long as Jenny's.

F: Linda's skirt isn't the same length as Jenny's.

M: Linda's purse isn't as formal as Jenny's.

F: Linda's purse isn't the same style as Jenny's.

M: Linda's blouse isn't as big as Jenny's

F: Linda's blouse isn't the same size as Jenny's.

现在我们来作代换练习. 老师先说一句话: This dress is the same length as that one. "这件连衣裙的长度跟那件一样". 接着老师给你一个字: style,你就把句子 改成: This dress is the same style as that one.老师也可能给你另外一个东西的 名称, 比方: "外套" coat, 那么你就应该把句子改成: This coat is the same length as that one. 好, 现在我们开始作练习.请你斟酌情况看看应该代换哪个字.每作 完一句,你就跟老师念的正确答案比较一下, 看你作对了没有.

M: This dress is the same length as that one.

M: style

F: This dress is the same style as that one.

M: purse

F: This purse is the same style as that one.

M: color

F: This purse is the same color as that one.

M: skirt

F: This skirt is the same color as that one.

M: price

F: This skirt is the same price as that one.

M: blouse

F: This blouse is the same price as that one.

M: size

F: This blouse is the same size as that one.

M: coat

F: This coat is the same size as that one.

M: length

F: This coat is the same length as that one.

下面我们换一个方式作练习. 练习的内容还是提到百货商店里卖的东西, 比方 "一双短袜" a pair of socks, "一双女人穿的长袜子" a pair of stockings, "一条牛 仔裤" a pair of jeans, "一双靴子" a pair of boots 等等. 练习的作法是由老师提出 一个问题, 比方: Is this pair of socks the same color as that pair? 接着老师说:

dark, 学生就用这个形容词的比较级作否定的答覆, 所以答案就是: No, this pair of socks is darker than that pair. 好, 现在我们开始作练习. 请你在学生回答问题 的时候也一起回答.

M: Is this pair of socks the same color as that pair?

M: dark

F: No, this pair of socks is darker than that pair.

M: Is this pair of stockings the same length as that pair?

M: short

F: No, this pair of stockings is shorter than that pair.

M: Is this pair of boots the same price as that pair?

M: expensive

F: No, this pair of boots is more expensive than that pair.

M: Is this pair of pants the same size as that pair?

M: small

F: No, this pair of pants is smaller than that pair.

M: Is this pair of gloves the same style as that pair?

M: formal

F: No, this pair of gloves is more formal than that pair.

M: Is this pair of glasses the same price as that pair?

M: cheap

F: No, this pair of glasses is cheaper than that pair.

M: Is this pair of jeans the same length as that pair?

M: long

F: No, this pair of jeans is longer than that pair.