随笔分类 -  C++程序设计

记录下学习的点滴
摘要:#include <iostream> #include <vector> #include <cstddef> #include <string> #include <sstream> #include <fstream> #include <algorithm> #include <cmath> 阅读全文
posted @ 2019-04-25 10:39 东宫得臣 阅读(140) 评论(0) 推荐(0) 编辑
摘要:template <class T> double VectorMedian(std::vector<T> &In) { std::sort(In.begin(), In.end()); if(In.size() % 2 == 0) { return 0.5*(In.at(In.size()/2)+ 阅读全文
posted @ 2019-04-10 20:08 东宫得臣 阅读(148) 评论(0) 推荐(0) 编辑
摘要:#include <iostream> #include <string> #include <vector> #include <algorithm> #include <map> #include <fstream> #include <sstream> void ReadDataFromFil 阅读全文
posted @ 2019-03-13 16:57 东宫得臣 阅读(232) 评论(0) 推荐(0) 编辑
摘要:template <class T1, class T2> double Minkowski(const std::vector<T1> &inst1, const std::vector<T2> &inst2, const double &k) { if(inst1.size() != inst2 阅读全文
posted @ 2019-03-06 16:57 东宫得臣 阅读(476) 评论(0) 推荐(0) 编辑
摘要:#include <iostream> #include <vector> #include <string> #include <sstream> #include <fstream> #include <algorithm> #include <functional> #include <num 阅读全文
posted @ 2019-02-28 10:45 东宫得臣 阅读(330) 评论(0) 推荐(0) 编辑
摘要:原始数据 #include <iostream>#include <fstream>#include <sstream>#include <vector>#include <string>#include <algorithm>#include <numeric>#include <cmath>#i 阅读全文
posted @ 2019-02-26 19:53 东宫得臣 阅读(149) 评论(0) 推荐(0) 编辑
摘要:Pseudo Code of KNN We can implement a KNN model by following the below steps: Load the data Initialise the value of k For getting the predicted class, 阅读全文
posted @ 2019-02-25 15:07 东宫得臣 阅读(201) 评论(0) 推荐(0) 编辑
摘要:比如输入是192.168.80.12-15,解析成192.168.80.12、192.168.80.13、192.168.80.14、192.168.80.15; 亦或192.168.10.10-192.168.10.12,解析成192.168.10.10、192.168.10.11、192.168 阅读全文
posted @ 2019-01-08 14:47 东宫得臣 阅读(399) 评论(0) 推荐(0) 编辑
摘要:template <class DataType>void ProcessMap(std::map<std::string, std::vector<DataType> > &mymapa, std::map<std::string, std::vector<DataType> > &mymapb) 阅读全文
posted @ 2018-11-30 15:16 东宫得臣 阅读(657) 评论(0) 推荐(0) 编辑
摘要:#include <iostream>#include <vector>#include <string> class Assoc { struct Pair { std::string name; double val; Pair(std::string n="", double v=0) :na 阅读全文
posted @ 2018-09-28 20:44 东宫得臣 阅读(229) 评论(0) 推荐(0) 编辑
摘要:#include <iostream> class Singleton { static Singleton s; int i; Singleton(int x):i(x) {} Singleton& operator=(Singleton&); Singleton(const Singleton& 阅读全文
posted @ 2018-09-23 11:58 东宫得臣 阅读(110) 评论(0) 推荐(0) 编辑
摘要:复制构造函数与复制赋值的区别如下: class Name { const char* s; //... }; class Table { Name* p; size_t sz; public: //... Table(const Table&); //复制构造函数 Table& operator=( 阅读全文
posted @ 2018-09-22 20:58 东宫得臣 阅读(182) 评论(0) 推荐(0) 编辑
摘要:关联数组是用户定义类型中最常见的也是最有用的一类。关联数组也常被成为映射(map),有时被 成为字典(dictionary),其中保存的是值的对偶。给定了一个称为关键码的值,我们就能访问另一个 称为映射值的值。可以将关联数组想象为一个下标不必是整数的数组: template<class K, cla 阅读全文
posted @ 2018-09-22 17:57 东宫得臣 阅读(1854) 评论(0) 推荐(0) 编辑
摘要:#include <sys/stat.h> int stat(const char *restrict pathname, struct stat *restrict buf); struct stat { mode_t st_mode; /*file type & mode(permissions 阅读全文
posted @ 2018-09-22 10:15 东宫得臣 阅读(3823) 评论(1) 推荐(1) 编辑
摘要:template <class T1, class T2> struct std::pair { typedef T1 first_type; typedef T2 second_type; T1 first; T2 second; pair() :first(T1()), second(T2()) 阅读全文
posted @ 2018-09-07 22:13 东宫得臣 阅读(252) 评论(0) 推荐(0) 编辑
摘要:#include <functional> template <class T1, class T2, class T3>void outer_product(std::vector<T1> &inst1, std::vector<T2> &inst2, std::vector<std::vecto 阅读全文
posted @ 2018-08-29 14:50 东宫得臣 阅读(3152) 评论(0) 推荐(0) 编辑
摘要:template <class T1, class T2>double Pearson(std::vector<T1> &inst1, std::vector<T2> &inst2) { if(inst1.size() != inst2.size()) { std::cout<<"the size 阅读全文
posted @ 2018-08-26 08:59 东宫得臣 阅读(1146) 评论(0) 推荐(0) 编辑
摘要:#include <iostream>#include <vector>#include <numeric> int main() { double a[]={1, 3, 5.4}; double b[]={1, 5, 7}; std::vector<double> v_a, v_b; for(si 阅读全文
posted @ 2018-08-25 15:01 东宫得臣 阅读(182) 评论(0) 推荐(0) 编辑
摘要:#include <string>#include <iostream>#include <stack> int main() { std::string str="hello"; std::stack<char> reverse_str; std::cout<<str<<std::endl; fo 阅读全文
posted @ 2018-08-25 13:32 东宫得臣 阅读(528) 评论(0) 推荐(0) 编辑
摘要:#include <iostream>#include <fstream>#include <vector>#include <string> int main() { std::vector<std::string> v_ip; v_ip.clear(); v_ip.push_back("192. 阅读全文
posted @ 2018-08-16 20:43 东宫得臣 阅读(171) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示