当前位置:文档之家› sstream库函数用法详解

sstream库函数用法详解

sstream库函数用法详解
sstream库函数用法详解

C++的sstream标准库介绍

C++风格的串流控制,C++引入了ostringstream、istringstream、stringstream这三个类,要使用他们创建对象就必须包含sstream头文件。

istringstream类用于执行C++风格的串流的输入操作。

ostringstream类用于执行C风格的串流的输出操作。

stringstream类同时可以支持C风格的串流的输入输出操作。

istringstream类是从istream(输入流类)和stringstreambase(c++字符串流基类)派生而来, ostringstream是从ostream(输出流类)和stringstreambase(c++字符串流基类)派生而来, stringstream则是从iostream(输入输出流类)和和stringstreambase (c++字符串流基类)派生而来。

istringstream是由一个string对象构造而来,istringstream类从一个string对象读取字符。

istringstream的构造函数原形如下:

istringstream::istringstream(string str);

//程序作者:管宁

//站点:https://www.doczj.com/doc/6d1110168.html,

//所有稿件均有版权,如要转载,请务必著名出处和作者

#include

#include

using namespace std;

int main()

{

istringstream istr;

istr.str("1 56.7",);

//上述两个过程可以简单写成 istringstream istr("1 56.7");

cout << istr.str()<

int a;

float b;

istr>>a;

cout<

istr>>b;

cout<

system("pause");

}

上例中,构造字符串流的时候,空格会成为字符串参数的内部分界,例子中对a,b对象的输入"赋值"操作证明了这一点,字符串的空格成为了整型数据与浮点型数据的分解点,利用分界获取的方法我们事实上完成了字符串到整型对象与浮点型对象的拆分转换过程。

str()成员函数的使用可以让istringstream对象返回一个string字符串(例如本例中的输出操作(cout<

ostringstream同样是由一个string对象构造而来,ostringstream类向一个string 插入字符。

ostringstream的构造函数原形如下:

ostringstream::ostringstream(string str);

示例代码如下:

//程序作者:管宁

//站点:https://www.doczj.com/doc/6d1110168.html,

//所有稿件均有版权,如要转载,请务必著名出处和作者

#include

#include

#include

using namespace std;

int main()

{

ostringstream ostr;

//ostr.str("abc");//如果构造的时候设置了字符串参数,那么增长操作的时候不会从结尾开始增加,而是修改原有数据,超出的部分增长

ostr.put('d');

ostr.put('e');

ostr<<"fg";

string gstr = ostr.str();

cout<

system("pause");

}

在上例代码中,我们通过put()或者左移操作符可以不断向ostr插入单个字符或者是字符串,通过str()函数返回增长过后的完整字符串数据,但值得注意的一点是,当构造的时候对象内已经存在字符串数据的时候,那么增长操作的时候不会从结尾开始增加,而是修改原有数据,超出的部分增长。

对于stringstream了来说,不用我多说,大家也已经知道它是用于C++风格的字符串的输入输出的。

stringstream的构造函数原形如下:

stringstream::stringstream(string str);

示例代码如下:

//程序作者:管宁

//站点:https://www.doczj.com/doc/6d1110168.html,

//所有稿件均有版权,如要转载,请务必著名出处和作者

#include

#include

#include

using namespace std;

int main()

{

stringstream ostr("ccc");

ostr.put('d');

ostr.put('e');

ostr<<"fg";

string gstr = ostr.str();

cout<

char a;

ostr>>a;

cout<

system("pause");

}

除此而外,stringstream类的对象我们还常用它进行string与各种内置类型数据之间的转换。

示例代码如下:

//程序作者:管宁

//站点:https://www.doczj.com/doc/6d1110168.html,

//所有稿件均有版权,如要转载,请务必著名出处和作者

#include

#include

#include

using namespace std;

int main()

{

stringstream sstr;

//--------int转string-----------

int a=100;

string str;

sstr<

sstr>>str;

cout<

//--------string转char[]--------

sstr.clear();//如果你想通过使用同一stringstream对象实现多种类型的转换,请注意在每一次转换之后都必须调用clear()成员函数。

string name = "colinguan";

char cname[200];

sstr<

sstr>>cname;

cout<

system("pause");

}

接下来我们来学习一下输入/输出的状态标志的相关知识,C++中负责的输入/输出的系统包括了关于每一个输入/输出操作的结果的记录信息。这些当前的状态信息被包含在

io_state类型的对象中。io_state是一个枚举类型(就像open_mode一样),以下便是它包含的值。

goodbit 无错误

Eofbit 已到达文件尾

failbit 非致命的输入/输出错误,可挽回

badbit 致命的输入/输出错误,无法挽回

有两种方法可以获得输入/输出的状态信息。一种方法是通过调用rdstate()函数,它将返回当前状态的错误标记。例如,假如没有任何错误,则rdstate()会返回goodbit.

下例示例,表示出了rdstate()的用法:

//程序作者:管宁

//站点:https://www.doczj.com/doc/6d1110168.html,

//所有稿件均有版权,如要转载,请务必著名出处和作者

#include

using namespace std;

int main()

{

int a;

cin>>a;

cout<

if(cin.rdstate() == ios::goodbit)

{

cout<<"输入数据的类型正确,无错误!"<

}

if(cin.rdstate() == ios_base::failbit)

{

cout<<"输入数据类型错误,非致命错误,可清除输入缓冲区挽回!"<

system("pause");

}

另一种方法则是使用下面任何一个函数来检测相应的输入/输出状态:

bool bad();

bool eof();

bool fail();

bool good();

下例示例,表示出了上面各成员函数的用法:

//程序作者:管宁

//站点:https://www.doczj.com/doc/6d1110168.html,

//所有稿件均有版权,如要转载,请务必著名出处和作者

#include

using namespace std;

int main()

{

int a;

cin>>a;

cout<

if(cin.good())

{

cout<<"输入数据的类型正确,无错误!"<

}

if(cin.fail())

{

cout<<"输入数据类型错误,非致命错误,可清除输入缓冲区挽回!"<

system("pause");

}

如果错误发生,那么流状态既被标记为错误,你必须清除这些错误状态,以使你的程序能正确适当地继续运行。要清除错误状态,需使用clear()函数。此函数带一个参数,它是你将要设为当前状态的标志值。,只要将ios::goodbit作为实参。

示例代码如下:

//程序作者:管宁

//站点:https://www.doczj.com/doc/6d1110168.html,

//所有稿件均有版权,如要转载,请务必著名出处和作者

#include

using namespace std;

int main()

{

int a;

cin>>a;

cout<

cin.clear(ios::goodbit);

cout<

system("pause");

}

通常当我们发现输入有错又需要改正的时候,使用clear()更改标记为正确后,同时也需要使用get()成员函数清除输入缓冲区,以达到重复输入的目的。

示例代码如下:

//程序作者:管宁

//站点:https://www.doczj.com/doc/6d1110168.html,

//所有稿件均有版权,如要转载,请务必著名出处和作者

#include

using namespace std;

int main()

{

int a;

while(1)

{

cin>>a;

if(!cin)//条件可改写为cin.fail()

{

cout<<"输入有错!请重新输入"<

cin.clear();

cin.get();

}

else

{

cout<

break;

}

}

system("pause");

}

最后再给出一个对文件流错误标记处理的例子,巩固学习,代码如下:

//程序作者:管宁

//站点:https://www.doczj.com/doc/6d1110168.html,

//所有稿件均有版权,如要转载,请务必著名出处和作者

#include

#include

using namespace std;

int main()

{

ifstream myfile("c:\\1.txt",ios_base::in,0);

if(myfile.fail())

{

cout<<"文件读取失败或指定文件不存在!"<

}

else

{

char ch;

while(myfile.get(ch))

{

cout<

}

if(myfile.eof())

{

cout<<"文件内容已经全部读完"<

}

while(myfile.get(ch))

{

cout<

}

}

system("pause");

}

c++ 中 stringstream介绍

2010-01-28 01:03

C++标准库中的提供了比ANSI C的更高级的一些功能,即单纯性、类型安全和可扩展性。在本文中,我将展示怎样使用这些库来实现安全和自动的类型转换。

为什么要学习

如果你已习惯了风格的转换,也许你首先会问:为什么要花额外的精力来学习基于的类型转换呢?也许对下面一个简单的例子的回顾能够说服你。假设你想用

sprintf()函数将一个变量从int类型转换到字符串类型。为了正确地完成这个任务,你必须确保证目标缓冲区有足够大空间以容纳转换完的字符串。此外,还必须使用正确的格式化符。如果使用了不正确的格式化符,会导致非预知的后果。下面是一个例子:

int n=10000;

chars[10];

sprintf(s,”%d”,n);// s中的内容为“10000”

到目前为止看起来还不错。但是,对上面代码的一个微小的改变就会使程序崩溃:

int n=10000;

char s[10];

sprintf(s,”%f”,n);// 看!错误的格式化符

在这种情况下,程序员错误地使用了%f格式化符来替代了%d。因此,s在调用完sprintf()后包含了一个不确定的字符串。要是能自动推导出正确的类型,那不是更好吗?

进入stringstream

由于n和s的类型在编译期就确定了,所以编译器拥有足够的信息来判断需要哪些转换。

库中声明的标准类就利用了这一点,自动选择所必需的转换。而且,转换结果保存在stringstream对象的内部缓冲中。你不必担心缓冲区溢出,因为这些对象会根据需要自动分配存储空间。

你的编译器支持吗?

库是最近才被列入C++标准的。(不要把与标准发布前被删掉的

弄混了。)因此,老一点的编译器,如GCC2.95,并不支持它。如果你恰好正在使用这样的编译器而又想使用的话,就要先对它进行升级更新。

库定义了三种类:istringstream、ostringstream和stringstream,分别用来进行流的输入、输出和输入输出操作。另外,每个类都有一个对应的宽字符集版本。简单起见,我主要以stringstream为中心,因为每个转换都要涉及到输入和输出操作。

注意,使用string对象来代替字符数组。这样可以避免缓冲区溢出的危险。而且,传入参数和目标对象的类型被自动推导出来,即使使用了不正确的格式化符也没有危险。

string到int的转换

string result=”10000”;

int n=0;

stream<

stream>>n;//n等于10000

重复利用stringstream对象

如果你打算在多次转换中使用同一个stringstream对象,记住再每次转换前要使用clear()方法;

在多次转换中重复使用同一个stringstream(而不是每次都创建一个新的对象)对象最大的好处在于效率。stringstream对象的构造和析构函数通常是非常耗费CPU时间的。

在类型转换中使用模板

你可以轻松地定义函数模板来将一个任意的类型转换到特定的目标类型。例如,需要将各种数字值,如int、long、double等等转换成字符串,要使用以一个string类型和一个任意值t为参数的to_string()函数。to_string()函数将t转换为字符串并写入result中。使用str()成员函数来获取流内部缓冲的一份拷贝:

template

void to_string(string & result,const T& t)

{

ostringstream oss;//创建一个流

oss<

result=oss.str();//获取转换后的字符转并将其写入result

}

这样,你就可以轻松地将多种数值转换成字符串了:

to_string(s1,10.5);//double到string

to_string(s2,123);//int到string

to_string(s3,true);//bool到string

可以更进一步定义一个通用的转换模板,用于任意类型之间的转换。函数模板convert()含有两个模板参数out_type和in_value,功能是将in_value值转换成out_type类型:

template

out_type convert(const in_value & t)

{

stringstream stream;

stream<

out_type result;//这里存储转换结果

stream>>result;//向result中写入值

return result;

}

这样使用convert():

double d;

string salary;

string s=”12.56”;

d=convert(s);//d等于12.56

salary=convert(9000.0);//salary等于”9000”

结论

在过去留下来的程序代码和纯粹的C程序中,传统的形式的转换伴随了我们很长的一段时间。但是,如文中所述,基于 stringstream的转换拥有类型安全和不会溢出这样抢眼的特性,使我们有充足得理由抛弃而使用库还提供了另外一个特性

—可扩展性。你可以通过重载来支持自定义类型间的转换。

一些实例:

stringstream通常是用来做数据转换的。

相比c库的转换,它更加安全,自动和直接。

例子一:基本数据类型转换例子 int转string

#include

#include

#include

int main()

{

std::stringstream stream;

std::string result;

int i = 1000;

stream << i; //将int输入流

stream >> result; //从stream中抽取前面插入的int值

std::cout << result << std::endl; // print the string "1000" }

运行结果:

例子二:除了基本类型的转换,也支持char *的转换。

#include

#include

int main()

{

std::stringstream stream;

char result[8] ;

stream << 8888; //向stream中插入8888

stream >> result; //抽取stream中的值到result

std::cout << result << std::endl; // 屏幕显示 "8888"

}

例子三:再进行多次转换的时候,必须调用stringstream的成员函数clear().

#include

#include

int main()

{

std::stringstream stream;

int first, second;

stream<< "456"; //插入字符串

stream >> first; //转换成int

std::cout << first << std::endl;

stream.clear(); //在进行多次转换前,必须清除stream

stream << true; //插入bool值

stream >> second; //提取出int

std::cout << second << std::endl;

}

运行clear的结果

没有运行clear的结果

英语主谓一致练习全集

英语主谓一致练习全集 一、主谓一致 1.On no-car day, ____________ students ____________ teachers are allowed to drive to school. A.either; or B.not only; but also C.neither; nor D.both; and 【答案】C 【解析】 句意:在无车日,学生和老师都不被允许开车去学校。either; or 或者,或者; not only; but also不仅,而且; neither; nor 既不,也不;both; and……和……都;根据On no-car day可知此处表示无车日,因此都不开车,故选C。 2.Smog and haze is a kind of air pollution. It _______ people _____ about their health. A.make, worry B.make, be worried C.makes, worried D.makes, worry 【答案】D 【解析】 【详解】 句意:雾霾是一种空气污染。它使人们担心他们的健康。考查主谓一致和动词短语辨析。it是单数第三人称,动词需用三单形式,可排除AB两项。make让,使役动词,make sb. do sth.让某人做某事,是固定结构,可排除C项。根据句意结构,可知选D。 3.The boys ____________ from America like China A.who is B.are C.which is D.who are 【答案】D 【解析】 【详解】 句意:这些来自美国的男孩喜欢中国。考查定语从句。本句是主谓宾结构,可排除B项。空白处做主语the boys的后置定语,先行词the boys是人,不可用which(用于先行词是 物时),需用who引导;the boys是复数人称,系词需用are;根据句意结构,可知选D。 4.Either Eve or Herb ___________ been invited by Lucy’s parents already. A.have B.has C.was D.Were 【答案】B 【解析】 【详解】 句意:伊芙或赫伯已经被路西的父母邀请了。 Either ... or...或者……或者,连接两个主语时,用就近原则,already是现在完成时的标志词,结合句意,故选B

英语语法专项:动名词用法讲解及练习(附答案)

你听过英文语法有动词(verb)、名词(noun);但你听过有动名词(gerund)吗? 1. The girl is singing a song. 2. The girl singing now is my sister. 3. Singing is one of her hobbies(爱好). 三个句子中都有singing。第一个句子的singing是常见的现在进行式(Present Continuous),是说眼下正在做什么;第二个句子的singing是现在分词(Present Participle),它把sing这个动词转为形容词,但仍有动词的成份(哈哈,这么一说,要把你搞晕了吧:-) 。关于分词,以后有空再谈OK?)。好戏在后头,你看看第三个句子的singing到底是什么东东呀?原来就是我们的主角动名词(Gerund)了!憧矗瑂ing原本是个动词,可是现在它加上ing后,看来竟像是一个名词了。 一、名词性的动名词(Nominal Gerund) Nominal Gerund 可以加上定冠词(Definite article,如the)或不定冠词(Indefinite article,如a, an),其他可加在动名词前的还有如:my, this, some, any, all, no 等等。举例如下: 1. The mellow(愉快地) singing of the birds announces the coming of spring. (singing前加定冠词the及形容词mellow;coming 前加the) 2. We knew the robber was near when we heard a faint rustling(沙沙声) in the bushes. (rustling 前加不定冠词a及形容词faint) 从上面的例子可看出如何将一个动词转成名词;但它和真正的名词还是有区别的,那就是没有单数或复数之分。不过,有一些动名词是可以变成真正名词的喔,如:saying, writing, opening, painting, cutting, heading, feeling, being,saving, surrounding, crossing, misunderstanding 等等。它们都可以有复数的喔,方法就是在它们的后面加个s,如:paintings。 二、动词性的动名词(Verbal Gerund) 看看下面的句子: Carelessly writing essays annoys the teacher. 上面的句子里的writing是动名词,但前面有副词carelessly(粗心地),后面又有受词(Object) essays。因此writing就有动词的特征。 注意:Verbal Gerund 这类动名词的前面可不能加上任何冠词(the, a, an ...)喔。 动名词的功能与用法 一、在句子中用作主语(Subject)或主语的补语(Subject Complement): 1.1 作主语 1. Listening to music gives me pleasure. (主语Listening ) 2. Running is good exercise. (主语running) 3. Walking to school is a good idea. (主语walking) 1.2 作主语的补语 1. My cat's favorite activity is sleeping. (补语sleeping) 2. Seeing is believing. (主语seeing, 补语believing) 1.3 主语置于句尾 1.3.1 用It + be + ... +v-ing 句型 1. It is fun speaking English. 2. It is of great importance fighting against pollution(污染).

英语动词重要分类及用法说明

英语动词重要分类及用法说明 ■及物动词与不及物动词 根据后面是否带宾语,行为动词又可分为及物动词和不及物动词,及物动词(vt)后面要跟宾语,不及物动词(vi)不跟宾语。如: They study hard. 他们勤奋学习。(study后没有宾语,是不及物动词) I know them well. 我很了解他们。(know后有宾语them,是及物动词) 注:有的动词既可作及物动词,也可用作不及物动词。如: She sings very well. 她唱得很好。(sing是不及物动词) She sang an English song just now. 她刚才唱了一首英文歌。(sing是及物动词) ■动态动词和静态动词 根据词义特点,行为动词可分为动态动词和静态动词。动态动词表示动作,如give, take, work, run等;静态动词表示感觉、情感、内心世界、相互关系等,如know, live, lie, exist, be, have, mean, seem, appear, sound, prove, concerns, hate, dislike, like, love, prefer, surprise, astonish, satisfy, contain, include, matter depend on, belong to, guess, suppose,imagine, believe, doubt, admire, envy等。 ■延续性动词和非延续性动词 根据动作是否延续,行为动词又分为延续性动词和非延续性动词。如rain, live, work, learn等是延续性动词,go, come, leave, start, arrive, join, finish, end等是非延续性动词。 注:非延续性动词在肯定句中通常不与表示时间段连用的for短语连用。如: [译]他离开这里三天了。 [误]He has left here for three days. [正]He has been away from here for three days. [正]He left here three days ago. [正]It’s three days since he left. ■限定动词与非限定动词 限定动词在句中作谓语,有人称和数的变化。非限定动词有动词不定式、动名词和分词三

人教版英语英语数词复习附答案解析

人教版英语英语数词复习附答案解析 一、初中英语数词 1.Our country is 70 years old this year. We will celebrate her _____ birthday on Oct. 1. A. the seventieth B. seventieth C. the seventy D. seventy 【答案】 B 【解析】【分析】句意:今年我们的国家70岁了,我们将在10月1日庆祝她的70岁生日。表达某人几岁生日用one's+序数词+birthday,seventy,70,基数词;seventieth第七十,序数词,排除C、D,故选B。 【点评】考查序数词用法,注意平时识记one's+序数词+birthday。 2.The number of the students in our school is about four __________. _______ of them are girls. A. thousand; Two thirds B. thousands; Two third C. thousands; Two thirds D. thousand; Two third 【答案】 A 【解析】【分析】句意:我们学校的学生人数大约是四人。三分之二是女孩。four基数词后用thousand的原形,分数表达形式是分子是基数词,分母是序数词,分子大于一,分母用复数形式,故三分之二是two thirds,故选A。 【点评】考查数词,注意分数的用法。 3. should not be allowed to drive. A. Sixteen-year-old B. Sixteen years old C. Sixteen-year-olds D. Sixteen year olds 【答案】 C 【解析】【分析】句意:16岁的青少年不允许开车。sixteen-year-olds:十六岁的孩子(青少年),是名词性短语;sixteen-year-old:通常只做形容词用,十六岁的;sixteen years old:十六岁。结合句意,故答案为C。 【点评】考查数词和名词的用法。注意识记名词sixteen-year-olds。 4.Lin Tao, an ______ boy, was very brave and helped his classmates run out of the classroom when the earthquake happened. A. 8-year-old B. 8 year old C. 8-years-old D. 8 year olds 【答案】 A 【解析】【分析】句意:林涛,八岁的男孩,很勇敢并且在地震发生时帮助他的同学从教室里跑出来。数量词在句中作前置定语,注意量词用单数,并且带连字符号,故选A。【点评】考查数量词在句中作定语的用法。 5.Most of the doctors in this hospital were born ________, and they are ________now. A. in the 1970; in their fifties B. in 1970s; in the fiftieth C. in the 1970s; in fiftieth D. in the 1970s; in their fifties

l主谓一致讲解最全面主谓一致讲解

主谓一致的讲解 主谓一致是指: 1)语法形式上要一致,即名词单复数形式与谓语要一致。 2)意义上要一致,即主语意义上的单复数要与谓语的单复数形式一致。 一、并列结构作主语时的主谓一致 1.由and 连接主语时 And 连接的两个或多个单数可数名词、不可数名词或代词作主语时根据意义或概念确定谓语用单数或复数 1)并列主语表示不同的人、物或概念时谓语动词用复数 Li Ming and Zhang Hua are good students. Like many others, the little tramp and the naughty boy have rushed there in search of gold. 小流浪汉和调皮的小男孩也赶到那里寻找金子 Both rice and wheat are grown in this area. 2)并列主语表示同一个人、物或概念时,谓语动词用单数形式。 The professor and writer is speaking at the meeting. 那位教授兼作家正在会上发言 A journalist and authour lives on the sixth floor. 一位新闻记者兼作家 His lawyer and former college friend was with him on his trip to Europe. 他的律师兼大学时代的朋友陪他去欧洲旅行 The Premier and Foreign Minister was present at the state banquet. 总理兼外长 比较:the writer and the educator have visited our school. the writer and educator has visited our school. His lawyer and his former college friend were with him on his trip to Europe. 注意:指同一个人或物时,并列主语前只用一个冠词,指不同的需要分别加冠词,但两个名词具有分别的对立的意思时只需要一个冠词即可 A boy and girl are playing tennis. 3)并列主语前有each, every, many a , no 等修饰时谓语动词用单数 Each doctor and (each) nurse working in the hospital was asked to help patients. Every man, woman and child is entitled to take part in the activity. 有权参加 Every boy and (every) girl admires him for his fine sense of humour. Many a boy and (many a ) girl has made the same mistake No boy and no girl is there now.没有任何男孩和女孩在那里 注意:many a 跟单数可数名词但是表示复数意义翻译为很多 Many a student was disappointed after seeing the movie. 4)并列主语为不可分的整体时,谓语动词用单数 A law and rule about protecting environment has been drawn up. 关于保护环境的法律法规已经起草完成。 The knife and fork has been washed 刀叉已经被洗好 War and peace is a constant theme in history 战争与和平是历史永恒的主题 注意;常被视为主体的结构 A cup and saucer 一副杯碟 A horse and cart 马车 A knife and fork 一副刀叉

商务写作指南:超好记的appreciate的用法

WRONG: We would appreciate if you corrected the entry in the register as soon as possible. 错误用法:如果你能尽快更改登记处的入口,我将非常感激。 RIGHT: We would appreciate it if you corrected the entry in the register as soon as possible. 正确用法:如果你能尽快更改登记处的入口,我将非常感激(英语原句比前者多了一个it)。This is a very common mistake, and remember that when you use the phrase “I would appreciat e…”you MUST include the word “it”before “if”: 这是一个常见错误,记住当你要用“I would appreciate…”这个表达式时,一定要在if前加一个it。 More examples: 更多例子: E.g.1:I am sure the supervisory authority would not appreciate it if you took that course of action. 例1:我相信监督部门对你的所作所为不会表示欣赏。 E.g.2:We would appreciate it if you would arrange for immediate payment. 例2:如果您能立即付款,我们将很感激。 There is no need to add “it”if you do not include “if”. 如果你不用if从句的话,就没有必要在appreciate后面加it了。 E.g.: We would much appreciate a letter informing us of the result of your enquiries. 例句:如果您能对您的询盘结果给我们回信的话,我们将非常感激。 An alternative phrase to “I would appreciate it if…”is, “I would be grateful if…”This is the more formal phrase of the two and does not require that troublesome“it”! “I would appreciate it if…”这个表达式的替代用法有“I would be grateful if…”,但是这个用法更为正式,而且不需要加那个麻烦的“it”!

英语动词分类讲解及练习(有答案)

一.动词概述 注:英语行为动词也可以分为及物动词和不及物动词。及物动词是必须带宾语的动词。可以分为两类:(1)及物动词+宾语(2)及物动词+间接宾语+直接宾语 My mother bought me a gift. (可以接双宾语的词有:give, teach, buy, l end, find, hand, l eave, sell, show, read, pay, make, offer, buil d, pass, bring, cook等 不及物动词不需要跟宾语,本身意义完整。有些不及物动词加上介词后变成及物性短语动词,后跟宾语。She did not reply to my l etter。 英语中接双宾语的动词 award sb. sth. = award sth. to sb. 颁奖给某人 bring sb. sth. = bring sth. to sb. 把某物带给某人 hand sb. sth. =hand sth. to sb. 把某物递给某人 lend sb. sth. = lend sth. to sb. 把某物借给某人 mail sb. sth. = mail sth. to sb. 把某物寄给某人 offer sb. sth. = offer sth. to sb. 将某物给某人 owe sb. sth. = owe sth. to sb. 欠某人某物 pass sb. sth. = pass sth. to sb. 把某物递给某人 pay sb. sth. = pay sth. to sb. 付给某人某物(钱) post sb. sth. = post sth. to sb. 把某物寄给某人 read sb. sth. = read sth. to sb. 把某物读给某人听 return sb.sth. = return sth. to sb. 把某物还给某人 send sb. sth. = send sth. to sb. 把某物送给某人 sell sb. sth. = sell sth. to sb. 把某物卖给某人 serve sb. sth. = serve sth. to sb. 拿某物招待某人 show sb. sth. = show sth. to sb. 拿某物给某人看 take sb. sth. = take sth. to sb. 把某物拿给某人 teach sb. sth. = teach sth. to sb. 教某人某物 tell sb. sth. = tell sth. to sb. 告诉某人某情况 throw sb. sth. = throw sth. to sb. 把某物扔给某人 write sb. sth. = write sth. to sb. 给某人写信 2、双宾语易位时需借助介词for的常用动词 book sb. sth. = book sth. for sb. 为某人预定某物 buy sb. sth. = buy sth. for sb. 为某人买某物 choose sb. sth. = choose sth. for sb. 为某人选某物 cook sb. sth. = cook sth. for sb. 为某人煮某物

英语数词的用法

英语数词的用法 Revised as of 23 November 2020

英语数词用法详解 数词部分 ▲掌握分数、时间、日期的表达法。 【复习要点】 (一)基数词 基数词用来表示数目,或者说表示数量的词叫基数词。最基本的基数词如下表所示。 1 one11 eleven100 a?hundred 2 two12 twelve20 twenty1000 a?thousand 3 three13 thirteen30 thirty1,000,000 a?million 4 four14 fourteen40 forty10,000,000 ten million 5 five15 fifteen50 fifty100,000,000 a?hundred million 6 six16 sixteen60 sixty1,000,000,000 a?billion 7 seven17 seventeen70 seventy 8 eight18 eighteen80 eighty 9 nine19 nineteen90 ninety 10 ten 说明: 1.13—19是由个位数加后缀-teen构成。注意其中13、15的拼写是thirteen和fifteen。

2.20—90由个位数加后缀-ty构成,注意其中20—50的拼写分别是twenty, thirty, forty?和fifty;80的拼写是eighty。 3.其它非整十的两位数21—99是由整十位数加连字符“-”,再加个位数构成。如:81 eighty-one。 4.101—999的基数词先写百位数,后加and再写十位数和个位数。如:691 six hundred and ninety-one。 5.1000以上的基数词先写千位数,后写百位数,再加and,最后写十位数和个位数。 如:5893 five thousand eight hundred and ninety-three。在基数词中只有表示“百”、“千”的单位词,没有单独表示“万”、“亿”的单位词,而是用thousand(千)和million(百万)来表达,其换算关系为:1万=10 thousand;1亿=100 million; 10亿=a thousand million=a billion。 6.多位数的读法: 1)1000以上的多位数,要使用计数间隔或逗号“,”。即从个位起,每隔三位加一个间隔或逗号。第一个间隔或逗号前是thousand(千),第二个间隔或逗号前是million(百万),第三个间隔或逗号前是a thousand million或a billion(十亿)。 2)每隔三位分段以后就都成了101—999。读的时候十位数(或个位数)的前面一般要加and。如: 888,000,000读作:eight hundred and eighty-eight million。 基数词的用法: 1.基数词在句中的作用

(完整)初中英语主谓一致和就近原则讲解及练习.doc

英语语法——主谓一致(就近、就远原则) 就近原则: 也称“ 近原”“就近一致原” (Proximity),即:与靠近的名、代(有不一定是主)在“人称、数”上一致。 在正式文体中: 1. 由下列接的并列主:"there be +句型 ; or ; either;?norr; neither?nor;whether ? or;not ? but; not only?but also"等;。e.g. ①What he does or what he says does not concern me .他的行或言都与我无关。 ②N either you nor I am wrong . 你和我都没。 ③N ot you but your father is to blame . 不是你,而是你父受。 ④Not only you but(also) he is wrong . 不你了,他也了。 2. 在倒装句中:可与后面第一个主一致。 e.g. ①In the distance was heard the clapping of hands and the shouts of the people .在,能听鼓掌声和人的呼喊声。 ②T here is (are) a pen and some books on the desk . 桌上有一支笔和几本。 II.非正式文体中: 有依“就近一致原”,但也可依“意一致原”或格地依“ 法一致原”。 e.g. Neither she nor I were there (意一致)我和他当都不在那儿。(非正式) Neither she nor I was there .(就近一致)(文同上句)(正式) 但是,如果依“就近一致原”而与其他两原相矛盾,常常是不太合符范的。e.g. No one except his own supporters agree with him .他自己的支持者同意他的意。(依“就近”和“意”一致的原;但法上,“ No one ”才是主,要改成“agrees ”。“写作中”一 般要依“ 法一致”原。 英语就近原则短语 1.There be 句型There is a book and some pencils on the desk. =There are some pencils and a book on the desk. 2.neither...nor...Neither you nor he is right. = Neither he nor you are right. 3.either...or...Either they or Jim is going to Shanghai next Saturday. = Either Jim or they are going to shanghai next Saturday. 4.not only...but also... Not only Ann but also her parents stay at home every Sunday.

appreciate表示感谢的用法

外教一对一https://www.doczj.com/doc/6d1110168.html, 用appreciate表示「感谢」,用对不容易 在邮件里表示「感谢」的时候,我们常常会用到appreciate一词;在比较正式的场合,你也会偶尔听到有英美人在口语中使用appreciate 来表示「感谢」的含义。本帖将教会大家如何用对appreciate一词。1)表示感谢的时候,appreciate的对象通常不是某人,而是某件事。 和动词thank不一样的地方在于:thank 后面常常是某人。比如:Thank you for doing sth。但是appreciate后面常常是某件事,比如:I really appreciate your help. 很感谢你的帮助。Your support is greatly appreciated. 很感谢你的支持。以上的两个例句,通常都用在帮助或者支持完成之后说。而下面的这句话,是我们邮件中最常用的句式:I would appreciate it if you paid in cash. 如果你用现金支付,我会非常感谢。这个邮件的高频句式其实很容易出错,注意以下三点:appreciate后面的it不能漏掉appreciate后面不能直接加you以上面的句子为例,主句里的would和从句里的paid使用了过去式,是为了让语气更加婉转,而非表达过去的含义。I will appreciate it if...do...这样的句式也正确。2)中文里可以「欣赏」某人的品质;appreciate也一样。 中文里「欣赏」一词有两层含义:领略欣赏。比如:欣赏一段音乐认为……好。比如:老板很欣赏他的才华。巧合的是,appreciate 也有这两层含义:领略欣赏。You can't fully appreciate foreign literature in translation. 看翻译作品很难欣赏到外国文学的精髓。认为……好。His talents are not fully appreciated in that company. 在那个公司,他的才能得到充分地赏识。丨There's no point buying him expensive wines - he doesn't appreciate them. 别给他买很贵的酒,他不懂得品赏。3)appreciate还有一层生僻的含义:增值 我们会在财经新闻里看到appreciate及其反义词depreciate,分别表示「增值」和「贬值」。Their investments have appreciated over the years. 他们的投资在几年间增值了。currency depreciation 货币贬值 文章来源:https://www.doczj.com/doc/6d1110168.html,

关于动词的分类及用法

关于动词的分类及用法 以下是小编给大家整理的动词的分类及用法,希望可以帮到大家 系动词:大概是最简单的动词了。你只需注意的是系动词除了be的形式之外,还有become,get,grow,turn,sound,look,smell,taste等,它们不能单独作谓语,必须和作表语的词语(如形容词, 名词等) 连用, 所以用的时候,可要小心为是呀!如:It smells delicious.(它闻起来味道很美)。delicious 是形容词,不是副词。 情态动词:首先要记住情态动词后必跟动词原形。 must的意思是"应当,必须",侧重于说话者的主观看法,没有时态变化,其否定 式是mustn't,在"Must I(we) ...."的疑问句中,须注意的是其否定回答常用needn't。如:Must I go?(我一定要走吗?)No,you needn't.(不,不必。) need意为"需要"。既可作实义动词,又可作情态动词,因此在用法上需要注意。 作实义动词时,need后跟名词,动名词,或不定式。如:I need to go. (我得走了。) 作情态动词时,后跟动词原形。如:You needn't come tomorrow if you are busy. (如 果你忙,明天就不必来了。) 实意动词:我们跑(run),我们跳(jump),我们笑(laugh),这些都得用实意动词来 表达。我们一起来看一看一些特殊的词吧。它们在接动名词和不定式时意义有所不同。 stop:这个词让好多同学大伤了一番脑筋,到底什么时候加to do,什么时候加doing 呢?两者意义又有什么不同呢?OK, Come with me. 看下面两个句子。 When the teacher came in, they stopped to read. When the teacher came in, they stopped talking. 第一句的意思是"当老师进来时,他们停下来开始读书"。而第二句的意思是 "老师 进来时,他们停止了说话"。所以stop to do sth表示"停止正在做的事情去干另一件事"。而stop doing表示"中断正在做的某事"。 forget,remember,regret 这三个词用法基本相同,只要记住+doing 表示"事情 已经做过",+to do表示"事情还未做"就可以了。 感官动词:see,watch, notice,look at,hear,listen to,smell,taste,feel 等 +do 表示动 作的完整性,真实性 +doing 表示动作的连续性,进行性。如:I saw him work in the garden yesterday. 昨天我看见他在花园里干活了。(强调"我看见了"这个事实) I saw

高中英语主谓一致知识点讲解

高中英语主谓一致知识点讲解 本文主要讲解主谓一致,并列结构作主语时谓语用复数主谓一致中的靠近原则谓语动词与前面的主语一致 等常见考点。 主谓一致是指: 1)语法形式上要一致,即单复数形式与谓语要一致。 2)意义上要一致,即主语意义上的单复数要与谓语的单复数形式一致。 3)就近原则,即谓语动词的单复形式取决于最靠近它的词语, 一般来说,不可数名词用动词单数,可数名词复数用动词复数。例如: There is much water in the thermos. 但当不可数名词前有表示数量的复数名词时,谓语动词用复数形式。例如: Ten thousand tons of coal were produced last year. 并列结构作主语时谓语用复数,例如: Reading and writing are very important. 读写很重要。 注意:当主语由and连结时,如果它表示一个单一的概念,即指同一人或同一物时,谓语动词用单数,and 此时连接的两个词前只有一个冠词。例如: The iron and steel industry is very important to our life. 钢铁工业对我们的生活有重要意义。 典型例题 The League secretary and monitor ___ asked to make a speech at the meeting. A. is B. was C. are D. were 答案B. 注:先从时态上考虑。这是过去发生的事情应用过去时,先排除A.,C。本题易误选D,因为The League secretary and monitor 好象是两个人,但仔细辨别,monitor 前没有the,在英语中,当一人兼数职时只在第一个职务前加定冠词。后面的职务用and 相连。这样本题主语为一个人,所以应选B。

表语从句用法详解

表语从句用法详解(例句丰富) 一、表语从句的引导词 引导表语从句的词有连词that, whether,连接代词和连接副词,关系代词型what,以及as if, as though, because等连词。 1. 由that引导 The fact is that he doesn’t really try. 事实是他没有做真正的努力。 The trouble is that I have lost his address. 麻烦的是我把他的地址丢了。 My suggestion is that we should tell him. 我的建议是我们应该告诉他。 His sole requirement was (is) that the system work. 他唯一的要求是这个制度能起作用。 My idea is that we should start making preparations right now. 我的意见是我们马上就开始做准备工作。 2. 由whether引导 The question is whether the film is worth seeing. 问题是这部电影是否值得看。 【注意】whether 可引导表语从句,但与之同义的if却通常不用于引导表语从句。 3. 由连接代词引导 You are not who I thought you were. 你已不是我过去所想像的人。 The problem is who we can get to replace her. 问题是我们能找到谁去替换她呢。 The question is who (m) we should trust. 问题是我们应当相信谁。 What I want to know is which road we should take. 我想知道的是我们应走哪条路。 4. 由连接副词引导 The problem is how we can find him. 问题是我们如何找到他。 That was when I was fifteen. 这是我15岁时发生的事。 That’s where I first met her. 那就是我第一次遇见她的地方。 That’s why he didn’t come. 这就是他没有来的缘故。 That’s why I object to the plan. 这就是我反对这个计划的原因。 That’s where you are wrong. 这就是你不对的地方。

初中英语数词用法总结

英语 ------ 数词 ▲掌握分数、时间、日期的表达法。 【复习要点 (一)基数词 基数词用来表示数目,或者说表示数量的词叫基数词。最基本的基数词如下表所示。 1 one11 eleven100 a hundred 2 two12 twelve20 twenty1000 a thousand 3 three13 thirteen30 thirty1, 000, 000 a million 4 four14 fourteen40 forty10, 000,000 ten million 5 five15 fifteen50 fifty100, 000,000 a hundred million 6 six16 sixteen60 sixty1, 000, 000, 000 a billion 7 seven17 seventeen70 seventy 8 eight18 eighteen80 eighty 9 nine19 nineteen90 ninety 10 ten 说明: 1. 13— 19 是由个位数加后缀-teen 构成。注意其中13、 15 的拼写是 thirteen 和 fifteen 。2. 20— 90 由个位数加后缀-ty 构成,注意其中20— 50 的拼写分别是twenty, thirty, forty 和fifty;80 的拼写是eighty 。 3 .其它非整十的两位数21— 99是由整十位数加连字符“-”,再加个位数构成。如:81 eighty-one 。 4.101— 999 的基数词先写百位数,后加and 再写十位数和个位数。如:691 six hundred and ninety-one 。 5. 1000 以上的基数词先写千位数,后写百位数,再加and,最后写十位数和个位数。 如:5893 five thousand eight hundred and ninety-three 。在基数词中只有表示“百”、“千”的单位词,没有单独表示“万”、“亿”的单位词,而是用thousand(千)和 million (百万)来 表达,其换算关系为: 1 万 =10 thousand;1 亿 =100 million; 10亿=a thousand million=a billion。6.多位数的读法: 1) 1000 以上的多位数,要使用计数间隔或逗号“,”。即从个位起,每隔三位加一个间 隔或逗号。第一个间隔或逗号前是thousand(千),第二个间隔或逗号前是million (百万),第三个间隔或逗号前是 a thousand million 或 a billion( 十亿 )。 2)每隔三位分段以后就都成了101— 999。读的时候十位数(或个位数)的前面一般要 加 and。如: 888, 000,000 读作: eight hundred and eighty-eight million 。 基数词的用法: 1.基数词在句中的作用 基数词的作用相当于名词和形容词,在句中可作定语、主语、宾语(介宾)、表语、同

(完整版)主谓一致详解超详细

1、形式一致 主语是复数,谓语动词用复数形式 主语是单数,谓语动词用单数形式 2、语意一致 谓语动词用单数的清况 1)当名词词组中心词为表示金钱、时间、度量、距离、价格等复数名词时,把这些复数名词看作一个整体。谓语动词采用单数形式。 Twenty-five dollars is too much to pay for that shirt. Fifty minutes isn’t enough to finish this test. Ten miles seems like a long walk to me. 2 以“-s”结尾的书刊名、国名、组织名、游戏名、运动名,谓语动词用单数 以-ics结尾的名词指一门学科时,常用单数谓语动词形式。当这些名词表示实际内容时,谓语动词则用复数形式。 这类单词有:economics经济学electronics电子学 physics物理学politics政治学 mathematics数学statistics统计学 Roots was a novel about a slave family. His politics were a matter of great concern to his friend. Politics is his favorite subject. Statistics show that approximately 40 percent of all marriages in the US end in divorce. Statistics is a subject that is difficult to learn. 3) 有些表示某类别的总称的集合名词,如:machinery(机械),clothing(衣服),luggage(行李),furniture(家具),equipment(设备),jewelry(珠宝)等作主语时,谓语动词常用单数。如:My luggage was sent by air. The equipment of our factory is all imported from Britain. 4) 不定式、现在分词和从句作主语,谓语动词通常用单数: Playing with fire is dangerous. 注意:若用and连接两个动名词、不定式短语或主语从句,表示两个不同的概念,则谓语动词用复数形式。若表示同一概念,则谓语动词用单数形式 Early to rise and early to bed is a good habit. When and where the building will be built hasn’t been decided. 主语从句要根据从句表达的意思而定 What she said is correct.What he gave me are five English books. 谓语动词用复数的情况 1)由and或both...and...连接两个单数名词作主语时,指的是复数概念,谓语动词用复数形式(不可数名词同样)。如: Fire and water do not agree. 注意如果and连接的两个词是指同一个人、同一事物或同一概念,则两个名词共用一个冠词,谓语动词必须用单数。

相关主题
文本预览
相关文档 最新文档