C#泛型列表ListT基本用法总结

C#泛型列表ListT基本用法总结
C#泛型列表ListT基本用法总结

C#泛型列表List基本用法总结

示例代码如下:

namespace SampleListT

{

class Program

{

static void Main(string[] args)

{

//using System.Collections.Generic; 命名空间中的List

//using System.Collections;命名空间中的ArrayList

//都实现了列表集合,一个是泛形集合,一个是非泛型的

//下面我们将Person对象加到集合中

Person p1 = new Person( "aladdin" , 20 );

Person p2 = new Person("zhao", 10);

Person p3 = new Person("jacky", 40);

//如果不制定list的容器大小,默认是0,只要有元素加入是,会自动扩展到4,如果第5个元素加入时,就变成了8,第9个加入,就成16

//可以看出,总是成倍的增长,扩展时要重新开辟内存,这样会影响效率,如果事先知道元素个数,或者可能个数,最好给个尽量大的权衡值

//我们加入3个元素,设容器大小为4.注:设为4不是指只能放4个元素,如果超出,一样也会成倍扩展,这样做只是为了尽量扩展带来的开销

List list = new List(4);

list.Add(p1);

list.Add(p2);

list.Add(p3);

//本方法是清除多于的没有用的内存空间,例:如果开辟大小为100,而我们只用了4

个,其余的放着,是不是很浪费

//本方法调用时会检查元素个数是不是占到了容器大小的90%以上,如果是,则不进

行回收.

list.TrimExcess();

//ArrayList方法与List<>用法一样,不同的是,它是对象集合,参数是Object这样会有

装箱拆箱的可能,尽量用List<>

//本处不再做演示

// 1 初始化集合器

// C#3.0开始,提供了初始化功能,但是并没有反应到IL代码中,在IL中,一样也

是把个转化成ADD方法来调用

List l2 = new List() { 1 ,2 ,3 ,4 ,5 };

// 2 添加元素AddRange() 本方法可以一次性添加一批对象

List lists = new List(10);

//参数是一个必须可能跌代的对象,也可是数组

list.AddRange( new Person[] { new Person( "aladdin" ,20) , new Person("zhao",6)});

//构造传入批量参数,与AddRange效果一样

List mylist = new List(new Person[] { new Person( "aladdin" ,20) ,

new Person("zhao",6)});

// 3 插入元素

// 使用Insert()方法,可以在指定位置插入元素

// 例我们在1位置插入则最后变成了aladdin jacky zhao..插入意思就是,这个位我占了,以前占这位的和他之后的,通通往后移一位

mylist.Insert( 1 , new Person( "jacky" , 88 ));

foreach (Person p in mylist)

{

Console.WriteLine(https://www.360docs.net/doc/0e4750856.html,);

}

// 4 访问元素

// ArrayList 与List都是提供了索引器来访问的

Console.WriteLine( "----------------访问元素------------------------");

for (int i = 0; i < mylist.Count; i++)

{

Console.WriteLine(mylist[i].name);

}

//还可以使用foreach跌代器来实现,些处不再举例

//使用Foreach方法

//public delegate void Action(T obj);例用委托做为参数

//些处我们用呀妈Day表达式实现

Console.WriteLine( "-----------------用ForEach方法输出------------------------");

mylist.ForEach( param => Console.WriteLine(https://www.360docs.net/doc/0e4750856.html,) ) ;

// 5删除元素

//删除元素可以使用RemoveAt()直接传入索引器值

//将第一个元素直接删除

mylist.RemoveAt(0);

//也可以将要删除的元素传给Remove方法

List lists2 = new List(10);

Person per1 = new Person( "aladdin" , 100 );

Person per2 = new Person("zhao", 100);

Person per3 = new Person("jacky", 100);

lists2.Add(per1);

lists2.Add(per2);

lists2.Add(per3);

lists2.Remove(per3);

Console.WriteLine( "-------删除后的元素---------");

foreach (Person per in lists2)

{

Console.WriteLine(https://www.360docs.net/doc/0e4750856.html,);

}

//从结果可以看出名称为Jacky的元素被删除了

//下面说一下Remove方法的删除过程

// 用IndexOf方法确定出对象的索引,然后按索引删除

// 在IndexOf方法内,首先检查元素是不是实现了IEquatable接口,如果是,就调用这个

接口中的Equals方法

// 如果没有实现,则调用Object中的Equals方法比较元素(也就是址址比较) // 以上我们删除per3,很显明显一个地址,所以被删除了

// 下面我们改装了Person ,实现了IEquatable,在比较方法中,始终返回false ,

则per3会比较失败,不会被删除

// 结果3个都在

// 如果要删除对象,最好使用索引直接删除,因为Remove方法经历了一系列过程后,最

后才按索引删除!

// RemoveRange()删除一个范围

// 第一个参数开始位置第二个个数

//lists2.RemoveRange( 1 , 2 );

//Console.WriteLine( "批量删除后----------------");

//foreach (Person per in lists2)

//{

// Console.WriteLine(https://www.360docs.net/doc/0e4750856.html,);

//}

// 6 搜索

// 搜索有很多种方式,可以使用IndexOf LastIndexOf FindIndex FindLasIndex Find FindLas ,如果只是查看元素存不,可以使用Exists()方法

// IndexOf() 方法需要将一个对象做参数, 如果打到,就返回本元素在集合中的索引,如果找不到就返回-1,IndexOf还可以使用IEquatable接口来比较元素

List ls3 = new List(10);

Person person1 = new Person("aladdin", 100);

Person person2 = new Person("zhao", 100);

Person person3 = new Person("jacky", 100);

ls3.Add(person1);

ls3.Add(person2);

ls3.Add(person3);

// 为了使用默认的地址比较,我们把Person的接口暂时去掉

int index = ls3.IndexOf(person3);

Console.WriteLine( "per3 的索引:" + index); //2

// 还可以指定搜索范围从第3个开始,范围长度是1

int index2 = ls3.IndexOf(person3,2,1);

Console.WriteLine(index2);

//IEquatable比较方法前面已经写过,不再举例

// FindIndex()方法是用来搜索带有一定特性的元素

// 例用委托做参数 public delegate bool Predicate(T obj);

int index3 = ls3.FindIndex(param => https://www.360docs.net/doc/0e4750856.html,.Equals("jacky"));

Console.WriteLine( index3 );// 2

// FindLastIndex是从后面查第一个出现的元素,因为我们这里没有重复元素,所以体现

不出他只查找一个,就停下来的效果

int index4 = ls3.FindLastIndex(p => https://www.360docs.net/doc/0e4750856.html,.Equals("aladdin"));

Console.WriteLine(index4);

// Find方法与FindIndex方法用法一样,不同的是,它返回的是元素本身

Person ppp = ls3.Find( p => https://www.360docs.net/doc/0e4750856.html,.Equals("jacky")) ;

Console.WriteLine(ppp);

// 如果要查找所有的匹配元素,而不是找到第一个就停下来,就使用FindAll方法

// 我们查找所有年纪等于100的对象,3个都符合

List newList = ls3.FindAll(p => p.age == 100);

Console.WriteLine( "----------查找所有---------");

foreach (Person p in newList)

{

Console.WriteLine(https://www.360docs.net/doc/0e4750856.html,);

}

// 7 排序

// List可以例用Sort方法排序,实现算法是快速排序

// 本方法有好几个重载

//public void Sort(); //只对元素实现了IComparable才能使用这个方法,如果实现了则,可以直接调用一次sort之后,就排好序了

//public void Sort(Comparison comparison); //我们的Person并没有实现那个接口,

所以要用泛型委托当参数的方法

//public void Sort(IComparer comparer); //泛型接口当参数public delegate int

Comparison(T x, T y);

//public void Sort(int index, int count, IComparer comparer); //可以指定范围

List ls4 = new List(10);

Person person4 = new Person("aladdin", 100);

Person person5 = new Person("zhao", 33);

Person person6 = new Person("jacky", 44);

ls4.Add(person4);

ls4.Add(person5);

ls4.Add(person6);

ls4.Sort(MyComparFunc);

Console.WriteLine( "-------------排序后的-------------");

foreach (Person p in ls4)

{

Console.WriteLine(https://www.360docs.net/doc/0e4750856.html,+ p.age );

}

Console.WriteLine( "--------颠倒循序------------------");

ls4.Reverse();

foreach (Person p in ls4)

{

Console.WriteLine(https://www.360docs.net/doc/0e4750856.html,+ p.age);

}

// 8 类型转换

//可以将集合中的元素转换成任意类型的元素,比如,我们要将集合中的Person转换成为Racer

对象Racer只包含名字,没有年纪

// public List ConvertAll(Converter converter);

// public delegate TOutput Converter(TInput input); 委托参数List ls5 = ls4.ConvertAll((input) => new Racer(https://www.360docs.net/doc/0e4750856.html,)) ;

Console.WriteLine( "-----------转换后的玩意--------");

foreach (Racer r in ls5)

{

Console.WriteLine(https://www.360docs.net/doc/0e4750856.html,);

}

// 9 只读集合

// 在创建完集合以后,肯定是可读写的,如果不是,他就不能再添加新元素了,但是,如果是

认为填充完毕,不要再做修改.

// 可以使用只读集合,使用AsReadOnly方法() 返回ReadOnlyCollection类型,它与List<>操作是一样的,但是一但有修改集合的操作,就会刨出异常

// 他屏蔽了通常的ADD等方法

ReadOnlyCollection persss = ls5.AsReadOnly();

Console.WriteLine("输出只读集合");

foreach (Racer r in persss)

{

Console.WriteLine(https://www.360docs.net/doc/0e4750856.html,);

}

Console.ReadLine();

}

//为了比较写的委托实现方法

public static int MyComparFunc(Person p1, Person p2)

{

if (p1.age == p2.age)

{

return 0;

}

else if (p1.age > p2.age)

{

return 1;

}

else

{

return -1;

}

}

}

//two helper classes

class Person//:IEquatable

{

public string name;

public int age;

public Person( string name , int age )

{

this.age = age;

}

////始终给一个False值

//public bool Equals(Person other)

//{

// return false;

//}

}

class Racer

{

public string name;

public Racer(string name)

{

}

}

}

过去完成时态用法小结

过去完成时态的用法小结 默认分类2009-12-27 12:54:52 阅读281 评论0 字号:大中小订阅 一、过去完成时适用场合 1. 过去完成时表示在过去某一时间或动作以前已经完成了的动作。这个过去的时间常用by,before等介词短语或一个时间状语从句表示,也可以暗含在上下文中。 I had finished my homework before supper.我在晚饭前就把作业做完了。 The play had already started when we got to the theatre. 我们到剧场时戏已经开始了。 By the end of June they had treated over 10,000 patients. 到六月底他们已经治疗了一万多病人。 2. 过去完成时还可表示过去某一时刻之前发生的动作或状态持续到过去某个时间或还要持续下去,常与for,since等词连用。如: He had served in the army for ten years before he retired last year. 他在部队干了十年,去年退役了。 He told me that he had known her since he was a child. 他告诉我他从小就认识她。 He had learned English for eight years before he went to England for further study. 他在去英国深造前,已学了八年英语。 3. 在一段情景连贯的文字中,先发生的事放在后面叙述时,要用过去完成时。如: Tom flew home, but his father had already died. 汤姆乘飞机回家,他的父亲却已经去世了。4. 过去完成时也用于hardly...when..., no sooner...than..., It was the first time + that分句等一些固定句型中。 He had no sooner left the room than they began to talk about him. 他刚离开房间,他们就议论起他来。 We had hardly begun when we were told to stop. 我们刚开始就被叫停。 It was the first time that he had ever spoken to me in such a tune.他用这样的语调跟我讲话,这是第一次。 二、过去完成时与一般过去时的比较 1. 当一个由before, after, as soon as 等连词引导的从句所表示的动作和主句的动作紧接着发生时,两个动作均可用一般过去时来表示。 We had breakfast after we did morning exercises. 做完早操后,我们吃早饭。 The train started to move just before he reached the platform. 他到月台时火车刚开走。 They started ploughing as soon as they got to the fields. 他们一到地里就开始耕地。 2. 按时间顺序叙述两个或两个以上接连发生的动作时,用一般过去时。 He entered the room, turned on the light and sat down at the table. 他走进屋子,打开灯,坐在桌子旁。 3. 在表示某人过去未曾完成的“心愿”、“打算”、“计划”、“想法”、“许诺”等时,hope, mean, plan, think, intend等谓语动词常用过去完成时。 I had hoped to be back last night, but I didn’t catch the train. 我本来希望昨晚回来的,但没搭上火车。 We had thought to return early but they wouldn’t let us go. 我们本想早回来的,但他们不让我们走。 4. 在表示过去的句子中出现常与完成时态连用的词,如:already,yet,since,for,ever,never及次数名词等时,常用过去完成时来表示。

java泛型详解

java泛型详解 泛型(Generic type 或者generics)是对 Java 语言的类型系统的一种扩展,以支持创建可以按类型进行参数化的类。可以把类型参数看作是使用参数化类型时指定的类型的一个占位符,就像方法的形式参数是运行时传递的值的占位符一样。 可以在集合框架(Collection framework)中看到泛型的动机。例如,Map类允许您向一个Map添加任意类的对象,即使最常见的情况是在给定映射(map)中保存某个特定类型(比如String)的对象。 因为Map.get()被定义为返回Object,所以一般必须将Map.get()的结果强制类型转换为期望的类型,如下面的代码所示: Map m = new HashMap(); m.put("key", "blarg"); String s = (String) m.get("key"); 要让程序通过编译,必须将get()的结果强制类型转换为String,并且希望结果真的是一个String。但是有可能某人已经在该映射中保存了不是String的东西,这样的话,上面的代码将会抛出ClassCastException。 理想情况下,您可能会得出这样一个观点,即m是一个Map,它将String键映射到String值。这可以让您消除代码中的强制类型转换,同时获得一个附加的类型检查层,该检查层可以防止有人将错误类型的键或值保存在集合中。这就是泛型所做的工作。 泛型的好处 Java 语言中引入泛型是一个较大的功能增强。不仅语言、类型系统和编译器有了较大的变化,以支持泛型,而且类库也进行了大翻修,所以许多重要的类,比如集合框架,都已经成为泛型化的了。这带来了很多好处: · 类型安全。泛型的主要目标是提高 Java 程序的类型安全。通过知道使用泛型定义的变量的类型限制,编译器可以在一个高得多的程度上验证类型假设。没有泛型,这些假设就只存在于程序员的头脑中(或者如果幸运的话,还存在于代码注释中)。 Java 程序中的一种流行技术是定义这样的集合,即它的元素或键是公共类型的,比如“Str ing列表”或者“String到String的映射”。通过在变量声明中捕获这一附加的类型信息,泛型允许编译器实施这些附加的类型约束。类型错误现在就可以在编译时被捕获了,而不是在运行时当作 ClassCastException展示出来。将类型检查从运行时挪到编译时有助于您更容易找到错误,并可提高程序的可靠性。

最新过去分词作状语的用法归纳

过去分词作状语 一.过去分词作状语的基本用法: 过去分词作状语主要是说明谓语动作发生的背景或条件;表示原因、时间、条件、让步、方式或伴随情况等。过去分词可置于主句前,也可置于主句后,用逗号与主句隔开。 1. 原因状语 Choked by the heavy smoke, he could hardly breathe. 他被浓烟呛了,几乎不能呼吸了。 Caught in a heavy rain, he was all wet. 因为淋了一场大雨,所以他全身湿透了。Frightened by the n oise in the night, the girl didn’t dare to sleep in her room. 受到夜晚响声的惊吓,那姑娘不敢睡在她的房间。 2. 时间状语 Left to itself in the room, the baby began to cry.当被孤独地留在房间里时,婴儿哭了起来。 Asked why he did it, the monitor said it was his duty. 当被问及这件事时,班长说这是他的职责。 Approached in the dark, the lights looked lonely and purposeless. 在黑暗中走近时。那些电灯显得孤单而无意义。 3. 条件状语 Seen in this aspect, the matter isn’t as serious as people generally suppose. 如果从这个角度看,问题并不像人们一般预料的那样`严重。 Grown in rich soil, these seeds can grow fast. 如果种在肥沃的土壤里,这些种子能长得很快。 Given better attention, the accident could have been avoided. 要是多加注意,那次事故就能避免了。 Watered more, these cabbages could have grown better. 如果多浇点水,这些大白菜还可以长的得更好。 Compared with you, we still have a long way to go. 和你相比,我们还有很大的差距。 4. 方式或伴随状语 Surrounded by his students, the professor sat there cheerfully. 那位教授在学生的簇拥下,兴高采烈地坐在那儿。 He stood there silently, moved to tears. 他静静地站在那里,被感动得热泪盈眶。The old man went into the room, supported by his wife. 那位老人在妻子的搀扶下,走进了房间。 5. 让步状语 Beaten by the police and sent to jail, Gandi created the principle of nonviolent resistance. 尽管受警察的殴打,被投入监狱,甘地却首创了非暴力抵抗的原则。Defeated again, he didn’t lose heart. 尽管再次被击败,但他没有灰心。

lingo用法总结

ji例程1、 model: sets: quarters/1..4/:dem,rp,op,inv; endsets min=@sum(quarters:400*rp+450*op+20*inv); @for(quarters(i):rp<=40); @for(quarters(i)|i#gt#1: inv(i)=inv(i-1)+rp(i)+op(i)-dem(i);); inv(1)=10+rp(1)+op(1)-dem(1); data: dem=40 60 75 25; enddata end 例程2、 model: sets: quarters/1..4/:dem,rp,op,inv; endsets min=@sum(quarters:400*rp+450*op+20*inv); @for(quarters(i):rp<=40); @for(quarters(i)|i#gt#1: inv(i)=inv(i-1)+rp(i)+op(i)-dem(i);); inv(1)=a+rp(1)+op(1)-dem(1); data: dem=40 60 75 25; a=? enddata end ?LINGO总是根据“MAX=”或“MIN=”寻找目标函数,而除注释语句和TITLE语句外的其他语句都是约束条件,因此语句的顺序并不重要。 ?LINGO中函数一律需要以“@”开头 ?Lingo中的每个语句都以分号结尾 ?用LINGO解优化模型时已假定所有变量非负(除非用限定变量取值范围的函数@free或@sub或@slb另行说明)。 ?以感叹号开始的是说明语句(说明语句也需要以分号结束)) ?理解LINGO建模语言最重要的是理解集合(Set)及其属性(Attribute)的概念。 ?一般来说,LINGO中建立的优化模型可以由5个部分组成,或称为5“段” (SECTION): (1)集合段(SETS):以“ SETS:” 开始,“ENDSETS”结束,定义

过去完成时知识点总结和题型总结(word)

过去完成时知识点总结和题型总结(word) 一、初中英语过去完成时 1.—We all went to the park except you last weekend. Why didn't you come? —Because I the park twice. A. have gone to B. had gone to C. had been to D. have been to 【答案】 C 【解析】【分析】have gone to去了(尚未回).have been to去过(已回),根据句意在last weekend之前去过,所以用过去完成时,故选C。 【点评】本题考查过去完成时的用法,表示在过去某一时间前已经发生的动作。 2.Sue didn't go to see the film with us last week because she ________________ it with her mother. A. has seen B. had seen C. will see D. saw 【答案】 B 【解析】【分析】句意:苏上星期没和我们一起去看电影,因为她和她妈妈一起看过了。 A.已经看了,现在完成时; B.已经看了,过去完成时; C.将看,一般将来时; D.看了,一般过去时。Sue和妈妈看了电影的影响是上周Sue没有和我们看电影,所以用完成时,根据didn't可知是与过去有关,所以用过去完成时,结构是had+动词过去分词,see的过去分词是seen,故选B。 【点评】考查过去完成时,注意平时识记其结构,理解句意。 3.Jake _____his key in the office so he had to wait until his wife _______ home. A. has forgotten … comes B. forgot… come C. had left… came D. had left…would come 【答案】 C 【解析】【分析】句意:杰克把他的钥匙丢在办公室了,因此他不得不等到他的妻子回家。结合语境可知前文描述的是过去某时前已经完成的动作,故用过去完成时态。下文指的是过去某时的动作,故用一般过去时态。选C。 【点评】英语中的时态主要是借助于时间状语与上下文语境来进行判断。解答此类题型,首先要注意句子中的时间状语,如果没有则要通过分析上下文,结合语境来判断句子的时态。 4.When I ______ the cinema, the film _______for ten minutes A. got to; has begun B. arrived at; has been on C. reached; had begun D. hurried to; had been on

英语过去完成时的用法总结

英语过去完成时的用法总结 它表示句子中描述的动作发生在“过去的过去”。 基本结构 主语+had+过去分词vpp、(done) ①肯定句:主语+had+过去分词、 ②否定句:主语+had+not+过去分词、 ③一般疑问句:Had+主语+过去分词? 肯定回答:Yes,主语+had、 否定回答:No,主语+had not 、 ④特殊疑问句:特殊疑问词或词组+一般疑问句(Had+主语+过去分词)? 基本用法表示在过去某一时刻或动作以前完成了的动作,也可以说过去的时间关于过去的动作。即“过去的过去”。可以用by, before等介词短语或一个时间状语从句来表示,也可以用一个表示过去的动作来表示,还可能通过上下文来表示。 例如: By nine o’clock last night, we had got200 pictures from the spaceship、到昨晚9点钟,我们已经收到200 张飞船发来的图片。 过去完成时-语法判定 1、由时间状语来判定

一般说来,各种时态都有特定的时间状语。与过去完成时连用的时间状语有: (1 ) by + 过去的时间点。如: I had finished reading the novel by nine oclock last night、 (2 ) by the end of + 过去的时间点。如: We had learned over two thousand English words by the end of last term、 (3 ) before + 过去的时间点。如: They had planted six hundred trees before last Wednesday、 2、由“过去的过去”来判定。 过去完成时表示“过去的过去”,是指过去某一动作之前已经发生或完成的动作,即动作有先后关系,动作在前的用过去完成时,在后的用一般过去时。这种用法常出现在: (1 )宾语从句中 当宾语从句的主句为一般过去时,且从句的动作先于主句的动作时,从句要用过去完成时。在told, said, knew, heard, thought等动词后的宾语从句。如: She said that she had seen the film before、 (2 )状语从句中

过去分词用法归纳

过去分词用法归纳-标准化文件发布号:(9556-EUATWK-MWUB-WUNN-INNUL-DDQTY-KII

过去分词用法归纳 Mar 7, 2011 过去分词主要表示被动,可表示发生在过去,所以叫过去分词。也可以无时间概念,只表示被动。过去分词用法:状语、定语、补语、表语。 一.状语 情况 1:表“被动”的状语从句可简化成过去分词做状语。表示条件、时间、让步的连词可保留,如if, when, although。表原因的不保留,如because 等。 1) He won’t go to the party tomorrow, if he is not invited. He won’t go to the party, if not invited. 2) When she was asked about her age, she kept silent. When asked about her age, she kept silent. 3) Once it is formed, a bad habit is hard to kick. Once formed, a bad habit is hard to kick. 进一步练习: 1) If it is seen from the mountain, the city looks more beautiful. Seen from the mountain, the city looks more beautiful. 2) If it is heated to 100 degrees Centigrade, water boils. Heated to 100 degrees Centigrade, water boils. 3) The problems, if they are not solved properly, will seriously affect the relations of nations. The problems, if not solved properly, will seriously affect the relations of nations. 4) Although he was warned of the danger, the boy still went skating on the ice. 2

人教版英语过去完成时的用法大全附答案

人教版英语过去完成时的用法大全附答案 一、初中英语过去完成时 1.By the time I got to school, I realized that I ________ my backpack at home. A. have forgotten B. had forgotten C. have left D. had left 【答案】 D 【解析】【分析】句意:我到学校的时候,我意识到我把书包忘在家里。考查过去完成时。by the time:到…时候为止;通常引导一个时间状语从句,表示“到……的时候为止”主句则表示在此时间之前某个事件已完成。值得注意的是,当从句用过去时时,主句通常用过去完成时。Leave sth. Sp.:把…落在某地。结合句意和语境可知选D。 【点评】此题考查过去完成时的用法。 2.Mary thought of the party which she___________ for this day. A. plan B. planned C. had planned D. would plan 【答案】 C 【解析】【分析】句意:玛丽想起了她今天计划的聚会。plan的动作发生在thought of的动作之前,表示过去的过去,要用过去完成时had+过去分词。故选C。 【点评】考查过去完成时的构成和用法。注意过去完成时表示过去的过去含义。 3.The bus ______ for five minutes when Tim arrived at the station. A. went B. has left C. had left D. had been away 【答案】D 【解析】【分析】句意:当迪姆到达车站时,公交离开了五分钟了。表示到达车站前已经发生或完成的动作,句子用过去完成时态;leave是一个非延续性的动词,不能与表示一段时间的状语for…连用,可以表达成be away,形容词表示状态,可以与表示一段时间的状语连用。故选D。 【点评】本题考查过去完成时以及延续性动词的用法。 4.The girl sitting next to me on the plane was very nervous, for she before. A. didn't fly B. hasn't flown C. hadn't flown D. wasn't flying 【答案】C 【解析】【分析】句意:飞机上坐在我旁边的女孩很紧张,因为她以前没有坐过飞机。根据上文的句子The girl sitting next to me on the plane was very nervous的一般过去时态可知,这里空白处所表示的是过去的过去,谓语应该用过去完成时态:had+动词的过去分词。根据句意,故答案为C。 【点评】考查过去完成时态。掌握过去完成的意义和用法:表示过去的过去的动作或状

过去完成时用法小结

过去完成时用法小结 一、过去完成时适用场合 1. 过去完成时表示在过去某一时间或动作以前已经完成了的动作。这个过去的时间常用by,before等介词短语或一个时间状语从句表示,也可以暗含在上下文中。 I had finished my homework before supper.我在晚饭前就把作业做完了。 The play had already started when we got to the theatre. 我们到剧场时戏已经开始了。 By the end of June they had treated over 10,000 patients. 到六月底他们已经治疗了一万多病人。 2. 过去完成时还可表示过去某一时刻之前发生的动作或状态持续到过去某个时间或还要持续下去,常与for,since等词连用。如: He had served in the army for ten years before he retired last year. 他在部队干了十年,去年退役了。 He told me that he had known her since he was a child. 他告诉我他从小就认识她。 He had learned English for eight years before he went to England for further study. 他在去英国深造前,已学了八年英语。 3. 在一段情景连贯的文字中,先发生的事放在后面叙述时,要用过去完成时。如: Tom flew home, but his father had already died. 汤姆乘飞机回家,他的父亲却已经去世了。4. 过去完成时也用于hardly...when...(刚…就…), no sooner...than... (刚…就…), It was the first time + that分句等一些固定句型中。 He had no sooner left the room than they began to talk about him. 他刚离开房间,他们就议论起他来。 We had hardly begun when we were told to stop. 我们刚开始就被叫停。 It was the first time that he had ever spoken to me in such a tune.他用这样的语调跟我讲话,这是第一次。 二、过去完成时与一般过去时的比较 1. 当一个由before, after, as soon as 等连词引导的从句所表示的动作和主句的动作紧接着发生时,两个动作均可用一般过去时来表示。 We had breakfast after we did morning exercises. 做完早操后,我们吃早饭。 The train started to move just before he reached the platform. 他到月台时火车刚开走。 They started ploughing as soon as they got to the fields. 他们一到地里就开始耕地。 2. 按时间顺序叙述两个或两个以上接连发生的动作时,用一般过去时。 He entered the room, turned on the light and sat down at the table. 他走进屋子,打开灯,坐在桌子旁。 3. 在表示某人过去未曾完成的“心愿”、“打算”、“计划”、“想法”、“许诺”等时,hope, mean, plan, think, intend等谓语动词常用过去完成时。 I had hoped to be back last night, but I didn’t catch the train. 我本来希望昨晚回来的,但没搭上火车。 We had thought to return early but they wouldn’t let us go. 我们本想早回来的,但他们不让我们走。 4. 在表示过去的句子中出现常与完成时态连用的词,如:already,yet,since,for,ever,

过去分词用法详解

过去分词的用法 一、构成:规则动词的过去分词是有动词原形+ed构成的,不规则动词则有各自构成。 二、基本特点:过去分词在句子中的基本用法有两点:1.与逻辑主语之间是被动关系 2.表示完成的动作 三、过去分词的用法: 1.作表语:过去分词作表语时,一般同时具备被动与完成的含义 例如:(1)The cup is broken.(2)He is retired. (3)After running,he is tired. 【注意】过去分词作表语时,已经变成形容词性质,主要表示主语的状态(被动完成),而被动语态则表示动作. 例如:(1) The cup was broken by my little sister yesterday. 茶杯是昨天我小妹打碎的.(是被动语态,表示动作) (2)The cup is now broken. 茶杯碎了.(过去分词作表语,表示状态) 【注意】有些动词如interest, bore, worry, surprise, frighten 等通常用其过去分词形式来修饰人,表示“感到……” 用-ing 形式来修饰物,表示“令人……” 例如:The book is interesting and I'm interested in it. 这本书很有趣,我对它很感兴趣. 2.做定语 作定语用的过去分词其逻辑主语就是它所修饰的名词.及物动词的过去分词作定语,既表被动又表完成;不及物动词的过去分词作定语,只表完成. 1)单一过去分词作定语,常置于其所修饰的名词之前,称作前置定语。 例如:We must adapt our thinking to the changed conditions. 我们必须使我们的思想适应改变了的情况. 2)过去分词短语用作定语时,一般置于其所修饰的名词之后,相当于一个定语从句,称作后置定语。 例如:The concert given by their friends was a success.他们朋友举行的音乐会大为成功. 3)过去分词短语有时也可用作非限制性定语,前后常有逗号. 例如:The meeting, attended by over five thousand people, welcomed the great hero. 4)用来修饰人的过去分词有时可以修饰与人有关的表情,面貌,举止行为以及感觉等,这时不能用v-ing形式例如:The boy looked up with a pleased expression. His satisfied look showed that he had passed this exam. 3.作状语 作状语的过去分词在句子中多表示被动和完成两重含义。 1)时间状语:A.当和谓语动词动作同时发生时,一般仅表示被动,可以用when从句代替。 例如:Faced with difficulties,we shouldn’t withdraw for any excuse. B.当表示动作发生在谓语动词之前时,通常既表被动又表完成,可用after从句代替,也可用现在分词的被动完成形式代替。 例如:Caught by the police,the thief lay on the ground,crying and shouting. 2)原因状语:过去分词所表示的动作多有被动和完成两重含义。 例如:Written in a hurry, this article was not so good! 因为写得匆忙,这篇文章不是很好. Welcomed by all the students,we expressed own true thanks to them.被全体同学欢迎,我们表达真挚的感激【注意】有些过去分词因来源于系表结构,作状语时不表被动而表主动.这样的过去分词及短语常见的有: lost (迷路); seated (坐); hidden (躲); stationed (驻扎); lost / absorbed in (沉溺于); born (出身于); dressed in (穿着); tired of (厌烦). 等,这种结构可以改写成一个because引导的主系表结构句子。 例如:Lost / Absorbed in deep thought, he didn't hear the sound.因为沉溺于思考之中,所以他没听到那个声音. Tired of the noise,he decided to move to the country.因厌倦了噪音,他决定搬到农村去。 Dressed in an orange dress,she looked more beautiful than before.穿上橘红色连衣裙,她看起来比以前更美3)条件状语:作条件状语时,一般只表被动含义。相当于if引导的条件状语从句。 例如:Grown in rich soil, these seeds can grow fast. 如果种在肥沃的土壤里,这些种子能长得很快. 4)伴随情况:表示伴随谓语动词发生的另外动作,位于主语之后,用逗号隔开,可以同时表示被动与完成, 例如:The mother ran across the street,followed by her little son. 5)结果状语:表示发生在谓语动词后的动作,位于主句后用都逗号分开,也可以同时表示被动与完成。 例如:He listened to the hero’s story,moved to tears. 【注意】状语从句改成过去分词作状语时有时还可保留连词,构成"连词+过去分词"结构作状语. 例如:When given a medical examination, you should keep calm. 当你做体格检查时要保持镇定.

如何在lingo中使用集合1

例题1. 在lingo 中输入下列线性规划模型,并求解 ∑∈?=A j i j i x j i d z ),(),(),( min s.t. 1),1(≥∑∈V j j x , , },10,,2,1{,0),(x ,),(, 1,1),(V V A V V i i i j i x j j i x V i ?==∈=>=∑∈ 为非负实数 所有 的数值如下表:d d=0 8 5 9 12 14 12 16 17 22 8 0 9 15 16 8 11 18 14 22 5 9 0 7 9 11 7 12 12 17 9 15 7 0 3 17 10 7 15 15 12 16 9 3 0 8 10 6 15 15 14 8 11 17 8 0 9 14 8 16 12 11 7 10 10 9 0 8 6 11 16 18 12 7 6 14 8 0 11 11 17 14 12 15 15 8 6 11 0 10 22 22 17 15 15 16 11 11 10 0; 分析:这个模型输入的难点,在于变量的数量太多,足足有100个。约束条件也比较多,有没有什么方便的输入方法?下面介绍lingo 中集合的建立 新建lingo 文件 输入下面内容 model : sets : V/1..10/;!创建集合V; A(V,V):d,x;!创建集合A 是V 乘V.而d,x 是与A 同结构的,即d ,x 分别是10*10矩阵; endsets min =@sum (A(i,j):d(i,j)*x(i,j));!创建目标函数; @sum (V(j):x(1,j))>=1; !第一个约束条件; @for (V(j)|j#gt#1: !i#gt#1为逻辑判断语句表示i>1是返回真值,但这里不能直接写i>1,因为">"是关系运算符不是逻辑运算符; @sum (V(i):x(i,j))=1;); !利用循环函数表达:当i>1(即i 从2到10)时, {x(i,j):j=1..10}的和等于1;

中考考点_过去完成时知识点汇总(全)

中考考点_过去完成时知识点汇总(全) 一、初中英语过去完成时 1.—How long you TV by the time I called you? —For about two hours A. had; watched B. have; watched C. did; watch D. were; watching 【答案】 A 【解析】【分析】由句中的by the time可判断.这里用过去完成时,故选A。句意是:—到我打电话给你为止,你已经看了多长时间的电视了?—大约两个小时。 【点评】本题考查过去完成时的用法。 2.We are too tired. Please stop __________ a rest. A. to have B. having C. have D. has 【答案】 A 【解析】【分析】句意:我们是在太累了,停下来休息一下吧。stop to have a rest.固定搭配故选A 【点评】注意时态一致, 3.Jake _____his key in the office so he had to wait until his wife _______ home. A. has forgotten … comes B. forgot… come C. had left… came D. had left…would come 【答案】 C 【解析】【分析】句意:杰克把他的钥匙丢在办公室了,因此他不得不等到他的妻子回家。结合语境可知前文描述的是过去某时前已经完成的动作,故用过去完成时态。下文指的是过去某时的动作,故用一般过去时态。选C。 【点评】英语中的时态主要是借助于时间状语与上下文语境来进行判断。解答此类题型,首先要注意句子中的时间状语,如果没有则要通过分析上下文,结合语境来判断句子的时态。 4.By the end of last month, Jane _____ enough money for the poor sick boy. A. raised B. would raise C. had raised D. has raised 【答案】 C 【解析】【分析】句意:在上个月末,珍已经为贫穷的生病的孩子筹集到了足够的钱。根

过去完成时结构与用法

过去完成时(The Past Perfect Tense):过去完成时表示过去某一时间之前完成的动作或发生的情况,句子谓语形式由had+动词的过去分词构成,通常表述为“过去的过去”。在不同的句子结构中有相应体现,也可跟有一定的时间状语,如by, before等介词或连词。 1. 过去完成时的结构: 肯定句:主语+had+done+others A. I had arrived. 我已经到了。 B. He had sent the letter. 他已经寄了这封信。 否定句:主语+had+not+done+others A. However,Her father had not brought her birthday presents. 然而,她的父亲没有给她买生日礼物。 疑问句:had+主语+done+others 肯定回答:YES,主语+had/否定回答:NO,主语+ hadn’t

A. Had Lisa gone to costume ball ? 丽莎已经去化妆舞会了吗? Yes,she had. 是的,她去了。 No,she hadn’t. 没有,她没去。 特殊疑问句:特殊疑问词+had+主语+done+others A. Why had The Castle become a memory of generation? 为什么电影城堡已经成为了一代的记忆? 被动语态:主语+had(not)been+done+others A. At the end of last year,another magic design had been completed. 在去年低,另一个神奇的设计已经完成。 B. There was still doubtful that why the film had not been chased by public. 对于这部电影为什么没有被大众所追捧依然存在些疑惑。2. 过去完成时的用法 在宾语从句中的运用:

过去分词的用法

过去分词的用法 1. 分词的定义 动词的-ed分词即过去分词,是由动词的过去分词构成,一般只有一种形式。 2. 过去分词的语法作用 过去分词一方面具有动词的性质,另一方面也相当于一个形容词或副词,在句中可以作表语、定语、状语和补足语。 3. 过去分词作表语 1)过去分词作表语,主要表示主语的心理感觉或所处的状态。如: Don’t touch the glass because it is broken. 不要碰那个杯子,它是坏的。 He is quite pleased with the design of the dress. 她很喜欢那礼服的式样。 2)及物动词的过去分词作表语,与句子主语是被动关系,表示主语的状态,既表示被动, 又表示完成。 The cup is broken. 茶杯破了。 3)不及物动词的过去分词作表语,与句子主语是主动关系,表示主语的状态,只表示动作 的完成。 He is retired. 他已退休。 4)过去分词作表语与被动语态的区别:过去分词作表语,主要是表示主语的状态,而被动 语态则表示动作。 The cup was broken by my little sister yesterday. 茶杯是昨天我小妹打碎的。(是被动语态,表示动作) The library is now closed. 图书馆关门了。(过去分词作表语) 4. 过去分词作定语 1)单个的过去分词作定语一般放在名词的前面,相当于一个定语从句。 The excited people rushed into the building. 激动的人们奔进了大楼。 =The people who were excited rushed into the building. 2)过去分词短语作定语通常放在被修饰的词后面,相当于一个定语从句。 The suggestion made by the foreign expert was adopted by the manager. 外国专家提出来的建议被经理采纳了。 =The suggestion that was made by the foreign expert was adopted by the manager. 3)过去分词作定语也可用作非限制性定语,前后用逗号隔开。 The books, written by Lu Xun, are popular with many Chinese people.

(完整版)过去完成时的用法总结,推荐文档

1. cleaned the blackboard 2. closed the window ——————∣—————∣—————→∣——→ had cleaned the closed the window now blackboard She had cleaned the blackboard before she closed the window. After she had cleaned the blackboard , she closed the window. 1. ran out of breath 2. drank water ——————∣—————∣—————→∣——→ had run out drank water now of breath He had run out of breath before he drank water. After he had run out of breath, he drank water. 1. ate an apple 2. slept ——————∣—————∣—————→∣——→ had eaten slept now an apple She had eaten an apple before she slept. After she had eaten an apple , she slept. 一、过去完成时定义: ②过去某动作一直持续到现在将来可能还要延续下去。句中的动作发生在过去之前(过去的过去),即过去完成时动作发生在过去的过去。 He said he had been to Beijing twice. 他说他已经去过北京两次。(因为“说”said就是过去式,而去北京的动作发生在说said 的过去,所以用过完而不用现完。

相关文档
最新文档