摘要: #includeusing namespace std;int main(){ /* 算法--冒泡排序(实现升序) 比较相邻元素,若第一个>第二个,则交换 对每一组相邻元素执行上句操作,完成后,找到第一个最大值 ... 阅读全文
posted @ 2021-03-10 13:28 yub4by 阅读(245) 评论(0) 推荐(0)
摘要: #includeusing namespace std;int main(){ /* 数组特点: 放在一块连续内存空间中 数组中每个元素的数据类型相同 下标从0开始索引 */ //数组定... 阅读全文
posted @ 2021-03-10 13:27 yub4by 阅读(67) 评论(0) 推荐(0)
摘要: #includeusing namespace std;/* 函数的声明,作用是提前告诉编译器函数的存在 函数声明可以有多次(但一般写一次就行),函数定义只能有一次*///函数声明int get_max_1(int a, int b);//函数定义... 阅读全文
posted @ 2021-03-09 20:52 yub4by 阅读(31) 评论(0) 推荐(0)
摘要: #includeusing namespace std;/* 常见函数样式: 无参无返 有参无返 无参有返 无参无返*/// 1void test1(){ cout << "this is test1" << endl;}/... 阅读全文
posted @ 2021-03-09 20:51 yub4by 阅读(31) 评论(0) 推荐(0)
摘要: #includeusing namespace std;/* 函数定义5个要点: 返回值类型 函数名 参数列表 函数体语句 return表达式 返回值类型 函数名(参数列表){ 函数体语句 ... 阅读全文
posted @ 2021-03-09 20:50 yub4by 阅读(35) 评论(0) 推荐(0)
摘要: #includeusing namespace std;/* 综合案例:指针+数组+函数 封装一个函数,利用冒泡排序,实现对整型数组的升序排列*/void bubble_sort(int * arr, int len){ // 形参指针arr接收数... 阅读全文
posted @ 2021-03-09 20:41 yub4by 阅读(25) 评论(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 阅读(22) 评论(0) 推荐(0)
摘要: #includeusing namespace std;int main(){ /* 指针的定义和使用 */ int a = 10; //定义指针:数据类型 * 指针变量名 int * p; //让指针记录变量... 阅读全文
posted @ 2021-03-09 20:36 yub4by 阅读(38) 评论(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 阅读(27) 评论(0) 推荐(0)
摘要: 1、问题描述:设有n个程序{1,2,……,n}要存放在长度为L的磁带上。程序i存放在磁带上的长度是li(1<=i<=n)。程序存储问题要求确定这n个程序在磁带上的一个存储方案,使得能够在磁带上存储尽可能多的程序。在保证存储最多程序的前提下,还要求磁带的利用率达到最大。 2、算法设计:对于给定的n个程 阅读全文
posted @ 2019-12-08 18:09 yub4by 阅读(176) 评论(0) 推荐(0)