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

记录下学习的点滴
摘要:#include <stdio.h> void inplace_swap(int *x, int *y) { printf(" \n"); printf("x = %d, y = %d\n", *x, *y); *y = *x ^ *y; printf("x = %d, y = %d\n", *x, 阅读全文
posted @ 2024-01-16 18:40 东宫得臣 阅读(16) 评论(0) 推荐(0) 编辑
摘要:#include <stdio.h> #include <stack> int main() { std::stack<char> s; int num, mod; printf("输入十进制数: \n"); scanf("%d", &num); printf("num: %d\n", num); 阅读全文
posted @ 2024-01-16 11:47 东宫得臣 阅读(89) 评论(0) 推荐(0) 编辑
摘要:函数体与函数调用相联系称为捆绑。晚捆绑又称为动态捆绑或运行时捆绑。为了引起晚捆绑,c++要求在基类中声明这个函数时使用virtual关键字。 不把析构函数设为虚函数是一个隐匿的错误,因为它常常不会对程序有直接的影响。但会不知不觉地引入存储器泄露。 #include <iostream> #inclu 阅读全文
posted @ 2021-07-15 10:55 东宫得臣 阅读(78) 评论(0) 推荐(0) 编辑
摘要:#include <iostream> #include <sstream> #include <algorithm> #include <iterator> #include <cmath> template<class T> struct chainNode{ T element; chainN 阅读全文
posted @ 2021-07-08 13:09 东宫得臣 阅读(46) 评论(0) 推荐(0) 编辑
摘要:void f(vector<string>& v, int i, const char *p) { if(p == nullptr) return; if(i<0 || v.size()<=i) error("bad index."); string s = v[i]; if(s == p) { / 阅读全文
posted @ 2021-07-04 21:31 东宫得臣 阅读(71) 评论(0) 推荐(0) 编辑
摘要:#include <iostream> int main() { int v[] = {1, 2, 3, 4, 5}; for(auto& x:v) std::cout<<x<<" "; std::cout<<std::endl; return 0;} We use auto where we do 阅读全文
posted @ 2021-07-04 17:44 东宫得臣 阅读(139) 评论(0) 推荐(0) 编辑
摘要:用函数原型,在声明和定义一个函数时,必须使用参数类型描述。这种描述就是“原型”。 调用函数时,编译器使用原型确保正确传递参数并且正确地处理返回值。如果调用函数时程序 员出错了,编译器就会捕获这个错误。在函数原型中,参数表包含了应当传递给函数的参数类型 和参数的标识符(对声明而言可以是任选的)。参数的 阅读全文
posted @ 2021-07-04 15:53 东宫得臣 阅读(547) 评论(0) 推荐(0) 编辑
摘要:#include <iostream> #include <algorithm> #include <string> #include <vector> int main() { std::string str; while(std::cin>>str) { std::vector<char> v_ 阅读全文
posted @ 2019-11-27 13:58 东宫得臣 阅读(804) 评论(0) 推荐(0) 编辑
摘要:#include <iostream> #include <vector> int main() { enum {size = 4}; std::vector<int> num(size); size_t i=0; while(std::cin>>num.at(i++)) { if(i == siz 阅读全文
posted @ 2019-11-24 13:34 东宫得臣 阅读(339) 评论(0) 推荐(0) 编辑
摘要:#include <iostream> int main() { int num; while(std::cin>>num) { int mod, left, sum=0; left = num % 3; while(num/3) { mod = num / 3; left = num % 3; s 阅读全文
posted @ 2019-11-23 01:24 东宫得臣 阅读(1550) 评论(0) 推荐(0) 编辑
摘要:#include <iostream> #include <string> #include <cmath> int main() { std::string hex; while(std::cin>>hex) { int sum=0, flag=0; for(std::string::const_ 阅读全文
posted @ 2019-11-23 00:08 东宫得臣 阅读(3737) 评论(2) 推荐(0) 编辑
摘要:#include <iostream> #include <set> int main() { int n; std::set<int> i_set; while(std::cin>>n) { i_set.clear(); int data_in; for(size_t i=0; i<n; ++i) 阅读全文
posted @ 2019-11-21 14:12 东宫得臣 阅读(191) 评论(0) 推荐(0) 编辑
摘要:#include <iostream> #include <vector> #include <algorithm> int main() { int N, M; while(std::cin>>N>>M) { std::vector<int> v_data; v_data.clear(); for 阅读全文
posted @ 2019-11-20 23:14 东宫得臣 阅读(1225) 评论(0) 推荐(0) 编辑
摘要:#include <iostream> #include <sstream> #include <fstream> #include <algorithm> #include <vector> void Conv(std::vector<std::vector<int> > &vv_image, s 阅读全文
posted @ 2019-09-06 11:33 东宫得臣 阅读(447) 评论(0) 推荐(0) 编辑
摘要:#include <iostream> #include <string> #include <vector> #include <cmath> int hex2int(const std::string &hex) { std::string::const_reverse_iterator rit 阅读全文
posted @ 2019-08-30 19:33 东宫得臣 阅读(1105) 评论(0) 推荐(0) 编辑
摘要:#include <iostream> #include <iterator> #include <vector> #include <cstddef> #include <string> #include <sstream> #include <fstream> #include <algorit 阅读全文
posted @ 2019-07-03 20:39 东宫得臣 阅读(236) 评论(0) 推荐(0) 编辑
摘要:#include <iostream>#include <vector>#include <cmath>#include <algorithm>#include <numeric>#include <fstream>#include <sstream>#include <functional> do 阅读全文
posted @ 2019-06-21 01:28 东宫得臣 阅读(385) 评论(0) 推荐(0) 编辑
摘要:#include <iostream> #include <vector> #include <cmath> #include <algorithm> #include <numeric> double myfunction(double num) { return exp(num); } temp 阅读全文
posted @ 2019-06-19 09:55 东宫得臣 阅读(1727) 评论(0) 推荐(0) 编辑
摘要:#include <iostream> #include <vector> #include <cstddef> #include <string> #include <sstream> #include <fstream> #include <algorithm> #include <cmath> 阅读全文
posted @ 2019-06-18 13:58 东宫得臣 阅读(288) 评论(0) 推荐(0) 编辑
摘要:void ReadDataFromCsv(std::string &filename, std::vector<std::vector<std::string> > &lines_feat) { std::ifstream vm_info(filename.c_str()); std::string 阅读全文
posted @ 2019-06-17 13:31 东宫得臣 阅读(440) 评论(0) 推荐(0) 编辑

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