摘要: 源程序: #include <iostream> #include <cstring> using namespace std; int main() { string s1 = "c++语言"; string s2 = "程序设计"; string s3 = s1 + s2; string s4; 阅读全文
posted @ 2019-12-02 19:45 bobo哥 阅读(129) 评论(0) 推荐(0)
摘要: 源程序: #include <iostream> #include <string> using namespace std; int main() { string str; if (str.empty()) cout << "str is NULL." << ",length=" << str. 阅读全文
posted @ 2019-12-02 19:17 bobo哥 阅读(124) 评论(0) 推荐(0)
摘要: 源程序: #include <iostream> #include <string> using namespace std; int main() { string s1, s2; s1 = "c++程序"; s2 = s1; string s3; cout << "s3=" << s3 << e 阅读全文
posted @ 2019-12-02 18:54 bobo哥 阅读(159) 评论(0) 推荐(0)
摘要: 源程序: #include <iostream> #define N 5 using namespace std; class Insert { private: int a[N]; public: Insert(int m[], int n) //构造函数初始化私有变量数组 { for (int 阅读全文
posted @ 2019-12-02 18:40 bobo哥 阅读(229) 评论(0) 推荐(0)
摘要: 源程序: #include <iostream> #define N 5 using namespace std; void insert_sort(int a[], int n) //直接插入排序 { int i, j, temp; for (i = 1; i < n; i++) { temp = 阅读全文
posted @ 2019-12-02 16:28 bobo哥 阅读(139) 评论(0) 推荐(0)
摘要: 源程序: #include <iostream> using namespace std; int bigger(int x, int y) { if (x > y) return x; else return y; } int bigger(float x, float y) { if (x > 阅读全文
posted @ 2019-12-02 15:30 bobo哥 阅读(164) 评论(0) 推荐(0)
摘要: 源程序: #include <iostream> using namespace std; int main() { int a1 = 3; const int a2 = a1; //数据a2是常量 int *a3 = &a1; //普通指针指向普通变量 const int *a4 = &a1; / 阅读全文
posted @ 2019-12-02 15:22 bobo哥 阅读(133) 评论(0) 推荐(0)
摘要: 源程序: #include <iostream> using namespace std; int oneX = 10; int oneY = 20; int &refValue(int &x) { return x; } int main() { refValue(oneX) = 30;//返回值 阅读全文
posted @ 2019-12-02 15:06 bobo哥 阅读(132) 评论(0) 推荐(0)
摘要: 源程序: #include <iostream> using namespace std; void SwapValue(int a, int b) { int tmp; tmp = a; a = b; b = tmp; cout << "在SwapValue()函数中:\t\ta=" << a < 阅读全文
posted @ 2019-12-02 11:38 bobo哥 阅读(257) 评论(0) 推荐(0)
摘要: 源程序: 各种数据类型的转换 #include <iostream> using namespace std; int main() { const int cInt = 30; int oneInt = 50; int &ref = oneInt; const int &rc1 = cInt; c 阅读全文
posted @ 2019-12-02 11:29 bobo哥 阅读(110) 评论(0) 推荐(0)
摘要: 源程序: using namespace std; int main() { int oneInt = 1; int &ref = oneInt; const int &refc = oneInt; //定义常引用 ref = 2; //修改ref也即修改了oneInt cout << "oneIn 阅读全文
posted @ 2019-12-02 11:19 bobo哥 阅读(119) 评论(0) 推荐(0)
摘要: 源程序: #include <iostream> using namespace std; void func(int a = 11, int b = 22, int c = 33) { cout << "a=" << a << ",b=" << b << ",c=" << c << endl; } 阅读全文
posted @ 2019-12-02 10:42 bobo哥 阅读(135) 评论(0) 推荐(0)
摘要: 源程序: #include <iostream> using namespace std; int main() { int a = 10; const int *p = &a; const int ca = 30; int *q; cout << "a的地址为:\t" << &a << "\ta的 阅读全文
posted @ 2019-12-02 10:35 bobo哥 阅读(139) 评论(0) 推荐(0)
摘要: 源程序: #include <iostream> #include <string> using namespace std; int main() { int oneInt1, oneInt2; char strArray[20]; string str; double oneDouble; ch 阅读全文
posted @ 2019-12-02 09:14 bobo哥 阅读(193) 评论(0) 推荐(0)