摘要: #include <stdio.h>#include <stdlib.h>#include <memory.h>char srcR[7], srcn[3];//string length, +1int dstR[5], dstn[2], point, n;//point记录小数点位置,n记录dstn的int形式;int ans[200], result[200];int main(){ while (1) { if (scanf("%s", srcR) == EOF) break; getchar(); scanf... 阅读全文
posted @ 2011-09-15 22:07 SunnyDay2015 阅读(248) 评论(0) 推荐(0) 编辑
摘要: /*总结:1.float的精度是6位有效数字,取值范围是10的-38次方到10的38次方,float占用4字节空间 double的精度是15位有效数字,取值范围是10的-308次方到10的308次方,double占用8字节空间。 浮点数相等判断; const float EPSINON = 0.00001; if ((x >= - EPSINON) && (x <= EPSINON) 大于小于直接比较 2.不要将数量级相差较大的两个浮点数相加,也不可将两个相近的浮点数相减*/#include <stdio.h>#include <ma... 阅读全文
posted @ 2011-09-14 21:10 SunnyDay2015 阅读(310) 评论(0) 推荐(0) 编辑
摘要: /*总结: 1.不要忘了溢出 2.单独处理最高位的加法更容易些。summary: 1.The overflow of addition of large numbers should be noticed. 2.It's easier to deal with the highest bit when adding,I think.*/#include <stdio.h>#include <string.h>#include <memory.h>int main(){ char srca[1000], srcb[1000]; int dsta[... 阅读全文
posted @ 2011-09-14 14:53 SunnyDay2015 阅读(370) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>using namespace std;int main(){ int array[21][21][21]; for (int i=0; i<=20; i++) { for (int j=0; j<=20; j++) { for (int k=0; k<=20; k++) { if (i == 0 || j == 0 || k == 0) { array[i][j][k] ... 阅读全文
posted @ 2011-09-05 12:34 SunnyDay2015 阅读(312) 评论(0) 推荐(0) 编辑
摘要: #include <iostream>#include <memory.h>using namespace std;int weight[101][101], dis[101], pi[101];int visit[101] = {0};int minTime = 10000, vertexNum = 0;void input(){ int p = 0, cost = 0; for (int j=1; j<=vertexNum; j++) { cin >> weight[j][0]; for (int i=1; i<=weight[j][0]; 阅读全文
posted @ 2011-09-03 20:18 SunnyDay2015 阅读(235) 评论(0) 推荐(0) 编辑
摘要: #include<cstdio>#include<cstring>char c[50];int i,l;double x,y;int main(){ while(scanf("%s",c)!=EOF) { printf("%s [8] = ",c); l=strlen(c)-1; x=0; y=1; for(i=l;i>1;i--) { x=((c[i]-'0')*y+x)*125; y*=1000; } x/=y; i=0; while(x) { c[i]=int(x*=10)%10+'0' 阅读全文
posted @ 2011-09-03 19:50 SunnyDay2015 阅读(373) 评论(0) 推荐(0) 编辑
摘要: 这道题我用的是Bellman Ford算法,用其他的最短路径算法(Floyd、Dijstra)也可。#include <iostream>#include <memory.h>using namespace std;int weight[101][101];int dis[101];int pi[101];int minTime = 10000;//最多有 100 * (100-1) 条边,每个边有两个节点int edgeStack[100 * (100-1) * 2];//Index 首字母大写,因为 index 在函数库中另有含义 int Index = 0; .. 阅读全文
posted @ 2011-08-31 18:00 SunnyDay2015 阅读(211) 评论(0) 推荐(0) 编辑
摘要: 其实书上写很清楚了,只是写一下自己的理解备忘,没什么技术含量。拓扑排序: TOPOLOGICAL-SORT(G) 可为有向无环图产生其拓扑排序,要证明这个算法的正确性,只要证对于任意边 (u,v),有 f[v] < f[u]。因为在TOPOLOGICAL-SORT(G)算法中,总是令 f 值较大的点排在队列的前面,即“去除”(并不是真的删掉)那些 f 值较大的点。首先,当探索到 (u,v) 这条边时,v 一定不为灰色。首先,因为 u 为灰色,所以 v 一定不为灰色。再者,若 v 为白色,那么它是 u 的后续节点,有 f[v] < f[u];如果 v 是黑色的,显然有 f[v] &l 阅读全文
posted @ 2011-08-25 20:28 SunnyDay2015 阅读(930) 评论(0) 推荐(0) 编辑
摘要: 参考这篇博文:http://blog.csdn.net/danny_xcz/article/details/3332251步骤:1.在官网下载一个CodeBlocks(带mingw的版本);2.配置编译器,在Selected Compiler选项中选GNU GCC Compiler ;3.填写编译参数,Compiler Setting里的Other Options中粘贴-fopenmp ;4.填写连接参数,Link Setting里的Other Options中粘贴-lgomp -lpthread ;5.建立并运行所参考博文所写的程序。如果运行时出现libgomp-1.dll丢失的问题而不能运 阅读全文
posted @ 2011-07-27 16:53 SunnyDay2015 阅读(4213) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h>#include <stdlib.h>#include <string.h>using namespace std;const int baseLength = 6;const int MAX = 200;char a[baseLength]={0}; //base///不要思维定势地以为b也要用字符数组来保存///Don't think b as array,a integer type is enoughint b = 0; //indexint c[MAX] = {0}; ... 阅读全文
posted @ 2011-07-06 18:39 SunnyDay2015 阅读(539) 评论(0) 推荐(0) 编辑