测试下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 votes, average: 4.00 out of 5)
最新评论