测试下CodeBox

872 次查看

想想以后应该用得着这个插件,毕竟有些时候还是会在博客里贴上代码的。这是插件的主页:http://wordpress.org/extend/plugins/wp-codebox/

#include <stdio.h>
double ComputePI()
{
	int segment		= 16 * 256;
	double length		= 1.0;
	double segment_width	= length / segment;
	double sum		= 0.0;
	int step 		= 0;
	double pos 		= 0.0;
 
	for (step = 0; step < segment; step++)
	{
		pos = (step + 0.5) * segment_width;
 
		sum += 4 / (1 + pos * pos);
	}
 
	sum *= segment_width;
 
	return sum;
}
 
int main(int argc, char *argv[])
{
	double pi = ComputePI();
	printf("PI is %f\n", pi);
 
	return 0;
}
1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 4.00 out of 5)
Loading ... Loading ...
2009年5月21日 | 归档于 博客, 技术
本文目前尚无任何评论.

发表评论

XHTML: 您可以使用这些标签: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">