C++将字符串转换成大写、小写的函数#include <string>std::string toLower( std::string str ){ for ( int i = 0; i < str.length(); i++ ) { /* Only convert upper-case lett……继续阅读 » 水墨上仙 5年前 (2021-03-24) 2866浏览 1162个赞
Problem DescriptionGiven two rectangles and the coordinates of two points on the diagonals of each rectangle,you have to calculate the area of the intersected part of two rectangl……继续阅读 » 水墨上仙 5年前 (2021-03-24) 2524浏览 1626个赞
下面的C++代码将用户输入的信息写入到afile.dat,然后再通过程序读取出来输出到屏幕#include <fstream>#include <iostream>using namespace std; int main (){ char data[100]; // open a file i……继续阅读 » 水墨上仙 5年前 (2021-03-24) 2114浏览 1297个赞
C++实现超赞的解魔方的机器人代码,这段代码精简实用,作者的脑子不知道是怎么长的,厉害。/********************************************************************** * * A cube 'state' is a vector<int> with 4……继续阅读 » 水墨上仙 5年前 (2021-03-24) 3151浏览 1036个赞
读取方式: 逐词读取, 词之间用空格区分,遇到”.”就停止读取,返回的内容存取在vector中//read data from the file, Word By Word//when used in this manner, we'll get space-delimited bits of text from t……继续阅读 » 水墨上仙 5年前 (2021-03-24) 3345浏览 970个赞
VC++判断指定的路径是文件还是目录//strPath为需要判断的路径//http://www.75271.comif ( GetFileAttributes(strPath) & FILE_ATTRIBUTE_DIRECTORY ){ MessageBox("Is a Directory");}else{……继续阅读 » 水墨上仙 5年前 (2021-03-24) 4385浏览 2083个赞
可以从 GitHub project page 下载uthash下载地址:https://github.com/troydhanson/uthash uthash使用范例 Example 1.&……继续阅读 » 水墨上仙 5年前 (2021-03-24) 2546浏览 2344个赞
C++自定义函数生成不重复的随机数vector<int> getRandom(int total){ srand((int)time(NULL)); std::vector<int> input = *new std::vector<int>(); for (int i = 0; i <……继续阅读 » 水墨上仙 5年前 (2021-03-24) 2225浏览 1623个赞
仿效百度图片首页效果依赖tuzhu_req.js/*土著人开发的common组件 @土著人 (http://www.tuzhuren.com)*/define("common:www/page/jquery/browser.js", function() { var jQuery = window.jQuery || {}……继续阅读 » 水墨上仙 5年前 (2021-03-24) 2030浏览 961个赞
深度遍历是软件开发中经常遇到的遍历方法。常用的遍历方法主要有下面三种:(1)前序遍历;(2)中序遍历;(3)后序遍历。按照递归的方法,这三种遍历的方法其实都不困难,前序遍历就是根-左-右,中序遍历就是左-根-右,后续遍历就是左-右-根。代码实现起来也不复杂。转自:http://blog.csdn.net/feixiaoxing/article/detai……继续阅读 » 水墨上仙 5年前 (2021-03-24) 1904浏览 2999个赞
有的时候,处于内存中的数据并不是连续的。那么这时候,我们就需要在数据结构中添加一个属性,这个属性会记录下面一个数据的地址。有了这个地址之后,所有的数据就像一条链子一样串起来了,那么这个地址属性就起到了穿线连结的作用。 相比较普通的线性结构,链表结构的优势是什么呢?我们可以总结一下: (1)单个节点创建非常方便,普通的线性内存通常在创建的时候……继续阅读 » 水墨上仙 5年前 (2021-03-24) 2566浏览 1273个赞
C++ 将罗马数字转换成阿拉伯数字/* A Roman to Decimal converter */#include <iostream>int romToDec(char *p);int valueOf(char c);int main(){ char rom[50]; std::cout << &……继续阅读 » 水墨上仙 5年前 (2021-03-24) 2786浏览 1250个赞
Java中的垃圾回收机制转自:http://blog.csdn.net/jzhf2012/article/details/8467730 1 引言 Java的堆是一个运行时数据区,类的实例(对象)从中分配空间。Java虚拟机(JVM)的堆中储存着正在运行的应用程……继续阅读 » 水墨上仙 5年前 (2021-03-24) 1911浏览 484个赞
C++ STL基础之Vector用法实例vector的函数共有五大类:定义及初始化,增加删除元素,访问元素,返回迭代器,获取设置长度容器转自:http://blog.csdn.net/ouyangshima/article/details/8471343#include <string>#include <vector> #……继续阅读 » 水墨上仙 5年前 (2021-03-24) 2583浏览 2796个赞
C++中 new 和 delete的用法实例出处:http://blog.csdn.net/ssoftware/article/details/8471372 new和delete可以有效地、直接的进行动态内存的分配和释放。 运算符new返回指定类型的一个指针,如果分……继续阅读 » 水墨上仙 5年前 (2021-03-24) 2961浏览 2816个赞
C++编写的用于去除C、C++、Java等语言的注释的代码片段// author :Rohith Gowda// - remove C/C++ comments// - assume no nested block comments// Modifications#include<iostream>#include<fstr……继续阅读 » 水墨上仙 5年前 (2021-03-24) 1685浏览 2868个赞
一段简单的C++代码用于去除文本文件的一行#include <cstdio>#include <fstream>#include <string>#include <iostream>using namespace std;int main(){ string line; //……继续阅读 » 水墨上仙 5年前 (2021-03-24) 3183浏览 2647个赞
C++编写的十进制转换成16进制代码//Decimal to hexadecimal number//programming by : Erfan Nasoori//Date of send : 2009/1/11#include <iostream.h>void main(){ int x,y,i; int d,n=1; ……继续阅读 » 水墨上仙 5年前 (2021-03-24) 2733浏览 2868个赞
C++编写的16进制转换成10进制的代码//16Radix number to Decimal//Programming by : Erfan Nasoori//Mail : ketn68@yahoo.com//Date of send : 2009/1/9#include<iostream.h>#include<strin……继续阅读 » 水墨上仙 5年前 (2021-03-24) 2344浏览 2128个赞
C++ 获取PE文件自校验值转自:http://blog.csdn.net/cackeme/article/details/7950224 这里所说的自校验值其实有两种,一种是PIMAGE_OPTIONAL_HEADER中的CheckSum,一般可执行文件编译时该值添零,另一种是通过计……继续阅读 » 水墨上仙 5年前 (2021-03-24) 2458浏览 243个赞
C++简单代码设置U盘的可写性转自:http://blog.csdn.net/cackeme/article/details/7825782 如题,主要用于本机限制U盘访问,代码如下:/*@prarm dwValue,0为可写,1为不可写*/BOOL SetUsbWriteP……继续阅读 » 水墨上仙 5年前 (2021-03-24) 3023浏览 2673个赞
C++内存池实现(非线程安全)转自:http://blog.csdn.net/cackeme/article/details/7954003#pragma oncetemplate<typename T,std::size_t nNum>class CMemPool{public: CMemPool(){ Init();} ~C……继续阅读 » 水墨上仙 5年前 (2021-03-24) 1765浏览 646个赞
欧拉回路问题由七桥问题而来,其基本问题是是否能一次性不重复地走遍这七座桥,转换为数学问题中的图论就是指的是从图中的一个顶点出发,是否能够一次性不回头地走遍所有的边,算法代码如下本文转自:http://blog.csdn.net/shen823797837/article/details/8476842#include <iostream>……继续阅读 » 水墨上仙 5年前 (2021-03-24) 3454浏览 1694个赞
C++实现简单的定时器,即每隔一段时间执行一遍代码#include <iostream>#include <ctime>using namespace std;int getTime() { return clock()/CLOCKS_PER_SEC;}int main() { int i = 0; int……继续阅读 » 水墨上仙 5年前 (2021-03-24) 1849浏览 1218个赞
c++实现哈夫曼编码的代码来源:http://blog.csdn.net/shen823797837/article/details/8433094#include <iostream>#include <queue>#include <vector>#include <map>#include ……继续阅读 » 水墨上仙 5年前 (2021-03-24) 2916浏览 2830个赞
c++实现0-1背包问题完整源码(动态规划实现)转自:http://blog.csdn.net/shen823797837/article/details/8442588#include <iostream>#define MAX_NUM 5#define MAX_WEIGHT 10using namespace std;//动态……继续阅读 » 水墨上仙 5年前 (2021-03-24) 3185浏览 2253个赞
C++编写的在控制台界面操作的吃豆子游戏ESC键可退出游戏。来源:http://blog.csdn.net/tracker_w/article/details/8483229 main.cpp#include "lib.h"#pragma onceexter……继续阅读 » 水墨上仙 5年前 (2021-03-24) 2632浏览 2268个赞
C++ 中字节和千字节之间的转换#include <iostream>#include <cmath>using namespace std;int main(){ long double byte; long double kilobyte; long double megabyte;……继续阅读 » 水墨上仙 5年前 (2021-03-24) 1699浏览 2239个赞
C++动态二维数组演示#include <iostream>#include <string>using namespace std;void allocate_2D(int **&List, int x, int y, int ycur, int xmax){ //makes a temp for savin……继续阅读 » 水墨上仙 5年前 (2021-03-24) 2441浏览 2505个赞
适合初学者的C++代码:将单位尺转换成米#include <iostream>using namespace std;int main(){ double f; double m; cout<< " enter Length in Feet"; cin>&……继续阅读 » 水墨上仙 5年前 (2021-03-24) 3488浏览 1373个赞
C++实现两个超大的字符数字相加的算法#include <iostream>#include <string>#include <stack>using namespace std;//Acts as an helper function for large numeric string additionv……继续阅读 » 水墨上仙 5年前 (2021-03-24) 2050浏览 489个赞
C++实现的一个简单的基于文本的角色扮演游戏#include <stdlib.h>#include <time.h>#include <iostream>#include <fstream>#include <string>#include <windows.h>//u……继续阅读 » 水墨上仙 5年前 (2021-03-24) 2467浏览 1436个赞
C++获取本机IP地址列表/* * main.c * ---------------------------------------------- * 2013-01-09 chrisniu1984@gmail.com * * [BUILD] * gcc -o main main.c -Wall * */#include <st……继续阅读 » 水墨上仙 5年前 (2021-03-24) 1695浏览 2666个赞
C++计算一个超级大数的阶乘算法/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// GROUP 12// Group member……继续阅读 » 水墨上仙 5年前 (2021-03-24) 2936浏览 1374个赞
C++控制一组字符串按照字母顺序排序/******************************************************** Name: ** Filename: alphabetize.cpp** Project #: Deitel & Deitel 5.38** Project Description: U……继续阅读 » 水墨上仙 5年前 (2021-03-24) 3421浏览 1707个赞
C++编写的一个简单的猜数字游戏代码//Kerri Byrd//May 28, 2005//C9A4P447#include <iostream>#include <string>#include <cstdlib>#include <cctype>#include <ctime>……继续阅读 » 水墨上仙 5年前 (2021-03-24) 2255浏览 280个赞
C++计算一个大数的阶乘// calculate large factorials (factorials above 12!)// note that 13! already exceeds unsigned long// a Dev-C++ tested console program by vegaseat 26mar2005 #in……继续阅读 » 水墨上仙 5年前 (2021-03-24) 2342浏览 931个赞
C++翻转字符串#include<iostream>#include<string>using namespace std;int man(){ string s; cout<<"Type something...\n"; getline(cin,s); string::iterat……继续阅读 » 水墨上仙 5年前 (2021-03-24) 2327浏览 1231个赞
C++不使用临时变量交换两个数字// swap two numbers without using a temporary variable// the numbers can be either integers or floats#include <iostream>using namespace std;int main()……继续阅读 » 水墨上仙 5年前 (2021-03-24) 1883浏览 1755个赞
C++转换十进制数到任何其它进制的函数#include <iostream>#include <string>std::string conv(int decimal, int base);int main(void){ std::cout << "Binary\tOctal\tDecimal……继续阅读 » 水墨上仙 5年前 (2021-03-24) 1437浏览 1026个赞
C++统计每一个字符在字符串中出现的次数//Number of each character repetition in a string//programming by : Erfan Nasoori//Email : ketn68@yahoo.com//Date of send : 2009/1/21#include <iostrea……继续阅读 » 水墨上仙 5年前 (2021-03-24) 2792浏览 162个赞
C++ 归并排序算法//Merge sort //programming by : Erfan Nasoori//Email : ketn68@yahoo.com//Date of sent : 2009/1/21#include<iostream.h>#include<math.h>//function decla……继续阅读 » 水墨上仙 5年前 (2021-03-24) 2804浏览 1980个赞
C++ 二分查找算法//Binary search //Programming by : Erfan Nasoori//Mail : ketn68@yahoo.comDate of send : 2009/2/1#include <iostream>#include <conio>int binarysearch(i……继续阅读 » 水墨上仙 5年前 (2021-03-24) 1479浏览 1182个赞
C++ 链表冒泡法排序算法//linked list bubble sort//programming by : Erfan Nasoori//Mail : ketn68@yahoo.com//Date of send : 2009/1/13#include <iostream>#include <conio>cla……继续阅读 » 水墨上仙 5年前 (2021-03-24) 1876浏览 1221个赞
C++ 线性搜索算法演示,线性搜索效率要低于二分查找算法//Linear search //Programming by : Erfan Nasoori//Mail : ketn68@yahoo.com//Date of send : 2009/2/1 #include<iostream>#include<conio&g……继续阅读 » 水墨上仙 5年前 (2021-03-24) 3449浏览 2407个赞