摘要: Description 编写用来交换两个数的函数,使得“Append Code”中的main()函数能正确运行。 用C实现三个函数int_swap()、dbl_swap()、SWAP(),其中SWAP()是个带参宏。 用C++实现两个函数,都以Swap()命名。 以上函数的调用格式见“Append 阅读全文
posted @ 2020-06-28 21:20 Joelin12 阅读(229) 评论(0) 推荐(0)
摘要: 此题的策略是选取可用范围最右边的点,一般来说该点辐射两边,左侧辐射,右侧辐射,所以用两个循环,第一个循环找出该点,第二个循环求出最右边的点 源代码: #include<iostream>#include<algorithm>using namespace std;#define maxn 1100i 阅读全文
posted @ 2020-05-29 20:40 Joelin12 阅读(169) 评论(0) 推荐(0)
摘要: 方法:将S逆序与S正序相比较,谁小加哪个 源代码 #include<iostream>#include<iomanip>#include<cstdio>#include<cmath>#include<vector>#include<cstdlib>#include<algorithm>using n 阅读全文
posted @ 2020-05-29 18:14 Joelin12 阅读(114) 评论(0) 推荐(0)
摘要: 本题的关键是从可选择方法中选择哪一类最优化 答案是结束时间最早的一类 源代码 #include<iostream>#include<algorithm>#include<cstdio>#define maxn 100100using namespace std;struct w{ int endd, 阅读全文
posted @ 2020-05-29 13:16 Joelin12 阅读(135) 评论(0) 推荐(0)
摘要: 贪心法遵从某种规则,不断贪心优化过程,此题规则就是优先选择面值大的硬币 源代码 #include<iostream>#include<cstdio>using namespace std;int main(){ int V[]={1,5,10,50,100,500}; int num=0,money 阅读全文
posted @ 2020-05-29 11:50 Joelin12 阅读(180) 评论(0) 推荐(0)
摘要: 宽度优先搜索运用了队列(queue)在unility头文件中 源代码 #include<iostream>#include<cstdio>#include<queue>#include<algorithm>#include<utility>using namespace std;typedef pa 阅读全文
posted @ 2020-05-29 11:27 Joelin12 阅读(256) 评论(0) 推荐(0)
摘要: #include<iostream>#include<cstdio>#include<cstdlib>#define maxn 100char ch[maxn][maxn];using namespace std;int length,width;void dfs(int x,int y){ ch[ 阅读全文
posted @ 2020-05-28 11:54 Joelin12 阅读(115) 评论(0) 推荐(0)
摘要: #include<iostream>#include<stack>#define maxn 30using namespace std;stack<int>st;int n,k,a[maxn];bool dfs(int i,int sum){ if(i==k) return sum==k;//加到最 阅读全文
posted @ 2020-05-28 10:47 Joelin12 阅读(104) 评论(0) 推荐(0)
摘要: 链接:https://vjudge.net/problem/UVA-524 题意:给出正整数n,输出以1开头,由2到n组合的字符序列,使相邻的数相加为素数,最后一个(关键信息为n大于1小于等于16),于是可以枚举出来素数可能的个数,然后用set中的count判断是否有素数,这里需要用到n重循环,所以 阅读全文
posted @ 2020-05-09 14:46 Joelin12 阅读(145) 评论(0) 推荐(0)
摘要: 01-复杂度2 Maximum Subsequence Sum (25分) Given a sequence of K integers { N​1​​, N​2​​, ..., N​K​​ }. A continuous subsequence is defined to be { N​i​​, 阅读全文
posted @ 2020-05-08 09:36 Joelin12 阅读(145) 评论(0) 推荐(0)