2024年3月11日
摘要: 用到的命令: echo 输出字符串 tr 常用于处理字符串间隔,例如将空格分割替换为逗号分割;删除多个连续的空格等等 sed 也是用于字符串处理。如字符串替换,也可做字符串删除 awk 也用于字符串处理。如将字符串按照空格等分隔符,分成好几列,按需输出某一列的值;字符计数,统计次数;复杂的字符串处理 阅读全文
posted @ 2024-03-11 15:29 进取 阅读(25) 评论(0) 推荐(0) 编辑
  2022年10月26日
摘要: 实现文件写入 #include<iostream> #include<fstream> using namespace std; void main() { fstream wfs("test5.txt", ios::out); if(!wfs) cout << "打开文件失败" << endl; 阅读全文
posted @ 2022-10-26 21:34 进取 阅读(18) 评论(0) 推荐(0) 编辑
摘要: #include<iostream> using namespace std; void main() { // 功能: 计算 中文在内存占用的字节数 char name[] = "成都"; char node_name[] = "成都移动04节点"; cout << "int占用:" << siz 阅读全文
posted @ 2022-10-26 21:17 进取 阅读(46) 评论(0) 推荐(0) 编辑
摘要: 闰年计算方法: 能被400整除。 能被4整除,不能被100整除。 #include<iostream> using namespace std; class Sample { private: int x; public: Sample() {} Sample(int a) {x=a;} void 阅读全文
posted @ 2022-10-26 21:08 进取 阅读(43) 评论(0) 推荐(0) 编辑
摘要: #include<iostream> using namespace std; const double Pi = 3.14; class Shape { public: virtual void draw() = 0; }; class Cicle:public Shape { public: v 阅读全文
posted @ 2022-10-26 21:04 进取 阅读(22) 评论(0) 推荐(0) 编辑
摘要: #include<iostream.h> class mix { public: mix(); friend mix operator+(mix &c1,mix &c2); void input(); void display(); private: int m[2][3]; }; mix::mix 阅读全文
posted @ 2022-10-26 20:58 进取 阅读(69) 评论(0) 推荐(0) 编辑
摘要: #include<iostream> using namespace std; class Complex { public: Complex() {real=0;imag=0;} Complex(double r,double i) {real=r;imag=i;} double get_real 阅读全文
posted @ 2022-10-26 20:48 进取 阅读(14) 评论(0) 推荐(0) 编辑
摘要: #include<iostream> using namespace std; class goods { public: goods() {total =0;} void get_toal() { cout << "当前货物总量 total = " << total << endl; } doub 阅读全文
posted @ 2022-10-26 20:47 进取 阅读(14) 评论(0) 推荐(0) 编辑
摘要: 引用 在c++中,我们有一种比传递指针更加高效的方式,那就是引用(Reference)。 引用类似于windows环境下的快捷方式,通过快捷方式和可执行程序本身都可以运行程序。 引用的定义方式类似于指针,只不过使用的 "&" 代替了 "*" 。 void main() { int a = 9; in 阅读全文
posted @ 2022-10-26 20:38 进取 阅读(27) 评论(0) 推荐(0) 编辑
摘要: #include<iostream> using namespace std; //用模板实现两个数值交换 template<class T> void tswap( T *x, T *y) { int temp = *x; *x = *y; *y = temp; } void main() { i 阅读全文
posted @ 2022-10-26 20:29 进取 阅读(32) 评论(0) 推荐(0) 编辑