摘要:
#include <iostream>#include <stdio.h>#include <ctype.h>#include <string>//注意c++中string库和c中的string.h库不同using namespace std;int main(){ while(1){string str;getline(cin,str);if(st... 阅读全文
posted @ 2010-04-25 20:40
北海小龙
阅读(221)
评论(0)
推荐(0)
摘要:
//主要是解题的思路//f(0) = 7//f(1) = 11//因为f(n)要模3,所以我先将f(0)和f(1)模的3,所以现在是//f(0) = 7 % 3 = 1//f(1) =11 % 3 = 2//f(3) = 3 % 3 = 0//f(4) = 2 % 3 = 2//f(5) = 2 % 3 = 2//f(6) = 4 % 3 = 1//f(7) = 3 % 3 = 0//f(8) =... 阅读全文
posted @ 2010-04-25 20:39
北海小龙
阅读(420)
评论(0)
推荐(0)
摘要:
//求阶乘的位数//方法:使用10的对数解决#include <iostream>#include <math.h>using namespace std;int main(){int count;cin>>count;while(count--){int number;cin>>number;double sum = 0;for(int i = 1... 阅读全文
posted @ 2010-04-25 20:39
北海小龙
阅读(262)
评论(0)
推荐(0)
摘要:
#include <iostream>using namespace std;int main(){int number;cin>>number;//cout<<endl;注意此处一定不要加endl,否则会出现格式错误的警告。int n,m;for(int i=0;i<number;i++){int j = 0;cin>>n>>m;... 阅读全文
posted @ 2010-04-25 20:38
北海小龙
阅读(223)
评论(0)
推荐(0)
摘要:
//注意:尽量使用C++的string类型,而不要使用c字符串数组#include <iostream>#include <string>using namespace std;int digit_sum(int digit);int main(){string digit;cin>>digit;//这里读入的是string类型,不是int类型,便于求各个位数和... 阅读全文
posted @ 2010-04-25 20:37
北海小龙
阅读(305)
评论(0)
推荐(0)
摘要:
//思路:使用周期实现,周期的开始不一定从头开始#include <iostream>using namespace std;int main(){int a,b;long n;while(cin>>a>>b>>n && (a+b+n)!=0){int result[200] = {0,1,1};if(n<3){cout<... 阅读全文
posted @ 2010-04-25 20:37
北海小龙
阅读(296)
评论(0)
推荐(0)
摘要:
#include <iostream>#include <vector>#include <string>using namespace std;//使用结构体实现typedef struct{string color;int time;}balloon;vector<balloon> balloons;void popular_color();vo... 阅读全文
posted @ 2010-04-25 20:36
北海小龙
阅读(130)
评论(0)
推荐(0)
摘要:
//求最小公倍数//思路:先求两个数的最小公倍数,前两个数的最小公倍数与第三个数再求最小公倍数,求出最小公倍数后接着与第四个数相求。//求两个数的最小公倍数:利用辗转相除法#include <iostream>using namespace std;int gcd(int a,int b);int main(){ int row,col;cin>>row;for(int i... 阅读全文
posted @ 2010-04-25 20:35
北海小龙
阅读(406)
评论(0)
推荐(0)
摘要:
//整数划分问题 思路:见《算法分析与设计》12页//注:使用递归会出现超时的情况,所以本程序将递归改成迭代的形式#include <iostream>using namespace std;int main(){int a[121][121]; //a[i][j]代表整数i最大数不超过jfor(int n=1;n<121;n++){for(int m=1;m<n+1;m+... 阅读全文
posted @ 2010-04-25 20:33
北海小龙
阅读(461)
评论(0)
推荐(0)
摘要:
//Prim算法求最小生成树#include <iostream>using namespace std;#define arraysize 501int maxData = 0x7fffffff;//设定最大值int dis[arraysize][arraysize];bool final[arraysize];int d[arraysize];int N;void prim(){i... 阅读全文
posted @ 2010-04-25 20:31
北海小龙
阅读(149)
评论(0)
推荐(0)
浙公网安备 33010602011771号