C++ 记录1

来源:互联网 发布:ML算法CSDN博客 编辑:程序博客网 时间:2024/06/01 10:44
 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

原创粉丝点击