C++ 記錄1

 using namespace std:cout
 using namespace std

#include <string>
using std::string

 string s1;
 string s2(s1);
 string s3("value");
 string s4(n,'c');

 getline(cin,line_string);


s.empty()
s.size()
s[n];
s1+s2
s1=s2
v1==v2
!= < > <= >=

string::size_type

isalnum(c)

True if c is a letter or a digit.

如果 c 是字母或數字,則爲 True。

isalpha(c)

true if c is a letter.

如果 c 是字母,則爲 true。

iscntrl(c)

true if c is a control character.

如果 c 是控制字符,則爲 true

isdigit(c)

true if c is a digit.

如果 c 是數字,則爲 true。

isgraph(c)

true if c is not a space but is printable.

如果 c 不是空格,但可打印,則爲 true。

islower(c)

true if c is a lowercase letter.

如果 c 是小寫字母,則爲 true。

isprint(c)

True if c is a printable character.

如果 c 是可打印的字符,則爲 true。

ispunct(c)

True if c is a punctuation character.

如果 c 是標點符號,則 true。

isspace(c)

true if c is whitespace.

如果 c 是空白字符,則爲 true。

isupper(c)

True if c is an uppercase letter.

如果 c 是大寫字母,則 true。

isxdigit(c)

true if c is a hexadecimal digit.

如果是 c 十六進制數,則爲 true。

tolower(c)

If c is an uppercase letter, returns its lowercase equivalent; otherwise returns c unchanged.

如果 c 大寫字母,返回其小寫字母形式,否則直接返回 c。

toupper(c)

If c is a lowercase letter, returns its uppercase equivalent; otherwise returns c unchanged.

如果 c 是小寫字母,則返回其大寫字母形式,否則直接返回 c。

#include <vector>
using std::vector ;

vector<T>  v1;
vector<T>  v2(v1);
vector<T> v3(n,i);
vector<T> v4(n);

v.empty();
v.size();
v.push_back();
v[n];
v1= v2
v1 == v2
!= < <= > >=
vector<T>::size_type   //type for count

iterators
vector<int>::iterator iter=ivec.begin();

for (vector<int>::iterator iter = ivec.begin();
                                iter != ivec.end(); ++iter)
         *iter = 0;  // set element to which iter refers to 0
 for (vector<string>::const_iterator iter = text.begin();
                                   iter != text.end(); ++iter)
         cout << *iter << endl; // print each element in text


bitset
#include <bitset>

bitset <n> b;
bitset<n> b(u);
bitset<n> b(s);
bitset<n> b(s,pos,n)

b.any()

Is any bit in b on?

b 中是否存在置爲 1 的二進制位?

b.none()

Are no bits in b on?

b.count()

Number of bits in b that are on

b 中不存在置爲 1 的二進制位嗎?

b.size()

Number of bits in b

b 中置爲 1 的二進制位的個數

b[pos]

Access bit in b at position pos

訪問 b 中在 pos 處二進制位

b.test(pos)

Is bit in b in position pos on?

b 中在 pos 處的二進制位置爲 1

b.set()

Turn on all bits in b

b.set(pos)

Turn on the bit in b at position pos

把 b 中在 pos 處的二進制位置爲 1

b.reset()

Turn off all bits in b

把 b 中所有二進制位都置爲 0

b.reset(pos)

Turn off the bit in b at position pos

把 b 中在 pos 處的二進制位置爲 0

b.flip()

Change the state of each bit in b

把 b 中所有二進制位逐位取反

b.flip(pos)

Reverse value of the bit in b in position pos

把 b 中在 pos 處的二進制位取反

b.to_ulong()

Returns an unsigned long with the same bits as in b

用 b 中同樣的二進制位返回一個 unsigned long 值

os << b

Prints the bits in b to the stream os

把 b 中的位集輸出到 os 流

iostream fstream sstream

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章