摘要: 今天有沙老师的好朋友给我们讲了一些算法方面的东西。几个关键词:组合方法(解线性方程等)、数值算法、优化方法(动态规则变化问题)、图论。还提了一些问题。等把动态变化都再掌握多一点之后,要查查相关的资料。记录在草稿纸上。总之,算法很多、深;学好算法课,走遍天下都不怕! 阅读全文
posted @ 2013-07-20 11:57 开心成长 阅读(111) 评论(0) 推荐(0) 编辑
摘要: 1、我也发现,自己理解问题的能力不强,而且急于给出自己自认为正确的答案。改正的方法:每次听人家讲完一个问题,别急着插嘴,好好把问题理解清楚,不清楚的一定先把问题问清楚,问清楚环境; 尝试给出自己的答案,但一定记着戒慎恐惧,不要认为自己的想法就是对的;2、关于算法设计这一块儿,我也有同样的问题。我总是只考虑给出的特殊情形,然后掌握不到问题的核心,根据具体的事例来设计算法,每次遇到新的事例时就解决不了。算法的漏洞很大。改正的方法:先长时间思考,学会思考并掌握问题的实质,以及可能的解决方法有哪几种,不要急着写; 每次写完一个算法,可以让师兄帮我看一下;3、另外,我自己需要增强的还有逻辑能力,沙老师平 阅读全文
posted @ 2013-07-19 19:58 开心成长 阅读(180) 评论(0) 推荐(0) 编辑
摘要: 1、有x美分钱,用1美分、5美分、10美分、25美分来组合,有多少种组合方式:用方式i,表示可以选择前i种美分;用j表示可以组合成j美分;用T(i,j)表示在可以选择前i种美分时,组合成j美分的组合方式;建表如下:1510152025303540451(1美分)11111111112(1、5美分)123456789103(1、5、10美分)1246912162025304(1、5、10、25)124691318243139注意:1) 像2、3、4和1;或者6、7、8、9和5,都可以视为相同。6、7、8、9只是在5的基础上多加了几张一美分的,在决策表中就是重复。如果一个数不能被5整除,则比它小的 阅读全文
posted @ 2013-07-19 17:26 开心成长 阅读(251) 评论(0) 推荐(0) 编辑
摘要: #includeusing namespace std; void Foo1(int arr[3]) { cout << "pass by pointer: " << sizeof(arr) << endl; } void Foo2(int (&arr)[3]) { cout << "pass by reference: " << sizeof(arr) << endl; } void Foo3(int *arr) { cout << "pass by 阅读全文
posted @ 2013-07-18 20:51 开心成长 阅读(412) 评论(0) 推荐(0) 编辑
摘要: 1、阶乘#includeusing namespace std;int fac(int n){ int result=1; if(n>n; cout<<fac(n)<<endl; return 0;}输入5;输出2、3、4、5、120 阅读全文
posted @ 2013-07-18 20:13 开心成长 阅读(217) 评论(0) 推荐(0) 编辑
摘要: /*PROB:beadsLANG:C++*/#include#include#include #include #includeusing namespace std;string strReverse(string str1){ int len=str1.size(); string str2=str1; char *end=&str1[0]+len-1; for(int i=0;i&str1[0]){ str2[i]=end[0]; end--; } else if(end==&str1[0])... 阅读全文
posted @ 2013-07-18 11:02 开心成长 阅读(419) 评论(0) 推荐(0) 编辑
摘要: #includeusing namespace std;int first_maxLen(string newstr){ int i=0; int n=newstr.size(); int temp_len=0; char br=' '; if(newstr[0]=='w'){ while(i<n){ if(newstr[i]=='w' || newstr[i]==br){ temp_len++; i++; continue; ... 阅读全文
posted @ 2013-07-17 20:09 开心成长 阅读(207) 评论(0) 推荐(0) 编辑
摘要: #includeusing namespace std;int maxLen(string newstr){ int i=0; int max_len=0; int n=newstr.size(); while(i<n){ int temp_len=0; char br=' '; while(i<n){ if(newstr[i]=='w' || newstr[i]==br){ temp_len++; i++; cont... 阅读全文
posted @ 2013-07-15 11:34 开心成长 阅读(350) 评论(0) 推荐(0) 编辑
摘要: #include#includeusing namespace std;string strReverse(string str1){ int len=str1.size(); string str2=str1; char *end=&str1[0]+len-1; for(int i=0;i=&str1[0]){ str2[i]=end[0]; end--; } return str2;}int main(){ cout>str; string newstr=""; newstr=strR... 阅读全文
posted @ 2013-07-14 19:26 开心成长 阅读(218) 评论(0) 推荐(0) 编辑
摘要: /*PROB:fridayLANG:C++*/#include#includeusing namespace std;const int MAXINPUT=400;const int MONTHS=12;int main(){ int myday[MAXINPUT*MONTHS]; myday[0]=6; int count[7]={0}; int year=1900; int month; int n; ifstream ifs("friday.in"); ofstream ofs("friday.out"); ifs>>n; fo... 阅读全文
posted @ 2013-07-14 11:35 开心成长 阅读(269) 评论(0) 推荐(0) 编辑