![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
旧文转移(2012年)
文章平均质量分 53
冰封飞飞
这个作者很懒,什么都没留下…
展开
-
C++实现龙贝格计算积分
很久之前写的了,纪念已经逝去的数值分析。。原创 2015-01-07 00:12:26 · 5808 阅读 · 1 评论 -
POJ2159解题报告
英文题鸭梨山大。读了很久题才读明白,但是没有看到重要的地方,导致WA。主要题意就是介绍2种加密方式,第一种是将每个字母ascii加相同的值(注意,不一定加1,只是例子是加1),超过Z返回A。第二种就是将字符串打乱(不一定是按照题干的序列打乱)。然后这个题就是统计一下各个字符出现的频率的序列是否相同就可以了。而不被在意那些字符是什么频率。这个方法可能不是对所有的数据都判断正确原创 2014-12-07 15:21:50 · 553 阅读 · 0 评论 -
POJ1083结题报告
这个题一开始没有什么思路,毕竟算法水平基本为0……看了一位同学的解析之后一下就明白了。按照这个方法,这题很水了。高手的思路真是不一般将走廊分成200份,有东西走过时,计数器加一。最后将走过次数最多的地方*10就可以了。#include #include #include #include using namespace std;bool rot(pair原创 2014-12-07 15:25:10 · 393 阅读 · 0 评论 -
POJ3006
题意是一个序列a, a+d,a+2d,……,a+nd;给定a,d,n,让你找出第n个素数#include using namespace std; bool isprime(int num){ /********************************************//** * 判断num是否为素数 **********原创 2014-12-07 15:27:44 · 484 阅读 · 0 评论 -
数据结构二叉查找树C++实现
#include using namespace std;templateclass BinarySearchTree{public: BinarySearchTree(); BinarySearchTree(const BinarySearchTree& rhs); //copy constructor ~BinarySearchTree(); //destru原创 2014-12-07 15:35:05 · 464 阅读 · 0 评论 -
九度OJ 1002
#include #include #include using namespace std;int abs(int n){ return n < 0 ? -n : n;}int main(){ int p, t, g1, g2, g3, gj; double grade; while(cin >> p >> t >> g1 >> g2 >> g3原创 2014-12-07 15:46:57 · 771 阅读 · 0 评论 -
九度OJ 1003
#include #include #include #include bool judge(const char& ch){ if(ch == ',') return true; else return false;}using namespace std;int main(){ string num1, num2;原创 2014-12-07 15:47:24 · 474 阅读 · 0 评论 -
九度OJ 1008
#include #include #include #include #include #include #include using namespace std;vector > len(1001, vector(1001));vector > cost(1001, vector(1001));vector distD(1001);vector distP(1001)原创 2014-12-07 15:49:14 · 455 阅读 · 0 评论 -
POJ2739解题报告
不算很难的题,看清题干,必须是连续的素数序列。看清这点一般就可以做出来了。首先将10000内的素数存到一个数组里面,我开了1300大小的数组。设置一个上标和下标。设置一个sum为连续序列的和,num为所求的数。1、当sum 如果sum+上标指定素数不大于num那就让sum+上标指定的素数然后将上标后移。如果下标超过上标的话终止。2.如果sum ==原创 2014-12-07 15:24:01 · 440 阅读 · 0 评论 -
九度OJ 1005
#include #include #include #include using namespace std;class student{public: student(int rk, int i, int j) : ge(rk), gi(i), id(j){} int getRank(){return ge + gi;} int getGe(){retu原创 2014-12-07 15:48:35 · 429 阅读 · 0 评论 -
vs2010将杂乱的代码格式化
有时候百度贴吧里的用户发的代码比较乱,复制到自己的IDE里面连看都不想看。今天发现一个神器AStyle。下载地址 http://sourceforge.net/projects/astyle/files/latest/download他可以把杂乱的代码格式化。原版是用命令行操作,现在把AStyle和vs2010整合一下。网上的教程比较乱而且说的参数说的也不对。这里简单的说一下。步骤:打开V原创 2014-12-07 15:56:03 · 3034 阅读 · 1 评论 -
数据结构队列C++实现 链式和循环
#include #include #include using namespace std;namespace my_space{ template class queue { public: queue(); //初始化队列 ~queue(); //销毁队列原创 2014-12-07 15:34:03 · 2150 阅读 · 0 评论 -
各种排序算法的C++实现
#include #include #include #include #include #include using namespace std;void bubble(vector &a) //冒泡排序{ for(size_t i = 0; i < a.size() - 1; ++i) { for(size_t j = i + 1; j < a.原创 2014-12-07 15:39:41 · 502 阅读 · 0 评论 -
数据接口线性表C++实现
#include #include using namespace std;const int list_init_size = 100;const int listincrement = 10;templateclass list_sq{public: bool InitList(); //构造一个空的线性表 void DestroyList(原创 2014-12-07 15:29:48 · 476 阅读 · 0 评论 -
数据结构二叉堆C++实现 最小堆
#include #include #include #include using namespace std;templateclass BinaryHeap{public: BinaryHeap(); explicit BinaryHeap(const vector& items); bool isEmpty() const; const Co原创 2014-12-07 15:38:07 · 1131 阅读 · 0 评论 -
OJ百练1003:Hangover
#include using namespace std;int cards(float lenth){ int num = 1; float currentLen = 0.5f; while(lenth >= currentLen) { ++num; currentLen += 1.0 / (num + 1); }原创 2014-12-07 15:44:56 · 606 阅读 · 0 评论 -
C++本地化小结
MinGW对c++的std::locale支持不佳,在MinGW程序下使用本地化功能要直接用c版本,setlocale(LC_ALL, "");这样wchar_t就可以一次性读2个字节的数据了,否则wchar_t只可以一次性读一个字节。但是输出的时候,不能用wcout,只能用wprintf输出。例如wprintf(L"%lc ",temp);写一个小程序,统计文本中所有汉字原创 2014-12-07 15:17:37 · 1796 阅读 · 0 评论 -
记录使用ubuntu的一些经历
1.安装gcc g++sudo apt-get install build-essential用上面命令安装GCC,可以编译C++的编译命令: g++ -o test test.cpp运行编译后的程序: ./test2.cairo-dock 类似于mac os的dock3.ubuntu安装kde首先,打开终端,输入sudo apt-get install k原创 2014-12-07 15:50:43 · 1488 阅读 · 0 评论 -
POJ1503
大数相加没什么好说的,就是代码写的稀烂……#include #include #include using namespace std; int main(){ freopen("1.txt", "r", stdin); string str1 = "", str2 = ""; while(cin >> str1 && str1 != "0")原创 2014-12-07 15:26:51 · 546 阅读 · 0 评论 -
数据结构 hashtable C++实现 链式
#include #include #include #include #include bool isPrime(int x){ for(int i = 2; i * i <= x; ++i) { if(x % i == 0) return false; } return true;}int nextprim原创 2014-12-07 15:36:43 · 478 阅读 · 0 评论 -
数据结构hashtable C++实现 非链式
#include #include using namespace std;bool isPrime(int x){ for(int i = 2; i * i <= x; ++i) { if(x % i == 0) return false; } return true;}int nextprime(int x)原创 2014-12-07 15:37:26 · 390 阅读 · 0 评论 -
OJ百练1001
#include #include #include using namespace std;string strMultiplies(const string& str1, const string& str2){ int len1 = str1.size(); int len2 = str2.size(); int *bigArray = new int[l原创 2014-12-07 15:42:53 · 1400 阅读 · 0 评论 -
OJ百练1002 487-3279
#include #include #include #include #include using namespace std;bool judge(const char& ch){ if(ch == '-') return true; else return false;}int main(){ int cnt;原创 2014-12-07 15:43:41 · 630 阅读 · 0 评论 -
OJ百练1005
#include #include using namespace std;int years(float x, float y){ float r = sqrt(x * x + y * y); float square = 3.1415926 * r * r / 2; float currentSquare = 0; int year = 0; w原创 2014-12-07 15:45:55 · 471 阅读 · 0 评论 -
九度OJ 1001
#include #include using namespace std;int main(){ int m, n; vector matrix; while(cin >> m && m != 0 && cin >> n) { int temp, count = 0; matrix.resize(m * n);原创 2014-12-07 15:46:31 · 515 阅读 · 0 评论 -
poj3299 解题报告
这个题还是算POJ中比较水的主要题意就是获得公式中3个变量中的其中2个然后求第三个。 humidex = temperature + h h = (0.5555)× (e - 10.0) e = 6.11 × exp [5417.7530 × ((1/273.16) - (1/(dewpoint+273.16)))]WA了一次,不知道为什么POJ上g++,原创 2014-12-07 15:21:02 · 441 阅读 · 0 评论 -
POJ2262解题报告
真题真心水题,不过做的时候2了……一开始将100000以下的素数打表……超时,然后怒了,将所有素数输出到文件里面,然后直接手动建表……代码长度过长了……无语了。其实直接计算需要的计算的数就可以了……#include using namespace std; bool isprime(int x){ for(int i = 2; i * i <= x;原创 2014-12-07 15:26:01 · 490 阅读 · 0 评论 -
数据结构链表C++实现
#include #include #include using namespace std;templateclass linklist{public: linklist(); //构造函数 ~linklist(); //析构函数 bool insert(int pos, ElemType e); //在pos位置插入e bool del(原创 2014-12-07 15:30:42 · 529 阅读 · 0 评论 -
数据结构双向链表C++实现
#include #include using namespace std;templateclass dblist{public: dblist(); //构造函数 ~dblist(); //析构函数 bool insert(int pos, ElemType e); //在pos位置插入e,插入成功返回t原创 2014-12-07 15:31:45 · 521 阅读 · 0 评论 -
数据结构栈的C++实现
#include #include #include using namespace std;namespace my_space{ template class stack { public: stack(); //栈的初始化 ~stack(); //栈的销毁 void原创 2014-12-07 15:32:31 · 488 阅读 · 0 评论 -
数据结构avlTree C++实现
#include using namespace std;templateclass AvlTree{public: AvlTree(); AvlTree(const AvlTree& rhs); ~AvlTree();public: const Comparable& findMin() const; //find the minimum val原创 2014-12-07 15:41:13 · 1170 阅读 · 0 评论 -
KMP算法 C++实现
#include #include #include using namespace std;void getNext(const string &substr, vector &next){ next.clear(); next.resize(substr.size()); int j = -1; next[0] = -1; for(int i原创 2014-12-07 15:41:36 · 5248 阅读 · 0 评论 -
九度OJ 1009
#include #include using namespace std;int main(){ int n; while(cin >> n, n != 0) { string tree; cin >> tree; string root; root = tree[0]; string原创 2014-12-07 15:49:54 · 489 阅读 · 0 评论 -
九度OJ 1004
#include #include #include #include using namespace std;int main(){ int m; vector vec; while(cin >> m) { int temp; for(int i = 0; i < m; ++i) {原创 2014-12-07 15:48:00 · 407 阅读 · 0 评论