上一页 1 ··· 5 6 7 8 9 10 下一页

2012年7月18日

cin、cin.get()、cin.getline()、getline()、gets()等函数的用法

摘要: 转载,并经过本人补充cin、cin.get()、cin.getline()、getline()、gets()等函数的用法2007/10/27 22:51学C++的时候,这几个输入函数弄的有点迷糊;这里做个小结,为了自己复习,也希望对后来者能有所帮助,如果有差错的地方还请各位多多指教(本文所有程序均通过VC 6.0运行)转载请保留作者信息;1、cin1、cin.get()2、cin.getline()3、getline()4、gets()5、getchar()1、cin>>用法1:最基本,也是最常用的用法,输入一个数字:#include <iostream>using n 阅读全文

posted @ 2012-07-18 22:22 铁树银花 阅读(192) 评论(0) 推荐(0) 编辑

<cf>Square

摘要: B. Squaretime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is a square painted on a piece of paper, the square's side equalsnmeters. John Doe draws crosses on the square's perimeter. John paints the first cross in the lower left corne 阅读全文

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

[置顶] 错误存档

摘要: 1.当n是short int ,m是long long int时,语句m=4*n,使用GNU,得到的m是short int的范围,因此当n稍大时,m就可能溢出。2.输出字符串时,遇到‘\0’结束输入,如果没有适当地设置'\0',可能会出现问题。比如有struct node{ char s[10];}n[2];如果w[0].s中没有‘\0’,则scanf("%s",n[0].s)不会只输出n[0]中字符数组s中的内容,因为这一个输出语句是输出以n[0].s为首地址直到'\0'为止的内容。3.当用memset给char型以外的数组初始化时,只能初 阅读全文

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

<cf>A. Exams

摘要: A. Examstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne day the Codeforces round author sat exams. He hadnexams and he needed to get an integer from2to5for each exam. He will have to re-sit each failed exam, i.e. the exam that gets mark2.The 阅读全文

posted @ 2012-07-18 00:13 铁树银花 阅读(158) 评论(0) 推荐(0) 编辑

2012年7月17日

<cf>Walking in the Rain

摘要: B. Walking in the Raintime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn Berland the opposition is going to arrange mass walking on the boulevard. The boulevard consists ofntiles that are lain in a row and are numbered from1tonfrom right to left. 阅读全文

posted @ 2012-07-17 23:04 铁树银花 阅读(299) 评论(0) 推荐(0) 编辑

<cf> Funky Numbers

摘要: A. Funky Numberstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAs you very well know, this year's funkiest numbers are so called triangular numbers (that is, integers that are representable as, wherekis some positive integer), and the cooles 阅读全文

posted @ 2012-07-17 10:23 铁树银花 阅读(324) 评论(0) 推荐(0) 编辑

2012年7月16日

<poj 1056>IMMEDIATE DECODABILITY

摘要: IMMEDIATE DECODABILITYTime Limit:1000MSMemory Limit:10000KTotal Submissions:8811Accepted:4177DescriptionAn encoding of a set of symbols is said to be immediately decodable if no code for one symbol is the prefix of a code for another symbol. We will assume for this problem that all codes are in bina 阅读全文

posted @ 2012-07-16 17:18 铁树银花 阅读(169) 评论(0) 推荐(0) 编辑

2012年7月15日

<cf>Game on Paper

摘要: B. Game on Papertime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne not particularly beautiful evening Valera got very bored. To amuse himself a little bit, he found the following game.He took a checkered white square piece of paper, consisting o 阅读全文

posted @ 2012-07-15 17:46 铁树银花 阅读(259) 评论(0) 推荐(0) 编辑

2012年7月14日

<cf>Two Problems

摘要: A. Two Problemstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA boy Valera registered on siteCodeforcesasValera, and wrote his firstCodeforces Round #300. He boasted to a friend Arkady about winning as much asxpoints for his first contest. But A 阅读全文

posted @ 2012-07-14 20:47 铁树银花 阅读(234) 评论(0) 推荐(0) 编辑

<poj 1046>Color Me Less

摘要: Color Me LessTime Limit: 1000MSMemory Limit: 10000KTotal Submissions: 25873Accepted: 12417DescriptionA color reduction is a mapping from a set of discrete colors to a smaller one. The solution to this problem requires that you perform just such a mapping in a standard twenty-four bit RGB color spac. 阅读全文

posted @ 2012-07-14 12:02 铁树银花 阅读(204) 评论(0) 推荐(0) 编辑

欧氏距离(Euclidean distance)

摘要: 原文地址:http://www.blogjava.net/spec-second/archive/2008/08/17/222609.html欧氏距离(Euclidean distance)欧氏距离定义: 欧氏距离( Euclidean distance)是一个通常采用的距离定义,它是在m维空间中两个点之间的真实距离。在二维和三维空间中的欧式距离的就是两点之间的距离,二维的公式是 d = sqrt((x1-x2)^+(y1-y2)^) 三维的公式是 d=sqrt(x1-x2)^+(y1-y2)^+(z1-z2)^) 推广到n维空间,欧式距离的公式是 d=sqrt( ∑(xi1-xi2)^ ) 阅读全文

posted @ 2012-07-14 10:48 铁树银花 阅读(1866) 评论(0) 推荐(0) 编辑

<poj1028> Web Navigation

摘要: Web NavigationTime Limit: 1000MSMemory Limit: 10000KTotal Submissions: 23618Accepted: 10534DescriptionStandard web browsers contain features to move backward and forward among the pages recently visited. One way to implement these features is to use two stacks to keep track of the pages that can be 阅读全文

posted @ 2012-07-14 10:32 铁树银花 阅读(188) 评论(0) 推荐(0) 编辑

2012年7月13日

<codeforces>Little Elephant and Sorting

摘要: B. Little Elephant and Sortingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe Little Elephant loves sortings.He has an arrayaconsisting ofnintegers. Let's number the array elements from 1 ton, then thei-th element will be denoted asai. The 阅读全文

posted @ 2012-07-13 19:58 铁树银花 阅读(166) 评论(0) 推荐(0) 编辑

2012年7月12日

<codeforces>A. Little Elephant and Rozdil

摘要: A. Little Elephant and Rozdiltime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe Little Elephant loves Ukraine very much. Most of all he loves town Rozdol (ukr. "Rozdil").However, Rozdil is dangerous to settle, so the Little Elephant wa 阅读全文

posted @ 2012-07-12 16:55 铁树银花 阅读(269) 评论(0) 推荐(0) 编辑

2012年7月5日

Biorhythms(poj1006)

摘要: BiorhythmsTime Limit:1000MSMemory Limit:10000KTotal Submissions:92184Accepted:28170DescriptionSome people believe that there are three cycles in a person's life that start the day he or she is born. These three cycles are the physical, emotional, and intellectual cycles, and they have periods of 阅读全文

posted @ 2012-07-05 16:03 铁树银花 阅读(207) 评论(0) 推荐(0) 编辑

数据类型取值范围

摘要: double型:-1.7*10^308~+1.7*10^308char -128 ~ 127 (1 Byte)short -32767 ~ 32768 (2 Bytes)unsigned short 0 ~ 65536 (2 Bytes)int -2147483648 ~ 2147483647 (4 Bytes)unsigned int 0 ~ 4294967295 (4 Bytes)long == intlong long -9223372036854775808 ~ 9223372036854775807 (8 Bytes) 阅读全文

posted @ 2012-07-05 08:15 铁树银花 阅读(163) 评论(0) 推荐(0) 编辑

2012年7月4日

matlab关键字

摘要: 使用iskeyword函数可以列出matlab的系统关键字 1 >> iskeyword 2 3 ans = 4 5 'break' 6 'case' 7 'catch' 8 'classdef' 9 'continue'10 'else'11 'elseif'12 'end'13 'for'14 'function'15 'global'16 'if'17 'otherwise 阅读全文

posted @ 2012-07-04 22:54 铁树银花 阅读(365) 评论(0) 推荐(0) 编辑

2012年6月20日

fatal error C1001: INTERNAL COMPILER ERROR

摘要: 我将运算符重载为类的友元函数时出现这个错误,据说这是vc6.0的一个bug,不是程序本身的error,我的解决方式:#include <iostream>using namespace std;改为#include "iostream.h"参考的是谭浩强老师的《C++程序设计》上的一段话:visual C++ 6.0没有完全实现C++标准,它所提供不带后缀.h的头文件不支持把成员函数重载为友元函数,但visual C++ 6.0提供的带有.h的头文件支持此项功能。 阅读全文

posted @ 2012-06-20 23:01 铁树银花 阅读(261) 评论(0) 推荐(0) 编辑

error LNK2001: unresolved external symbol "public: int __thiscall A<int>::get(void)" (?get@?$A@H@@QAEHXZ)

摘要: 关于此类错误,网上有各种各样的解释,而本人遇到的问题是:将类模板成员函数的声明和实现分离。将成员函数的实现也放到头文件中就没事了。说明一下,我用的是vc6.0 阅读全文

posted @ 2012-06-20 21:01 铁树银花 阅读(2234) 评论(0) 推荐(0) 编辑

2012年6月17日

C/C++怎么产生随机数【转】

摘要: C语言/C++中怎样产生随机数C语言/C++怎样产生随机数:这里要用到的是rand()函数, srand()函数,C语言/C++里没有自带的random(int number)函数。(1) 如果你只要产生随机数而不需要设定范围的话,你只要用rand()就可以了:rand()会返回一随机数值, 范围在0至RAND_MAX 间。RAND_MAX定义在stdlib.h, 其值为2147483647。例如:#include<stdio.h>#include<stdlib.h>void main(){ for(int i=0;i<10;i+) printf("%d 阅读全文

posted @ 2012-06-17 14:58 铁树银花 阅读(380) 评论(0) 推荐(1) 编辑

2012年6月11日

一些程序的整理

摘要: 1.#include <iostream>using namespace std;void func(int i=0){ cout<<i<<endl;}int main(){ func(3); return 0;}输出:3 阅读全文

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

2012年6月8日

error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'class std::basic_s

摘要: 没有添加头文件,cout不能直接输出string类的变量。 阅读全文

posted @ 2012-06-08 08:02 铁树银花 阅读(3587) 评论(0) 推荐(0) 编辑

2012年6月6日

'setw' : undeclared identifier

摘要: 没有#include <iomanip>,因此会出现这个错误,而且还有一个小问题要注意。我在编写一个类的时候用到了setw的格式化输出,成员函数在.cpp文件中实现,.cpp文件中包含了iomanip,但是声明类的.h文件中却没有包含,于是vc6.0报错。我添上之后就0 error 了。 阅读全文

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

2012年6月3日

initialization of 'XXX' is skipped by 'case' label

摘要: 中文翻译大致是xxx的初始化由于“case”被跳过出现error的原因是switch 的 case 中不能定义变量。例如case:int num;。解决方法是:在case中用{}将代码括起来,这样在{}中就能定义变量了;又或者直接用if-else代替switch 阅读全文

posted @ 2012-06-03 22:48 铁树银花 阅读(234) 评论(0) 推荐(0) 编辑

运算符重载

摘要: 参数个数的限定 非成员函数: 单目运算符:参数表中只有一个参数; 双目运算符:参数表中只有两个参数成员函数: 单目运算符:参数表中没有参数; 双目运算符:参数表中只有一个参数 >>待续 阅读全文

posted @ 2012-06-03 19:42 铁树银花 阅读(130) 评论(0) 推荐(0) 编辑

2012年5月28日

继承与派生

摘要: 继承 继承是面向对象程序设计中一个重要的机制,它能体现类的层次关系。继承使得程序员可以在一个较一般的类的基础上很快地建立一个新类,而不必从零开始设计每个类,实现了代码重用。在现实世界中,许多实体或概念不是孤立的,它们具有共同的特征,但也有细微的差别,人们使用层次分类的方法来描述这些实体或概念之间的相似点和不同点。比如“学生”是“小学生”和“大学生”的父类(基类),“小学生”和“大学生”分别是“学生”的子类(派生类),子类具有父类的全部属性并有自己新增的属性。派生类 继承机制是在原有类的基础上通过修改或扩充构成新类,产生的新类成为派生类,原有类称为基类。1.派生类的定义形式: class ... 阅读全文

posted @ 2012-05-28 23:45 铁树银花 阅读(263) 评论(0) 推荐(0) 编辑

友元和友元函数

摘要: 采用类的机制后实现了数据的隐藏与封装,类的数据成员一般定义为私有成员或保护成员,成员函数一般定义为公有的,依此提供类与外界间的通信接口。但是,有时需要定义一些函数,这些函数不是类的一部分,但又需要频繁地访问类的数据成员,这时可以将这些函数定义为该函数的友元函数。除了友元函数外,还有友元类,两者统称为友元。友元提高了程序的运行效率(即减少了类型检查和安全性检查等都需要时间开销),但它破坏了类的封装性和隐藏性,使得非成员函数可以访问类的私有成员和保护成员,降低了程序的可维护性,所以需要谨慎使用。友元函数:友元函数是可以直接访问类的私有成员、保护成员的非成员函数。它是定义在类外的普通函数,它不属.. 阅读全文

posted @ 2012-05-28 21:15 铁树银花 阅读(998) 评论(1) 推荐(0) 编辑

2012年5月20日

类的使用(基础)

摘要: 以下是本人学习类与对象的一些总结笔记,尚不完整,在补充更新中~~~一、类的定义 类一般在.h文件中声明,类中的成员函数的实现一般在.cpp文件中给出,注意需要在main函数外给出(例程1.4)。如果是单文件格式,类声明可以在main函数内也可以在main外(例程1.1),但是它的成员函数的定义不能main内。实际上当类在main内声明时成员函数的定义无论在main外还是main内都会有问题(我目前的发现是这样,见例程1.3),因此注意类的声明最好在main外,这样既清晰又不会错。注意类的声明之后要加分号。定义类时不能给成员赋初值(例程1.6),这跟结构体一致。例程1.1:类在main中声明,. 阅读全文

posted @ 2012-05-20 20:33 铁树银花 阅读(477) 评论(0) 推荐(0) 编辑

2012年5月17日

A. Vasya and the Bus

摘要: A. Vasya and the Bustime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne day Vasya heard a story: "In the city of High Bertown a bus number 62 left from the bus station. It hadngrown-ups andmkids..."The latter events happen to be of no i 阅读全文

posted @ 2012-05-17 23:13 铁树银花 阅读(220) 评论(0) 推荐(0) 编辑

2012年4月18日

HDU 1856 More is better(并查集 很好的基础题)

摘要: More is betterTime Limit: 5000/1000 MS (Java/Others)Memory Limit: 327680/102400 K (Java/Others)Total Submission(s): 5172Accepted Submission(s): 1939Problem DescriptionMr Wang wants some boys to help him with a project. Because the project is rather complex,the more boys come, the better it will be. 阅读全文

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

2012年4月17日

HDU 1172 猜数字(枚举)

摘要: 猜数字Time Limit: 20000/10000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1248Accepted Submission(s): 708Problem Description猜数字游戏是gameboy最喜欢的游戏之一。游戏的规则是这样的:计算机随机产生一个四位数,然后玩家猜这个四位数是什么。每猜一个数,计算机都会告诉玩家猜对几个数字,其中有几个数字在正确的位置上。比如计算机随机产生的数字为1122。如果玩家猜1234,因为1,2这两个数字同时存在于这两个数中, 阅读全文

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

2012年4月13日

HDU 1213 How Many Tables(并查集)

摘要: How Many TablesTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 5194Accepted Submission(s): 2452Problem DescriptionToday is Ignatius' birthday. He invites a lot of friends. Now it's dinner time. Ignatius wants to know how many tables he need 阅读全文

posted @ 2012-04-13 16:12 铁树银花 阅读(170) 评论(0) 推荐(0) 编辑

2012年4月12日

HDUOJ 1162 Eddy's picture(最小生成树)

摘要: Eddy's pictureTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 3511Accepted Submission(s): 1722Problem DescriptionEddy begins to like painting pictures recently ,he is sure of himself to become a painter.Every day Eddy draws pictures in his smal 阅读全文

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

HDUOJ 2544 最短路

摘要: 最短路Time Limit: 5000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 11062Accepted Submission(s): 4709Problem Description在每年的校赛里,所有进入决赛的同学都会获得一件很漂亮的t-shirt。但是每当我们的工作人员把上百件的衣服从商店运回到赛场的时候,却是非常累的!所以现在他们想要寻找最短的从商店到赛场的路线,你可以帮助他们吗?Input输入包括多组数据。每组数据第一行是两个整数N、M(N<=100,M 阅读全文

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

POJ 题目分类

摘要: :一.基本算法: (1)枚举. (poj1753,poj2965) (2)贪心(poj1328,poj2109,poj2586) (3)递归和分治法. (4)递推. (5)构造法.(poj3295) (6)模拟法.(poj1068,poj2632,poj1573,poj2993,poj2996)二.图算法: (1)图的深度优先遍历和广度优先遍历. (2)最短路径算法(dijkstra,bellman-ford,floyd,heap+dijkstra) (poj1860,poj3259,poj1062,poj2253,poj1125,poj2240) (3)最小生成树算法(prim,krusk. 阅读全文

posted @ 2012-04-12 16:44 铁树银花 阅读(187) 评论(0) 推荐(0) 编辑

2012年4月11日

HDUOJ 1198 Farm Irrigation(并查集)

摘要: Farm IrrigationTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2167Accepted Submission(s): 977Problem DescriptionBenny has a spacious farm land to irrigate. The farm land is a rectangle, and is divided into a lot of samll squares. Water pipes are p 阅读全文

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

2012年4月9日

并查集

摘要: 原文地址:http://www.ahathinking.com/archives/10.html昨天和今天学习了并查集和trie树,并练习了三道入门题目,理解更为深刻,觉得有必要总结一下,这其中的内容定义之类的是取自网络,操作的说明解释及程序的注释部分为个人理解。并查集学习:并查集:(union-find sets)一种简单的用途广泛的集合. 并查集是若干个不相交集合,能够实现较快的合并和判断元素所在集合的操作,应用很多,如其求无向图的连通分量个数等。最完美的应用当属:实现Kruskar算法求最小生成树。并查集的精髓(即它的三种操作,结合实现代码模板进行理解):1、Make_Set(x) 把每 阅读全文

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

HDU 1222 Wolf and Rabbit

摘要: Wolf and RabbitTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2968Accepted Submission(s): 1432Problem DescriptionThere is a hill with n holes around. The holes are signed from 0 to n-1.A rabbit must hide in one of the holes. A wolf searches the ra 阅读全文

posted @ 2012-04-09 08:50 铁树银花 阅读(226) 评论(0) 推荐(0) 编辑

2012年4月7日

HDU 1231 最大连续子序列

摘要: 最大连续子序列Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 10071Accepted Submission(s): 4227Problem Description给定K个整数的序列{ N1, N2, ..., NK },其任意连续子序列可表示为{ Ni, Ni+1, ...,Nj },其中 1 <= i <= j <= K。最大连续子序列是所有连续子序列中元素和最大的一个,例如给定序列{ -2, 11, -4, 13, - 阅读全文

posted @ 2012-04-07 23:03 铁树银花 阅读(209) 评论(0) 推荐(0) 编辑

2012年4月6日

HDUOJ 1879 继续畅通工程

摘要: 继续畅通工程Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 6712Accepted Submission(s): 2808Problem Description省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可)。现得到城镇道路统计表,表中列出了任意两城镇间修建道路的费用,以及该道路是否已经修通的状态。现请你编写程序,计算出全省畅通需要的最低成本。Input测试输入包含若干测 阅读全文

posted @ 2012-04-06 20:10 铁树银花 阅读(164) 评论(0) 推荐(0) 编辑

上一页 1 ··· 5 6 7 8 9 10 下一页

导航