1 #include 2 3 #include 4 #include 5 #include 6 7 using std::vector; 8 using std::string; 9 using std::cout;10 using std::endl;11 12 template13...
分类:
其他好文 时间:
2014-09-12 23:28:34
阅读次数:
203
Problem 1:vector coll = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };vector::const_iterator pos = find (coll.cbegin(), coll.cend(),5);cout ::const_reverse_iterator r...
分类:
其他好文 时间:
2014-09-11 18:56:12
阅读次数:
226
templatevoid f(char (&arr)[N]){ std::cout << sizeof(arr) << '\n';}此时数组不会退化为指针(C++11 section 8.3.5.5)
分类:
编程语言 时间:
2014-09-11 16:40:42
阅读次数:
224
Decode-译码//Decode-译码
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cctype>
usingnamespacestd;
voidprocess(stringstr,charch[],intkey);
intmain()
{
stringstr;
charch[100];
cout<<"Inputthecipher:\n";
cin&..
分类:
其他好文 时间:
2014-09-11 15:33:04
阅读次数:
376
#include #include using namespace std;int main(){ cout << sizeof(long) << endl;//4 cout << sizeof(long long) << endl;//8 cout << sizeof(__int...
一种改变const值的方式是使用const_cast类型转换符,将const变量转换为一个该变量的引用,通过这个引用去改变值,这种方法的实质就是用地址改变内存的值。如下实例:
struct SA {
int i = 0;
};
const SA sa;
cout
SA &sb =...
分类:
其他好文 时间:
2014-09-10 10:53:30
阅读次数:
264
按位异或运算可以在不引入临时变量的情况下实现两个变量值得互换。intmain()
{
inta=10;
intb=12;
cout<<"a="<<a<<";"<<"b="<<b<<endl;
a=a^b;//异或运算
b=a^b;
a=b^a;
cout<<"a="<<a<<";"<<"b="<<b<..
分类:
其他好文 时间:
2014-09-10 02:56:41
阅读次数:
186
#include
#include
#include
using namespace std;
void print(int n)
{
for(int i=0;(1<<i)<=n;i++)
if(n&(1<<i))
cout<<1;
else cout<<0;
cout<<endl;
}
int main()
{
i...
分类:
其他好文 时间:
2014-09-09 16:03:59
阅读次数:
220
要用到这个头文件: setw(x) : 表示控制输出x的位宽 setprecision(x) :表示 控制输出小数点后 x 位 cout.precision(x): 表示控制输出的 该数值的5个数字 例如:y=1.0456789 cout.precision(3); cout#include us....
分类:
编程语言 时间:
2014-09-09 15:01:28
阅读次数:
213
cout>键盘输入例子:double r=1.0;cin>>r; //键盘输入
分类:
编程语言 时间:
2014-09-09 12:24:18
阅读次数:
164