赵乐ACM

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
上一页 1 ··· 5 6 7 8 9 10 11 下一页

2012年3月26日

摘要: 1.刚开始想成是整个圆了,所以一直出错;2.ceil()函数,第一次用,详见(ceil_百度百科)#include #include using namespace std; const double PI = 3.1415926; int main() { double x, y, n; cin >> n; for(int i = 1; i > x >> y; cout << "Property " << i << ": This property will begin eroding in ye 阅读全文
posted @ 2012-03-26 10:55 赵乐ACM 阅读(140) 评论(0) 推荐(0)

2012年3月22日

摘要: 1. 试了各种数据类型保存输入的字符串,比如string,字符数组。在string类型中,不能一个一个字符地拷贝字符串,因为字符串末尾还有一个字符。2. 字符型数字转换成int类型;3. 自我感觉change函数写的比较巧妙,跟Curling 2.0有点类似。是把一个数组(有重复元素)无重复的放到另外一个数组。#include #include #include #include #include using namespace std; int telnum[100010]; int tel[100010][7]; int n; struct Node { int ans; ... 阅读全文
posted @ 2012-03-22 17:48 赵乐ACM 阅读(150) 评论(0) 推荐(0)

摘要: 1.字符型数字转换成int型(http://topic.csdn.net/t/20060329/20/4649488.html) 阅读全文
posted @ 2012-03-22 17:42 赵乐ACM 阅读(105) 评论(0) 推荐(0)

摘要: 1.scanf()的用法,见百度百科;2.scanf用来接收小数,把输入变量声明为float不行,声明为double就可以了,scanf里%f不行,但是%lf就行了。#include int main() { double sum, in; int num; while(scanf("%lf", &in) != EOF) { if(in == 0.00) break; num = 1; sum = 0.5; while(sum < in) { ... 阅读全文
posted @ 2012-03-22 11:10 赵乐ACM 阅读(111) 评论(0) 推荐(0)

摘要: 1.输出2位小数,用%.2f表示。%m.nf表示输出数据共占m列,其中有n位小数,左端补齐;#include int main() { float num[12], ans = 0; for(int i = 0; i < 12; i++) { scanf("%f", &num[i]); ans = ans + num[i]; } printf("%c%.2f", '$', ans / 12); return 0; } 阅读全文
posted @ 2012-03-22 10:26 赵乐ACM 阅读(113) 评论(0) 推荐(0)

2012年3月21日

摘要: 1.做得很痛苦的题,过程清楚,也可以用语句描述出来,但是输出结果这块想不清楚;2.参考了别人的代码,跟我写的基本上差不多,只是他递归的时候传递了step,我没有传递,但是设的全局变量,为什么就不行啊??3.这样还一直出错,最后把数组开大了,开到22也不行,直到开到50才AC,为啥啊,范围不就是到20吗?#include #include #include using namespace std; int sx, sy, ans; int w, h; int dir[4][2]= {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; int map[50][50];//我... 阅读全文
posted @ 2012-03-21 23:16 赵乐ACM 阅读(121) 评论(0) 推荐(0)

2012年3月16日

摘要: 1.比迷宫问题多了一个reset按钮,算法还是BFS;2.看解题报告看了很久才看懂,当初自己卡在如何判断该不该走reset这个点;3.BFS和DFS的题的思路已经清晰,就是每道题在结束循环的条件不同,并且需要用到的变量结构不同而已;4.开始弄错横纵坐标了,以后只要保持一致就行。以下是代码,参考别人的,几乎快能背过了。。。#include #include using namespace std; struct Node { int x; int y; int remtime; int step; } begin; int map[8][8]; int mar... 阅读全文
posted @ 2012-03-16 16:44 赵乐ACM 阅读(267) 评论(0) 推荐(0)

2012年3月15日

摘要: 1.成功的使用结构体:想清楚算法需要记录哪些内容,这些内容之间有什么关系,然后再确定用单个变量还是用结构体,还是用结构体数组;2.位与&运算的使用,第一次接触这一块,还是不明白check()函数中使用&运算的道理,这一部分是借鉴来的,自己写着写着逻辑就混乱了。。。关于位运算(位运算);3.知道了typedef的用法,也算是做这道题的额外收获吧;4.这道题错了好几次,方向弄错,多加return等错误,这方面的经验还要慢慢积累;5.这道题最简单的算法是列举每一个modules,dfs找到与它连通的房间,其实和水池那道题基本类似。以下是代码:#include using namesp 阅读全文
posted @ 2012-03-15 13:05 赵乐ACM 阅读(165) 评论(0) 推荐(0)

2012年3月14日

摘要: 听了MIT的《Introduction to Algorithm》真是着迷,这里把讲过的伪代码中关于排序的实现了,总结在下边1.插入排序,n方的复杂度void insertion_sort(int arr[]) { for(int j = 1; j = 0 && key < arr[i]) { arr[i+1] = arr[i]; i--; } arr[i+1] = key; } }2.合并排序,nlog2n复杂度,代码未写 阅读全文
posted @ 2012-03-14 21:17 赵乐ACM 阅读(145) 评论(0) 推荐(0)

摘要: 1.大牛们都说是简单的DFS,想自己A一道,结果还是没A出来,最后还是看了别人的结题报告;2.递归还是不熟悉,做DFS用递归,总是出现错误。通过这个题,用递归函数,首先要包含一个结束条件,然后才能用递归;3.自己第一遍写代码的过程中,学会了用sort()函数对结构体的某一个元素进行排序的方法,参考(C/C++ sort函数的用法_真爱无限_新浪博客);4.自始至终对整道题所要用的变量没有合理的安排,之前做的稍微复杂点的题都这样,如何改进是个问题以下是代码:#include #include using namespace std; int x, y ,tstep, n; bool used.. 阅读全文
posted @ 2012-03-14 16:05 赵乐ACM 阅读(755) 评论(0) 推荐(0)

上一页 1 ··· 5 6 7 8 9 10 11 下一页