2012年12月15日

error: no matching function for call to 'std::basic_ifstream<char>::open(std::string&)

摘要: string filename = "1.txt"; ifstream fin; fin.open(filename); 上述语句会产生如下错误:error: no matching function for call to 'std::basic_ifstream<char>::open(std::string&)原因是C++的string类无法作为open的参数。解决方案:使用C的字符串。例: char filename[10]; strcpy(filename, "1.txt"); ifstream fin; fin.o 阅读全文

posted @ 2012-12-15 23:23 铁树银花 阅读(5583) 评论(0) 推荐(0) 编辑

2012年12月8日

C++ istream::peek()

摘要: 功能:peek函数用于读取并返回下一个字符,但并不提取该字符到输入流中,也就是说,依然让该字符作为将要提取到输入流的下一个字符。例程:#include <iostream> #include <string> using namespace std; int main() { string word; char c; int n; cout << "Please enter a word or a number: "; c = cin.peek(); if(isdigit(c)) { cin >> n; ... 阅读全文

posted @ 2012-12-08 09:38 铁树银花 阅读(988) 评论(0) 推荐(0) 编辑

C/C++文件之eof()

摘要: C/C++文件之eof()版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明http://tuhao.blogbus.com/logs/21306687.html在使用C/C++读文件的时候,一定都使用过eof()这个函数来判断文件是否为空或者是否读到文件结尾了,也会在使用这个函数的过程中遇到一些问题,如不能准确的判断是否为空或者是否到了文件尾,以至于有些人可能还会怀疑这个函数是不是本身在设计上就有问题。先来看看如下这段代码:#include <iostream> #include <fstream> using namespace std; int ma 阅读全文

posted @ 2012-12-08 09:18 铁树银花 阅读(400) 评论(0) 推荐(0) 编辑

2012年12月5日

赋值和拷贝构造函数

摘要: 有程序: 1 #include <iostream> 2 3 using namespace std; 4 5 class ClassA 6 { 7 public: 8 ClassA(int i = 0) {x = i;} 9 ClassA(const ClassA& t)10 {11 x = t.x;12 cout << "调用拷贝构造函数" << endl;13 }14 ClassA& operator = (const ClassA& t)15 ... 阅读全文

posted @ 2012-12-05 23:38 铁树银花 阅读(217) 评论(0) 推荐(0) 编辑

error: macro names must be identifiers

摘要: 遇到的问题:工程中有一个头文件以数字为开头命名,编译结果显示预处理时出错,显示信息为error: macro names must be identifiers。中文大意应该“宏名称必须是标识符”。解决方案:将头文件重命名为字母开头,error消失。猜测:C++和C中命名变量时不能以数字开头,定义宏时也不能。 阅读全文

posted @ 2012-12-05 10:38 铁树银花 阅读(562) 评论(0) 推荐(0) 编辑

2012年12月4日

fopen C++

摘要: fopen<cstdio>FILE * fopen ( const char * filename, const char * mode );Open fileOpens the file whose name is specified in the parameter filename and associates it with a stream that can be identified in future operations by theFILE pointer returned.The operations that are allowed on the stream 阅读全文

posted @ 2012-12-04 18:47 铁树银花 阅读(1237) 评论(0) 推荐(0) 编辑

2012年11月29日

How many people have ipad II(数学)

摘要: How many people have ipad IITime Limit: 3000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 174Accepted Submission(s): 60Problem Descriptionhh found more and more of his friends are having ipad IIs. One day when they get together, hh asked his five friends, " 阅读全文

posted @ 2012-11-29 18:47 铁树银花 阅读(277) 评论(0) 推荐(0) 编辑

2012年11月28日

如何在文件夹中建立网页的快捷方式

摘要: 以在桌面上建立网页快捷方式为例。单击鼠标右键——新建——快捷方式,弹出对话框:复制想要建立快捷方式的网页的网址,粘贴到编辑框,点下一步,之后重命名快捷方式的名称,点完成即可。 阅读全文

posted @ 2012-11-28 11:50 铁树银花 阅读(360) 评论(0) 推荐(0) 编辑

2012年11月24日

Magic Number(dp)

摘要: Magic NumberTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1057Accepted Submission(s): 444Problem DescriptionThere are many magic numbers whose lengths are less than 10. Given some queries, each contains a single number, if the Levenshtein distanc 阅读全文

posted @ 2012-11-24 21:47 铁树银花 阅读(327) 评论(0) 推荐(0) 编辑

Outlets(最小生成树)

摘要: OutletsTimeLimit:2000/1000MS(Java/Others)MemoryLimit:32768/32768K(Java/Others)TotalSubmission(s):351AcceptedSubmission(s):174ProblemDescriptionInChina,foreignbrandcommoditiesareoftenmuchmoreexpensivethanabroad.ThemainreasonisthatweChinesepeopletendtothinkforeignthingsarebetterandwearewillingtopaymuc 阅读全文

posted @ 2012-11-24 10:05 铁树银花 阅读(293) 评论(0) 推荐(0) 编辑

The Power of Xiangqi(水题)

摘要: The Power of XiangqiTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 284Accepted Submission(s): 145Problem DescriptionXiangqi is one of the most popular two-player board games in China. The game represents a battle between two armies with the goal o 阅读全文

posted @ 2012-11-24 10:01 铁树银花 阅读(268) 评论(0) 推荐(0) 编辑

2012年11月21日

如何利用迭代器获取vector的最后一个元素

摘要: 错误观点:通过vector::end()能获取指向最后一个元素的指针。实际上,通过上面的方法获取的是指向末尾元素再下一个位置的指针。例子:#include <iostream> #include <vector> using namespace std; int main() { vector<int> Int; Int.push_back(1); Int.push_back(5); vector<int>::iterator it = Int.end(); cout << *it << endl; return 0; } 阅读全文

posted @ 2012-11-21 20:36 铁树银花 阅读(7624) 评论(0) 推荐(0) 编辑

一个文件读写的简易例子

摘要: 先在储存工程文件的文件夹中新建两个文件:in.txt和out.txt,分别用于存放需要读入的内容和写进的内容。例如在in.txt中输入a 1v 3.2d 0.2q 0w 12f 0.10 0运行程序 1 #include <fstream> 2 using namespace std; 3 4 int main() 5 { 6 ifstream in; //输入流对象 7 ofstream out; //输出流对象 8 char ch; 9 double w;10 in.open("in.txt"); //打开相应文件11 out.o... 阅读全文

posted @ 2012-11-21 10:09 铁树银花 阅读(202) 评论(0) 推荐(0) 编辑

2012年11月20日

Bone Collector(01背包问题入门)

摘要: Bone Collector原题连接:点击打开链接Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 15290Accepted Submission(s): 6055Problem DescriptionMany years ago , in Teddy’s hometown there was a man who was called “Bone Collector”. This man like to collect varies of bo 阅读全文

posted @ 2012-11-20 18:29 铁树银花 阅读(214) 评论(0) 推荐(0) 编辑

Excellent Team(模拟,细节)

摘要: A -Excellent TeamTime Limit:1000MSMemory Limit:65536KB64bit IO Format:%I64d & %I64uSubmitStatusPracticeURAL 1931DescriptionGibbs: Next!First Pirate: My wife ran off with my dog and I'm drunk for a month.Gibbs: Perfect. Next!Second Pirate: Me have one arm and a bum leg.Gibbs: It's the cro 阅读全文

posted @ 2012-11-20 00:25 铁树银花 阅读(389) 评论(0) 推荐(0) 编辑

2012年11月19日

01背包问题

摘要: 问题描述:有N件物品和一个载重量为C的背包。第i件物品的重量是w[i],价值是v[i]。求解将哪些物品装入背包可使这些物品的重量总和不超过背包容量,且价值总和最大。问题特点:每种物品仅有一件,可以选择放或不放。(0:不放 1:放)基本思路:用p[i][j]表示从i件物品中选择物品放入一个容量为j的背包中可以获得的最大价值。得到如下关系:1.p[i][0] = p[0][j] = 0··········· (1)2.p[i][j] = p[i - 1][j] (当j < w[i]) 阅读全文

posted @ 2012-11-19 23:47 铁树银花 阅读(152) 评论(0) 推荐(0) 编辑

2012年11月18日

Design T-Shirt(排序)

摘要: Design T-ShirtTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 3018Accepted Submission(s): 1500Problem DescriptionSoon after he decided to design a T-shirt for our Algorithm Board on Free-City BBS, XKA found that he was trapped by all kinds of sugge 阅读全文

posted @ 2012-11-18 14:33 铁树银花 阅读(320) 评论(0) 推荐(0) 编辑

Windows Message Queue(优先级队列+map)

摘要: Windows Message QueueTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1952Accepted Submission(s): 759Problem DescriptionMessage queue is the basic fundamental of windows system. For each process, the system maintains a message queue. If something ha 阅读全文

posted @ 2012-11-18 11:50 铁树银花 阅读(297) 评论(0) 推荐(0) 编辑

2012年11月13日

Jungle Roads(最小生成树+并查集)

摘要: Jungle RoadsTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2996Accepted Submission(s): 2124Problem DescriptionThe Head Elder of the tropical island of Lagrishan has a problem. A burst of foreign aid money was spent on extra roads between villages 阅读全文

posted @ 2012-11-13 23:01 铁树银花 阅读(199) 评论(0) 推荐(0) 编辑

Gene Assembly(贪心,简单)

摘要: 1076 - Gene Assembly时间限制:Java: 2000 ms / Others: 2000 ms内存限制:Java: 65536 KB / Others: 65536 KB问题描述 Statement of the ProblemWith the large amount of genomic DNA sequence data being made available, it is becoming more important to find genes (parts of the genomic DNA which are responsible for the synt 阅读全文

posted @ 2012-11-13 21:55 铁树银花 阅读(467) 评论(0) 推荐(0) 编辑

Argus(ZOJ Problem Set - 2212)(优先队列)

摘要: Argus 时间限制(普通/Java):1000MS/3000MS 运行内存限制:65536KByte总提交: 3 测试通过: 2描述A data stream is a real-time, continuous, ordered sequence of items. Some examples include sensor data, Internet traffic, financial tickers, on-line auctions, and transaction logs such as Web usage logs and telephone call reco... 阅读全文

posted @ 2012-11-13 15:55 铁树银花 阅读(314) 评论(0) 推荐(0) 编辑

2012年11月11日

error LNK2001: unresolved external symbol _main

摘要: Win32 控制台应用程序需要 main 函数作为入口点。当链接器在附加到项目的任何文件中都找不到 main 函数时会返回此错误消息。加上main()函数即可 阅读全文

posted @ 2012-11-11 23:38 铁树银花 阅读(103) 评论(0) 推荐(0) 编辑

c++ vector使用下标赋值出错

摘要: 有以下程序#include <iostream> #include <vector> using namespace std; int main() { vector<int> v; v[0] = 1; return 0; } 运行会出现内存非法操作的错误。症结在于“v[0] = 1”一句。一开始vector为空时,不能对其进行下标赋值。而要用push_back().以下程序#include <iostream> #include <vector> using namespace std; int main() { vector< 阅读全文

posted @ 2012-11-11 17:17 铁树银花 阅读(500) 评论(0) 推荐(0) 编辑

2012年11月7日

MFC程序出现“Debug Assertion Failed! File:afx.inl Line:177”错误

摘要: 程序运行时弹出提示框原因:数组访问越界。 阅读全文

posted @ 2012-11-07 10:04 铁树银花 阅读(490) 评论(0) 推荐(0) 编辑

MFC程序出现“Debug Assertion Failed! File:dlgdata.cpp Line: 43 ”错误

摘要: 运行程序时,弹出提示框出错的原因是,我删掉了一个编辑框,但是没有清除相应对话框类(***Dlg.h)和资源头文件(Resource.h)中的相关信息。我删除的编辑框的映射变量为“m_strOverflow”,在所有文件中查找这一关键词,注释掉相关语句,程序就能正常运行。 阅读全文

posted @ 2012-11-07 09:36 铁树银花 阅读(387) 评论(0) 推荐(0) 编辑

2012年11月5日

C++重载运算符

摘要: 本文主要讲述加号运算符“+”,自增运算符“++”,流提取运算符运“>>”,流插入运算符"<<"的重载。先给出Vector类:class Vector { public: Vector(double a = 0, double b = 0) {x = a, y = b;} //构造函数 Vector(const Vector& v){x = v.x, y = v.y;} //拷贝构造函数 Vector operator + (const Vector& v); //重载+ Vector operator ++ (); ... 阅读全文

posted @ 2012-11-05 20:27 铁树银花 阅读(449) 评论(0) 推荐(1) 编辑

2012年11月4日

MFC设置按下Enter键后响应指定的按钮

摘要: 鼠标右键点击想要设置的button,选择属性(Properties),再选择Styles,选中Default Button。 阅读全文

posted @ 2012-11-04 22:17 铁树银花 阅读(408) 评论(0) 推荐(0) 编辑

MFC无法给组合框控件添加CString类成员变量

摘要: 今天出现了这个问题,网上搜了很久,虽然没有找到直接的答案,但是获得了启发,解决了这个问题——其实只是自己刚入门所识有限。我原来设定组合框的类型为Drop List,下拉列表式组合框的编辑框是不能编辑的,因而不能添加字符串类,改为允许编辑的Dropdown即可。顺便介绍一下几种类型的组合框:1.简易组合框(Simple)简易组合框中的列表框是一直显示的,编辑框可以编辑。2.下拉式组合框(Dropdown)下拉式组合框默认不显示列表框,只有在点击了编辑框右侧的下拉箭头才会弹出列表框,编辑框可以编辑。3.下拉列表式组合框(Drop List)下拉列表式组合框的编辑框是不能编辑的,只能由用户在下拉列表 阅读全文

posted @ 2012-11-04 16:08 铁树银花 阅读(413) 评论(0) 推荐(0) 编辑

2012年11月3日

构造函数初始化列表

摘要: 以下所有程序在code::blocks中编译运行,使用GNU GCC compiler一、什么是构造函数初始化列表构造函数初始化列表以一个冒号开始,接着是以逗号分隔的数据成员列表,每个数据成员后面跟一个放在括号中的初始化式。例如:class MyClass{ public: MyClass():x(1),y(2){} private: int x; int y;};MyClass():x(1), y(2){}就是构造函数初始化列表,分别将MyClass的两个成员变量x和y初始化为1和2.以上的构造函数初始化列表跟普通的构造函数:MyClass(){x = 1; y = 2;}效果相同。二、使用 阅读全文

posted @ 2012-11-03 11:50 铁树银花 阅读(359) 评论(0) 推荐(0) 编辑

2012年10月29日

<Codeforces Round #147 (Div. 2)>A. Free Cash(水题)

摘要: A. Free Cashtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputValera runs a 24/7 fast food cafe. He magically learned that next daynpeople will visit his cafe. For each person we know the arrival time: thei-th person comes exactly athihoursmiminute 阅读全文

posted @ 2012-10-29 17:53 铁树银花 阅读(290) 评论(0) 推荐(0) 编辑

2012年10月20日

<errors>'MessageBoxA' : function does not take 1 parameter

摘要: 'MessageBoxA' : does not take 1 parameters原因及解决方法 AfxMessageBox()一般应用于窗体之中,没有窗体,或者是全局函数,不能使用该函数;MessageBox()可以应用于没有窗体和有窗体的两种情况1)在有窗体的情况下,和AfxMessageBox()的用法一样,也就是只要一个参数;2) 在没有窗体或者全局函数中,他必须传入一个窗体句柄才可能执行,如果没有,用NULL代替也可,但是此时该消息框属于桌面,可能达不到我们所需要的目的,所以一般要传入一个窗口句柄。第二种情况下须给出函数的四个参数int MessageBox(HWN 阅读全文

posted @ 2012-10-20 13:23 铁树银花 阅读(351) 评论(0) 推荐(0) 编辑

2012年10月18日

如何让MFC编写的应用程序(用VC6.0开发)能在别的电脑上运行

摘要: 把应用程序做成Release版的应用程序,具体步骤如下:菜单Build->SetActiveConfigure,在弹出对话框中选择Win32Release,点OK,然后 菜单project->setting ,在弹出对话框的General属性页的Microsoft Foundation classes 下拉列表中选择User MFC in static Library,然后rebuildall,把生成的Release目录下 的可执行文件拷贝到另一台机器上即可此外,rebuildall时,可能会出现警告:all references to "SHELL32.dll" 阅读全文

posted @ 2012-10-18 17:45 铁树银花 阅读(1713) 评论(0) 推荐(0) 编辑

2012年10月15日

模板实例化函数链接出错:error LNK2019: unresolved external symbol

摘要: 模板类的定义和实现要放在一个文件中 阅读全文

posted @ 2012-10-15 00:05 铁树银花 阅读(195) 评论(0) 推荐(0) 编辑

2012年10月5日

《C与指针》读书笔记

摘要: 第六章6.1. 内存和地址获得一个值的地址,就能根据这个地址获得这个值,但如果编程时直接使用地址访问值,是非常繁琐的,所以高级语言使用名字而非地址访问内存的位置,这些名字就是我们编程者所使用的变量。变量名和内存位置之间的关联是编译器提供的,为编程者所使用。而电脑硬件依旧使用地址访问内存位置。6.4. 间接访问操作符通过指针访问他所指向的内存地址称为“间接访问”或“解引用指针”,用于进行间接访问的操作符是单目运算符*。比如指针p的值是100,即它储存的地址(指向的地址)是100,对p使用间接访问操作符*时,就是访问内存地址100并察看那里存放的值。如果内存100存放的值是112,那么*p就等于1 阅读全文

posted @ 2012-10-05 21:41 铁树银花 阅读(217) 评论(0) 推荐(0) 编辑

2012年10月2日

指针总结

摘要: 1.指针的地址和指针上储存的地址。指针是储存地址的变量,而指针自身也有自己的地址。#include <iostream> using namespace std; int main() { int *p, a; p = &a; //将a的地址赋值给p,此时p储存a的地址 cout << "指针p的地址:" << &p << endl; cout << "指针p储存的地址:" << p << endl; cout << "a的地址:&q 阅读全文

posted @ 2012-10-02 20:01 铁树银花 阅读(241) 评论(0) 推荐(0) 编辑

'operator =' must be a <Unknown> member

摘要: 赋值运算符“=”,不能以友元函数方式重载,只能重载为某类中的成员函数. 阅读全文

posted @ 2012-10-02 12:45 铁树银花 阅读(266) 评论(0) 推荐(0) 编辑

2012年9月11日

归并排序模板

摘要: 1 #include <iostream> 2 #include <string> 3 #include <cstdio> 4 #include <cmath> 5 #include <cstring> 6 #include <algorithm> 7 #include <vector> 8 #define LL long long 9 #define MAXI 214748364710 #define MAXL 922337203685477580711 #define eps (1e-8)12 #defin 阅读全文

posted @ 2012-09-11 21:47 铁树银花 阅读(242) 评论(0) 推荐(0) 编辑

[置顶] ACM模板

摘要: 一、排序1.归并排序:点击打开链接 阅读全文

posted @ 2012-09-11 21:47 铁树银花 阅读(171) 评论(0) 推荐(0) 编辑

2012年9月5日

MATLAB学习--多项式拟合(1)

摘要: (1)polyfit函数MATLAB的polyfit函数用于多项式拟合,其语法为:p = polyfit(x, y, k);其中,x,y分别是横纵坐标向量,它们不仅元素个数相同,而且同为行向量或同为列向量。k为非负整数,是待拟合的多项式的最高次数。p是输出项,为待拟合的多项式的系数向量(由高次到低次排列)。例子:在MATLAB的命令窗口输入以下代码:>> x = [1, 2, 3, 4];>> y = [3, 5, 7, 9];>> p = polyfit(x, y, 1)敲击回车键,得到输出结果:p = 2.0000 1.0000所以拟合得的函数就是:y 阅读全文

posted @ 2012-09-05 10:49 铁树银花 阅读(11102) 评论(0) 推荐(1) 编辑

2012年9月4日

(Codeforces Round #136 (Div. 2))A. Little Elephant and Function(递归分析,简单)

摘要: A. Little Elephant and Functiontime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe Little Elephant enjoys recursive functions.This time he enjoys the sorting function. Let a is a permutation of an integers from 1 to n, inclusive, and ai denotes t 阅读全文

posted @ 2012-09-04 21:44 铁树银花 阅读(301) 评论(0) 推荐(0) 编辑

导航