#include
using namespace std;
int main()
{
double sum=0;
for(int i=0;i<6;++i)
{
if(i%2==0)
sum+=1;
else
{
sum=sum/2;
}
}
cout<<sum<<endl;
system("pause");
return 0;...
分类:
编程语言 时间:
2014-11-10 21:57:14
阅读次数:
273
#include
using namespace std;
int main()
{
int a,b,c;
cout<<"请输入三个数"<>a>>b>>c;
if(a>b)
{
if(a>c)
{
if(b>c)
{
cout<<"三个数的从小到大的排序为"<<endl;
cout<<a<<" "<<b<<" "<<c<<endl...
分类:
编程语言 时间:
2014-11-10 21:55:06
阅读次数:
413
1 #include "../../st.h" 2 3 int main() 4 { 5 vector nums; 6 double t; 7 int n; 8 cout>n;10 cin>>t;11 nums.push_back(t);12 ...
分类:
编程语言 时间:
2014-11-10 21:41:57
阅读次数:
295
1 #include 2 using namespace std; 3 4 int main() 5 { 6 int a=1,b=100; 7 int f=1; 8 char c=0; 9 10 while(f=1)11 {12 cout...
分类:
编程语言 时间:
2014-11-10 21:21:53
阅读次数:
285
C++字符串常用操作
1、string的可以用相加来连接两个字符串。
#include
#include
using namespace std;
int main()
{
string str;
str += "hello ";
str += "world !";
cout << str << endl;
return 0;
}
...
分类:
编程语言 时间:
2014-11-09 18:08:44
阅读次数:
223
C++友元类:
正常情况下,一个类是访问不到另一个类的私有成员的。就像下面这个:
#include
class A{
private:
int a;
public:
A(){
a = 1;
}
};
class B:public A{
public:
B(){
std::cout << a << ...
分类:
编程语言 时间:
2014-11-09 16:43:03
阅读次数:
229
今天看堆栈有关的算法时突然又想到了局部变量的压栈问题,在局部函数里面先定义的变量先压栈,按照所所需的大小分配内存,先压栈的变量地址会大些,这个不知是否跟编译器的实现有关,问题来了 int n = 1; int m = 2; int k = 3; int *p = &k; cout<<&n<<endl...
分类:
其他好文 时间:
2014-11-09 12:29:51
阅读次数:
142
测试一下 上次的测试很不爽 测试两下 再试一下 这个短路 void client(io_service &ios, deadline_timer &timer, const system::error_code &ec)
{ try{ cout str(100, 0); _sock...
分类:
其他好文 时间:
2014-11-09 12:27:47
阅读次数:
144
1.测试标题测试标题效果2.测试代码测试代码效果void client(io_service &ios, deadline_timer &timer, const system::error_code &ec){ try{ cout str(100, 0); _s...
分类:
其他好文 时间:
2014-11-09 12:26:40
阅读次数:
114
最近看了>, 设计到C++的指针,异常处理等方方面面,其中有些自认为非常不错的代码,在工作中非常值得借鉴。
1.指向成员函数的指针
A
#include
using namespace std;
class C
{
public:
void f(){ cout<<"C::f\n";}
void g(){cout<<"C::g\n";}
};
int main...
分类:
编程语言 时间:
2014-11-09 06:20:13
阅读次数:
253