码迷,mamicode.com
首页 >  
搜索关键字:iostream    ( 13291个结果
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
The Love-Letter Mystery
TheLove-LetterMystery#include<cmath> #include<cstdio> #include<vector> #include<iostream> #include<algorithm> #include<string> usingnamespacestd; intmain(){ intT; cin>>T; stringstr; getline(cin,str); while(T--) {..
分类:其他好文   时间:2014-09-26 00:39:28    阅读次数:253
Seeking in iostreams
Each type of iostream has a concept of where its “next” character will come from (if it’s an istream) or go (if it’s an ostream). In some situations y...
分类:移动开发   时间:2014-09-24 15:17:16    阅读次数:226
将iostream中的数据全部导入到另一个iostream对象中
每一个iosteram对象都有一个streambuf对象,streambuf对象有一些成员函数。 rdbuf()函数返回了iostream对象的streambuf指针,具体示例如下: #include "../require.h" #include #include using namespace ...
分类:移动开发   时间:2014-09-24 14:06:06    阅读次数:174
String类
// StringClass.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include "iostream" #include "string" using namespace std; class CMyString { public: CMyString(char * pData = "denggaoxiang"); CMyString(...
分类:其他好文   时间:2014-09-24 00:12:05    阅读次数:156
hdoj 5038 Grade【众数】
题目:hdoj 5038 Grade 题意:给出一组数,求众数,按升序输出 分析:只考众数的概念,但是一直没有搞清楚 众数:一组数中出现次数最多的数,假如所有数据的出现次数都一样,那么这组数据没有众数。(注意:数组中只有一个数的话众数就是它本身) AC 代码: #include #include #include #include #include #inclu...
分类:其他好文   时间:2014-09-23 10:20:24    阅读次数:213
hdoj 5037 Frog 【万恶的贪心】
题目:hdoj 5037 Frog 题意:一直聪明的青蛙,每次能条 l 的长度,河宽为m,喝中心有一些陆地,它会选择尽量少的次数跳,现在上帝可以任意往喝里面放陆地(视为点),让青蛙跳的次数最多,求最大次数? 分析:1:首先如果加入大于(l+1)的距离,那么上帝会给他分成(l+1)的段,因为我给他(l+1),它一下子跳不过去,必然中间还要一个点,让青蛙跳,这样肯定步数最大。(贪心...
分类:其他好文   时间:2014-09-22 19:26:53    阅读次数:171
二叉树的建立,非递归前序、中序、后续遍历
算法网上很多,这里只是我手写的可执行的代码,备份用。#include<iostream> #include<vector> #include<queue> usingnamespacestd; structnode{ charelement; structnode*left; structnode*right; //structnode*parent; node(chara){ element=a; }..
分类:其他好文   时间:2014-09-22 12:28:43    阅读次数:229
01背包问题实现源码
经典问题,物品个数为n,背包重量为v,则时间复杂度为O(nv)。空间复杂度为O(v)。不过如果要得到选择的最终结果,则需要把中间结果都记录下来,空间复杂度只能也用O(nv)。#include<iostream> usingnamespacestd; intmax(inta,intb){ returna>=b?a:b; } intbag_use_o..
分类:其他好文   时间:2014-09-21 03:08:30    阅读次数:268
查找两个有序序数组(一个递增、一个递减)中第K大的数
题目不难,关键是边界条件要想清楚。先写一个时间复杂度为O(K)的解法。#include<iostream> usingnamespacestd; //a[]increase //b[]decrease //useret_valuetoreturntheresult //functionretreprsenttheerrorifnot0 intfind_k(inta[],intb[],intm,intn,intk,int&ret..
分类:其他好文   时间:2014-09-20 19:54:10    阅读次数:250
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!