码迷,mamicode.com
首页 >  
搜索关键字:提升cin cout    ( 7220个结果
C++程序题
1.判断是否是闰年(多行输入)分析:是闰年的条件:year%4==0 && year%100 !=0 或者 year%400==0#include using namespace std;int main(){ int year; bool isLeapYear; cout>yea...
分类:编程语言   时间:2014-09-28 17:55:13    阅读次数:169
C++类构造优化 - 不调用拷贝构造函数
假如有下面这样一个类: class A{ public: A(int p, char q):x(p), c(q){ cout << "constructor called" << endl; } A(const A& a){x = a.x; c = a.c; cout << "copy constructor called" << endl;} ~A(){cout << "destruc...
分类:编程语言   时间:2014-09-28 02:30:00    阅读次数:160
关于数组地址的一道题
#includeusing namespace std;int main(){char a[2]={7,3};char *p0=NULL,*p1=NULL;p0=&a[0];p1=&a[1];cout<<p0<<endl; cout<<p1<<endl;cout<<p0-p1<<endl;cout<...
分类:其他好文   时间:2014-09-28 01:11:00    阅读次数:200
对象个数以及构造函数次序
当创建派生类对象时,构造函数的执行次序是 基类构造函数 对象成员构造函数 派生类构造函数,不信看代码#include using namespace std;class A{public: A() { cout<<"A"<<endl; }};class C{public:C...
分类:其他好文   时间:2014-09-27 23:45:10    阅读次数:226
范磊 C++ 第3章 初步了解函数
1 //范磊C++ 第3章 2 3 #include "stdafx.h" 4 #include "iostream" 5 6 //3.1 一个简单的函数 7 void show() 8 { 9 std :: cout > a; 33 cin >> b; 34...
分类:编程语言   时间:2014-09-27 20:20:00    阅读次数:224
字符串翻转
将字符串翻转,如下: 输入:Hi Welcome to cricode 输出:cricode to Welcome Hi #include #include #include using std::cout; using std::endl; using std::string; using std::stack; void main() { string...
分类:其他好文   时间:2014-09-27 13:09:29    阅读次数:175
hdu 5014 Number Sequence
为了a异或b的和最大,只需另b在不大于n的情况下按位取反即可。这里有两个输出小技巧可以参考:1.在用printf输出__int64时,在windows下使用格式"%I64d",在linux下使用"%lld",在hdu中应使用"%I64d",如果拿不准就是用cout好了。2.在遇到每个数之间有空格,最...
分类:其他好文   时间:2014-09-27 12:20:39    阅读次数:178
while(cin>>word)循环的退出方法
C++Primer中的一行代码: string word; while(cin>>word) cout<<word<<endl; return 0; 强制退出while循环的方法:按F6,然后回车。...
分类:其他好文   时间:2014-09-27 02:27:09    阅读次数:243
C++中的友元函数和友元类
#include using namespace std; class myClass1 { public :   myClass1():n(0){};   void setn(int tmpn){this->n=tmpn;}   void show(){cout private:     //友元类     friend class myClass2; ...
分类:编程语言   时间:2014-09-26 06:29:38    阅读次数:208
Utopian Tree
UtopianTree#include<iostream> usingnamespacestd; intheight(intn){ if(n==0) return1; else { if(n%2==0) returnheight(n-1)+1; else returnheight(n-1)*2; } return0; } intmain(){ intT; cin>>T; while(T--){ intn; cin>>n; cout<<height(n)&l..
分类:其他好文   时间:2014-09-26 00:40:08    阅读次数:188
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!