码迷,mamicode.com
首页 >  
搜索关键字:c const    ( 26295个结果
POJ 2478 Farey Sequence 筛选法求欧拉函数
题目来源:POJ 2478 Farey Sequence 题意:输入n 求 phi(2)+phi(3)+phi(4)+...+phi(n) 思路:用类似筛法的方式计算phi(1), phi(2), ..., phi(n) 再求前缀和 #include #include #include //欧拉phi函数 const int maxn = 1000010; typedef long...
分类:其他好文   时间:2014-05-14 01:05:22    阅读次数:323
字符串/数字之间类型转换总结
1、char向int转换 方法一:(适用于单个字符) char ch = '6'; int num = ch - '0';   //此时num=6 方法二:(适用于字符串) 函数atoi: int atoi ( const char * str ); 参数是一个char类型的数组,不能是单个char变量 char str[10] = "32352"; int num = atoi(...
分类:其他好文   时间:2014-05-13 06:55:14    阅读次数:362
关联容器 — hash_set
容器hash_set是以hash table为底层机制的,几乎所有的操作都是转调用hash table提供的接口。由于插入无法存储相同的键值,所以hash_set的插入操作全部都使用hash table的insert_unique接口,代码如下: pair insert(const value_type& obj) { pair p = rep.insert_unique(obj); ...
分类:其他好文   时间:2014-05-13 06:33:44    阅读次数:303
POJ 1006 Biorhythms 中国剩余定理
题目来源:POJ 1006 Biorhythms 题意:给出3个周期第一次发生的时间 和 当前开始的天数 求三个周期下一次到达高峰期发生在哪一天 思路:这题很水 试一下我的模版而已 #include #include using namespace std; typedef long long LL; const int maxn = 10; int a[maxn], m[maxn]; ...
分类:其他好文   时间:2014-05-13 05:07:28    阅读次数:253
排序算法——直接插入排序
直接插入排序是一种实现较为简单的排序算法。基本的思想是,从数组的第二个元素起,每次选取一个元素,与前面已经排序数组的元素比较,找到该元素的合适位置。不多说,直接上代码。#include #include #include using namespace std;const int arrSize =...
分类:其他好文   时间:2014-05-12 20:59:47    阅读次数:295
Delphi Inputbox 输入时显示‘*’
unit Unit1;interfaceusesWindows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,Dialogs, StdCtrls;const InputboxMessage = WM_USER + ...
分类:其他好文   时间:2014-05-12 19:20:32    阅读次数:314
clang 简单的str_replace实现
自己写的一段://goolchar* str_replace(char* source, const char* find, const char* replace){ if (source == NULL || find == NULL || find == "") return strdup.....
分类:其他好文   时间:2014-05-12 02:42:20    阅读次数:418
一个自己实现的string
最近实现了一个string类,添加了一些c++11元素。除了基本的构造析构函数,拷贝构造和赋值函数,另外添加移动拷贝和赋值函数。default是一个很方便的特性有木有。 //default constructorKianString()=default;KianString(const char *...
分类:其他好文   时间:2014-05-12 01:14:09    阅读次数:347
关于C++ const成员的一些细节
1.const对象,只能调用const成员函数2.非const对象可以调用const成员函数和非const成员函数 a.如果类同时具有const重载版本的成员函数和非重载版本,那么该类实例化的非const对象调用该成员函数的时候,会调用非重载版本。 b.如果类只有const版本的成员,那么实例化.....
分类:编程语言   时间:2014-05-11 15:23:04    阅读次数:258
常见的文件和目录函数
在APUE这本书,第三章与第四章都是在讲一些关于文件操作和目录操作的函数。简单地说明一下涉及到的函数及其使用。   open函数 原型为: #include   int open(const char *pathname, int oflag,.../*mode_t mode*/);        该函数是用来打开或创建一个文件(记住:是文件,不包括目录),第三个参数只有当打开文件不存在时...
分类:其他好文   时间:2014-05-11 04:46:16    阅读次数:336
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!