摘要: #includeusing namespace std;/* 函数的声明,作用是提前告诉编译器函数的存在 函数声明可以有多次(但一般写一次就行),函数定义只能有一次*///函数声明int get_max_1(int a, int b);//函数定义... 阅读全文
posted @ 2021-03-09 20:52 yub4by 阅读(19) 评论(0) 推荐(0) 编辑
摘要: #includeusing namespace std;/* 常见函数样式: 无参无返 有参无返 无参有返 无参无返*/// 1void test1(){ cout << "this is test1" << endl;}/... 阅读全文
posted @ 2021-03-09 20:51 yub4by 阅读(25) 评论(0) 推荐(0) 编辑
摘要: #includeusing namespace std;/* 函数定义5个要点: 返回值类型 函数名 参数列表 函数体语句 return表达式 返回值类型 函数名(参数列表){ 函数体语句 ... 阅读全文
posted @ 2021-03-09 20:50 yub4by 阅读(23) 评论(0) 推荐(0) 编辑
摘要: #includeusing namespace std;/* 综合案例:指针+数组+函数 封装一个函数,利用冒泡排序,实现对整型数组的升序排列*/void bubble_sort(int * arr, int len){ // 形参指针arr接收数... 阅读全文
posted @ 2021-03-09 20:41 yub4by 阅读(18) 评论(0) 推荐(0) 编辑
摘要: #includeusing namespace std;void swap1(int a, int b){ int temp = a; a = b; b = temp; cout << "swap1 a=" << a << endl; ... 阅读全文
posted @ 2021-03-09 20:39 yub4by 阅读(17) 评论(0) 推荐(0) 编辑
摘要: #includeusing namespace std;int main(){ /* 指针的定义和使用 */ int a = 10; //定义指针:数据类型 * 指针变量名 int * p; //让指针记录变量... 阅读全文
posted @ 2021-03-09 20:36 yub4by 阅读(30) 评论(0) 推荐(0) 编辑
摘要: #includeusing namespace std;int main(){ /* 指针和数组 */ int arr[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; cout << "数组第... 阅读全文
posted @ 2021-03-09 19:57 yub4by 阅读(16) 评论(0) 推荐(0) 编辑