摘要: 偶然看到一道趣味题,将一个正整数倒置过来,例如,将1234变成4321。如果采用C的话,使用do..while语句来做,只要temp不为0,每执行一次,rebmun用来存原整数的最右边的数字并乘以10。代码如下:#include<stdio.h>voidmain(){intnumber=0;intrebmun=0;inttemp=0;printf("\nEnteranumber:");scanf("%d",&number);temp=number;do{rebmun=10*rebmun+temp%10;temp=temp/10;}wh 阅读全文
posted @ 2011-08-10 18:04 牛皮糖NewPtone 阅读(1028) 评论(1) 推荐(0) 编辑
摘要: 关于该部分的项目描述请见Project2 Percolation in Grids 网格渗透 测试的场景要求如下:· set n=75 · consider values of p from 0 to 1 in increments of 0.05 (or smaller) · for each value of p, generate 10 random grids and record for each algorithm the average running time on the ten grids 可是我在编写该部分的测试代码时,遇到了些麻烦,一开始还 阅读全文
posted @ 2011-08-10 14:22 牛皮糖NewPtone 阅读(402) 评论(0) 推荐(0) 编辑
摘要: 此实验来自于part1中的具体要求:Next, consider grid sizes n = 10, 25, 50, and 75 and determine the percolation probabilities (you already know it for n=25). One way to visualize the performance for the different values of n is to make the same curve as above and show all three in one plot. Discuss how the size o. 阅读全文
posted @ 2011-08-10 13:28 牛皮糖NewPtone 阅读(810) 评论(0) 推荐(0) 编辑