- 博客(4)
- 收藏
- 关注
原创 台阶问题求解
<br /> <br />有一楼梯共m级,刚开始时你在第一级,若每次只能跨上一级或二级,要走上第m级,共有多少走法?<br /> <br /> <br />此问题中,从第四级之后,f(n)=f(n-1)+f(n-1)<br /> <br /> #include <stdio.h> #include <stdlib.h> #include <iostream> using namespace std; int max(int a,int b) { return (a>b)?a:b; }
2011-03-16 21:04:00 362
原创 求最大公约数,最小公倍数
<br />设a为大数,b为小数<br />开始后a/b,将b放入a,得到余数放入b,继续此过程,余数为零时b中即为最大公约数<br />最小公倍数为a*b/最大公约数
2011-03-16 21:02:00 320
原创 最大连续子串和
<br />连续查找累加,并连续记录最大值,当前值,如当前值为负数则弃掉数据,跳到之后继续查找<br /> <br /> #include <stdio.h> #include <stdlib.h> int main() { int t,ti,n,ni,*num,maxnum=-200,tempsum=0,startp; scanf("%d",&t); for (ti=0;ti<t;ti++) { scanf("%d",&n); num=new int[n];
2011-03-16 21:00:00 1498
原创 C++ String的替换,查找及gets使用 OJ113
#include #include #include #include using namespace std; int main() { char temp[1100]; string sinput; while(gets(temp)!=NULL) { if (temp[0]=='/0'||temp[0]==EOF) { break; } sinput=temp; int pos=sinput.find("you"); whi
2011-03-16 17:37:00 1124
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人