<?xml version="1.0" encoding="utf-8"?><rss version="2.0">
<channel>
<title><![CDATA[黑心虎]]></title>
<link>http://blog.pfan.cn/2588</link>
<description>编程爱好者博客</description>
<language>zh-cn</language>
			<item>
		<title><![CDATA[&nbsp;博客搬家了！！！！]]></title>
		<link>http://blog.pfan.cn/2588/25941.html</link>
		<description><![CDATA[博客搬家了！！！！
 本人博客已搬至：http://yhbspace.blog.163.com
 欢迎各位去坐坐，
 愿与广大C++爱好者一同学习
 同时本人还创建一个C++爱好者的圈子
 里面可有众多高手！]]></description>
		<author><![CDATA[2588]]></author>
		<pubDate>2007-05-16 11:20:00</pubDate>
		</item>
				<item>
		<title><![CDATA[c++入门实例之循环与判断三]]></title>
		<link>http://blog.pfan.cn/2588/24005.html</link>
		<description><![CDATA[求100至200之间的所有素数。素数即不能被&nbsp;&nbsp; 2——其2次方根√m&nbsp;&nbsp; 中的任一个整数整除。
#include&lt;iostream&gt;#include&lt;cmath&gt;using namespace std;int main(){&nbsp;int m,k,s;&nbsp;for(m=101;m&lt;200;m+=2)&nbsp;{&nbsp;&nbsp; s=sqrt(m);&nbsp;&nbsp; for(k=2;k&lt;=s;k++)&nbsp;&nbsp; {&nbsp;&nbsp;&nbsp; if(m%k==0)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;&nbsp;&nbsp; }&nbsp; if(m%k!=0)&nbsp;&nbsp;&nbsp; cout&lt;&lt;m&lt;&lt;"&nbsp; ";&nbsp;}&nbsp;return 0;}]]></description>
		<author><![CDATA[2588]]></author>
		<pubDate>2007-03-16 17:10:00</pubDate>
		</item>
				<item>
		<title><![CDATA[母牛生小牛问题]]></title>
		<link>http://blog.pfan.cn/2588/24002.html</link>
		<description><![CDATA[&nbsp;&nbsp;&nbsp; 前段时间看钱能的C++程序设计教程，有一个母牛生小牛问题：有一头母牛，从出生第四年起，每一年都生一头小母牛，以此类推，第N年时共有多少头母牛。&nbsp;&nbsp;&nbsp; 这应该也是一个Fibonacci数，和我的另一篇文章母兔生小兔基本一样（http://blog.programfan.com/trackback.asp?id=24000）只是算法有点出入，规律应该是：年份&nbsp;&nbsp;&nbsp;&nbsp;小牛&nbsp;&nbsp;&nbsp;&nbsp;中牛&nbsp;&nbsp;&nbsp;&nbsp;老牛&nbsp;&nbsp;&nbsp;&nbsp;总头数1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 12&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;13&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;14&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp]]></description>
		<author><![CDATA[2588]]></author>
		<pubDate>2007-03-16 15:20:00</pubDate>
		</item>
				<item>
		<title><![CDATA[C++入门实例之编程初步二]]></title>
		<link>http://blog.pfan.cn/2588/24000.html</link>
		<description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 这是一个古老的数学问题，有一对免子，从出生第三个月起每个月都生一对兔子，假如兔子都不死的话，求每个月兔子的总对数。这实际上是一个Fibonacci数，即前两个数是1，第三个数起，其后的每个数都是前面两个数之和。即：1&nbsp;&nbsp;&nbsp; 1&nbsp;&nbsp;&nbsp; 2&nbsp;&nbsp;&nbsp; 3&nbsp;&nbsp;&nbsp; 5&nbsp;&nbsp;&nbsp; 8&nbsp;&nbsp;&nbsp; 13......因此可用递归算法实现：
#include&lt;iostream&gt;#include&lt;iomanip&gt;using namespace std;int main(){&nbsp; long f1=1,f2=1;&nbsp; for(int i=1;i&lt;=10;i++)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //求20个月时每个月兔子的总对数&nbsp;&nbsp; {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cout&lt;&lt;setw(16)&lt;&lt;f1&lt;&lt;setw(16)&lt;&lt;f2;&nbsp;&nbsp;&nbsp; //每次输出两个月&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;f1=f1+f2;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;f2=f2+f1;&nbsp;&nbsp;&nbsp; }&nbsp; return 0;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 如果要实现某一个月的兔子的总对数，可用函数的递归调用：
#include&lt;iostream&gt;#include&lt;iomanip&gt;using namespace std;int main(){&nbsp; long fac(int );&nbsp; cout&lt;&lt;"输入要查询的月份：";&nbsp; int n;&nbsp; cin&gt;&g]]></description>
		<author><![CDATA[2588]]></author>
		<pubDate>2007-03-16 14:44:00</pubDate>
		</item>
				<item>
		<title><![CDATA[c++入门实例之循环与判断二]]></title>
		<link>http://blog.pfan.cn/2588/23999.html</link>
		<description><![CDATA[二、求PI的值。PI/4=1-1/3+1/5-1/7+1/9......直至最后一项的绝对值小于10的负17次方（即1E-7）。我看钱能的书上有不止一种算法，但我也是初学，所以在此只列出一种最简单的算法。&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 本文旨在掌握for循环与while循环的使用。1、用for循环实现：
#include&lt;iostream&gt;#include&lt;cmath&gt;&nbsp;&nbsp;&nbsp;&nbsp; //由于要用到绝对值函数fabs()，故包含此头文件#include&lt;iomanip&gt;&nbsp;&nbsp; //格式化输出using namespace std;int main(){&nbsp;int s=1;double n=1,m,t=0;for(m=1;fabs(n)&gt;1e-7;m+=2,n=s/m)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //m在循体内完成初始化{&nbsp; t=t+n;&nbsp; s=-s;}cout&lt;&lt;setiosflags(ios::fixed)&lt;&lt;setprecision(8);cout&lt;&lt;"pi="&lt;&lt;4*t&lt;&lt;endl;return 0;}
2、用while循环实现，只需修改循环体即可：
#include&lt;iostream&gt;#include&lt;cmath&gt;&nbsp;&nbsp;&nbsp;&nbsp; //由于要用到绝对值函数fabs()，故包含此头文件#include&lt;iomanip&gt;&nbsp;&nbsp; //格式化输出using namespace std;int main(){&nbsp;int s=1;double n=1,m=1,t=0;&nbsp;&nbsp;&nbsp; //此处要对m进行初始化为1while(fabs(n)&gt;1e-7){&nbsp; t=t+n;&nbsp; s=-s;&nbsp; m+=2;&nbsp; n=s/m;}cout&lt;&lt;setiosflags(ios::fixed)&lt;&lt;setprecision(8);c]]></description>
		<author><![CDATA[2588]]></author>
		<pubDate>2007-03-16 13:52:00</pubDate>
		</item>
				<item>
		<title><![CDATA[c++入门实例之循环与判断一]]></title>
		<link>http://blog.pfan.cn/2588/23997.html</link>
		<description><![CDATA[一、一运输公司要对用户计算运费，假设每吨每公里的价格为P，货物重量为W，路程为S，折扣为D，其运费计算标准如下：
&nbsp;&nbsp;&nbsp; 路程：s&lt;250&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 折扣：d=0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 250&lt;=s&lt;500&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; d=0.02&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 500&lt;=s&lt;1000&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; d=0.05&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1000&lt;=s&lt;2000&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;d=0.08&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb]]></description>
		<author><![CDATA[2588]]></author>
		<pubDate>2007-03-16 11:00:00</pubDate>
		</item>
				<item>
		<title><![CDATA[C++入门实例之编程初步一]]></title>
		<link>http://blog.pfan.cn/2588/23980.html</link>
		<description><![CDATA[一、求一元二次方程 ax2+bx+c=0 的根:#include&lt;iostream&gt;#include&lt;cmath&gt;#include&lt;iomanip.h&gt;using namespace std;int main(){&nbsp;float a,b,c;&nbsp;float x1,x2;&nbsp;cout&lt;&lt;"请输入a,b,c的值：";&nbsp;cin&gt;&gt;a&gt;&gt;b&gt;&gt;c;&nbsp;float t=b*b-4*a*c;&nbsp;if(t&lt;0)&nbsp;&nbsp; cout&lt;&lt;"此方程无实根."&lt;&lt;endl;&nbsp;else&nbsp; {&nbsp;&nbsp;&nbsp; x1=(-b+sqrt(t))/(2*a);&nbsp;&nbsp;&nbsp; x2=(-b-sqrt(t))/(2*a);&nbsp;&nbsp;&nbsp; cout&lt;&lt;setiosflags(ios::fixed)&lt;&lt;setiosflags(ios::right);&nbsp;&nbsp;&nbsp; cout&lt;&lt;setprecision(4);&nbsp;&nbsp;&nbsp; cout&lt;&lt;"x1= "&lt;&lt;x1&lt;&lt;endl;&nbsp;&nbsp;&nbsp; cout&lt;&lt;"x2= "&lt;&lt;x2&lt;&lt;endl;&nbsp; }&nbsp;return 0;}二、判别某一年是否为闰年，满足闰年的条件是：1、能被4整除而不能被100整除，2、能同时被100和400整除。#include&lt;iostream&gt;using namespace std;int main(){&nbsp; int year;&nbsp; cout&lt;&lt;"请输入要查询的年份：";&nbsp; cin&gt;&gt;year;&nbsp; if((year%4==0 &amp;&amp; year%100!=0)||(year%400==0))&nbsp;&nbsp; cout&lt;&lt;year&lt;&lt;"是闰年"&lt;&lt;endl;&nbsp; els]]></description>
		<author><![CDATA[2588]]></author>
		<pubDate>2007-03-15 14:03:00</pubDate>
		</item>
				<item>
		<title><![CDATA[C++入门实例之数据类型与表达式]]></title>
		<link>http://blog.pfan.cn/2588/23977.html</link>
		<description><![CDATA[一、阅读以下代码，观察输出结果，通过此段代码，可进一步认识&nbsp;&nbsp;&nbsp; C++中复合&nbsp;&nbsp;&nbsp; 运算符的应用。&nbsp;&nbsp;&nbsp; #include&lt;iostream&gt;&nbsp;&nbsp;&nbsp; using namespace std;&nbsp;&nbsp;&nbsp; int main()将&nbsp;&nbsp;&nbsp; {&nbsp;&nbsp;&nbsp;&nbsp; int i,j,m,n;&nbsp;&nbsp;&nbsp;&nbsp; i=8;&nbsp;&nbsp;&nbsp;&nbsp; j=10;&nbsp;&nbsp;&nbsp;&nbsp; m=++i+j++;&nbsp;&nbsp;&nbsp;&nbsp; n=(++i)+(++j)+m;&nbsp;&nbsp;&nbsp;&nbsp; cout&lt;&lt;i&lt;&lt;'\t'&lt;&lt;j&lt;&lt;'\t'&lt;&lt;m&lt;&lt;'\t'&lt;&lt;n&lt;&lt;endl;&nbsp;&nbsp;&nbsp;&nbsp; return 0;&nbsp;&nbsp;&nbsp;&nbsp; }&nbsp;&nbsp;&nbsp; 通过运行，其输出应为：10&nbsp;&nbsp;&nbsp; 12&nbsp;&nbsp;&nbsp; 19&nbsp;&nbsp;&nbsp; 41二、将“China”设为密码，用原来字母后的第四个字母代替原来的
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 字母，如：A后的第四个字母是E，用E代替A，因此“China”
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 应译为&nbsp; “Gimre” ,编程实现：&nbsp;&nbsp;&nbsp; #include&lt;iostream&gt;&nbsp;&nbsp;&nbsp; using namespace std;&nbsp;&nbsp;&nbsp; int main()&nbsp;&nbsp;&nbsp; { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; char c1,c2,c3]]></description>
		<author><![CDATA[2588]]></author>
		<pubDate>2007-03-15 11:46:00</pubDate>
		</item>
				<item>
		<title><![CDATA[中国老百姓的顺口溜(转)]]></title>
		<link>http://blog.pfan.cn/2588/23976.html</link>
		<description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 这年头，警察脾气特横，说打就打，说骂就骂，越看越像流氓；流氓啥事都管，组织纪律性不断提高，越看越像警察。你能分得清，谁是警察，谁是流氓吗？ &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 这年头，官员小手常伸，得拿就拿，得搂就搂，越看越像小偷；小偷衣冠楚楚，风度翩翩教养十足，越看越像官员。你能分得清，谁是官员，谁是小偷吗？ &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 这年头，明星时常犯贱，今天卖给他，明天卖给你，越看越像妓女；妓女时尚新潮，风情万种楚楚动人，越看越像明星。你能分得清，谁是明星，谁是妓女吗？ 



&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 这年头，导演生性风流，玩了这个，再玩那个，越看越像色狼；色狼和蔼可亲，循循善诱诲人不倦，越看越像导演。你能分得清，谁是导演，谁是色狼吗？ &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 这年头，学者专门溜须，上面说什么，他就阐述什么，越看越像屁精；屁精意气风发，苦心钻研拍马之道，越看越像学者。你能分得清，谁是学者，谁是屁精吗？ &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 这年头，教授一心向钱，手里有什么，他就卖什么，越看越像商人；商人附庸风雅，脸上眼镜身后书架，越看越像教授。你能分得清，谁是教授，谁是商人吗？ &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 这年头，医生心黑手辣，只管赚钱，不顾人命，越看越像杀手；杀手精益求精，宛若庖丁解牛娴熟自如，越看越像医生。你能分得清，谁是医生，谁是杀手吗？ &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 这年头，流言飞遍天下，基本属实，极少掺假，越看越像新闻；新闻一屁俩谎，隐瞒真相胡吹乱侃，越看越像流言。你能分得清，哪是流言，哪是新闻吗？ &nbsp;&]]></description>
		<author><![CDATA[2588]]></author>
		<pubDate>2007-03-15 11:16:00</pubDate>
		</item>
				<item>
		<title><![CDATA[深入理解C语言指针的奥秘(&nbsp;转)]]></title>
		<link>http://blog.pfan.cn/2588/23938.html</link>
		<description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 指针是一个特殊的变量，它里面存储的数值被解释成为内存里的一个地址。 要搞清一个指针需要搞清指针的四方面的内容：指针的类型，指针所指向的 类型，指针的值或者叫指针所指向的内存区，还有指针本身所占据的内存区。让我们分别说明。 　　先声明几个指针放着做例子： 　　例一： 　　(1)int*ptr; 　　(2)char*ptr; 　　(3)int**ptr; 　　(4)int(*ptr)[3]; 　　(5)int*(*ptr)[4]; 　　　　指针的类型　　从语法的角度看，你只要把指针声明语句里的指针名字去掉，剩下的部分就是这个指针的类型。这是指针本身所具有的类型。让我们看看例一中各个指针的类型： 　　(1)int*ptr;//指针的类型是int* 　　(2)char*ptr;//指针的类型是char* 　　(3)int**ptr;//指针的类型是int** 　　(4)int(*ptr)[3];//指针的类型是int(*)[3] 　　(5)int*(*ptr)[4];//指针的类型是int*(*)[4] 　　怎么样？找出指针的类型的方法是不是很简单？ 　　指针所指向的类型　　当你通过指针来访问指针所指向的内存区时，指针所指向的类型决定了编译器将把那片内存区里的内容当做什么来看待。 　　从语法上看，你只须把指针声明语句中的指针名字和名字左边的指针声明符*去掉，剩下的就是指针所指向的类型。例如： 　　(1)int*ptr;//指针所指向的类型是int 　　(2)char*ptr;//指针所指向的的类型是char 　　(3)int**ptr;//指针所指向的的类型是int* 　　(4)int(*ptr)[3];//指针所指向的的类型是int()[3] 　　(5)int*(*ptr)[4];//指针所指向的的类型是int*()[4] 　　在指针的算术运算中，指针所指向的类型有很大的作用。 　　指针的类型(即指针本身的类型)和指针所指向的类型是两个概念。当你对C越来越熟悉时，你会发现，把与指针搅和在一起的"类型"这个概念分成"指针的类型"和"指针所指向的类型"两个概念，是精通指针的关键点之一。我看了不少书，发现有些写得差的书中，就把指]]></description>
		<author><![CDATA[2588]]></author>
		<pubDate>2007-03-13 15:45:00</pubDate>
		</item>
				<item>
		<title><![CDATA[C++学习基础知识(转)]]></title>
		<link>http://blog.pfan.cn/2588/23937.html</link>
		<description><![CDATA[一、#include “filename.h”和#include 的区别
#include “filename.h”是指编译器将从当前工作目录上开始查找此文件
#include 是指编译器将从标准库目录中开始查找此文件
&nbsp;
二、头文件的作用
加强安全检测
通过头文件可能方便地调用库功能，而不必关心其实现方式
&nbsp;
三、* , &amp;修饰符的位置
对于*和&amp;修饰符，为了避免误解，最好将修饰符紧靠变量名
&nbsp;
四、if语句
不要将布尔变量与任何值进行比较，那会很容易出错的。
整形变量必须要有类型相同的值进行比较
浮点变量最好少比点，就算要比也要有值进行限制
指针变量要和NULL进行比较，不要和布尔型和整形比较
&nbsp;
五、const和#define的比较
const有数据类型，#define没有数据类型
个别编译器中const可以进行调试，#define不可以进行调试
在类中定义常量有两种方式
1、 在类在声明常量，但不赋值，在构造函数初始化表中进行赋值；
2、 用枚举代替const常量。
&nbsp;
六、C++函数中值的传递方式
有三种方式：值传递(Pass by value)、指针传递(Pass by pointer)、引用传递(Pass by reference)
void fun(char c) //pass by value
void fun(char *str) //pass by pointer
void fun(char &amp;str) //pass by reference
如果输入参数是以值传递的话，最好使用引用传递代替，因为引用传递省去了临时对象的构造和析构
函数的类型不能省略，就算没有也要加个void
&nbsp;
七、函数体中的指针或引用常量不能被返回
Char *func(void)
{
char str[]=”Hello Word”;
//这个是不能被返回的，因为str是个指定变量，不是一般的值，函数结束后会被注销掉
return str; 
}
函数体内的指针变量并不会随着函数的消亡而自动释放
&nbsp;
八、一个内存拷贝函数的实现体
void *memcpy(void *pvTo,const void]]></description>
		<author><![CDATA[2588]]></author>
		<pubDate>2007-03-13 15:39:00</pubDate>
		</item>
				<item>
		<title><![CDATA[S(n)=1+(1+2)+(1+2+3)+...(1+2+3+...n）多种解法]]></title>
		<link>http://blog.pfan.cn/2588/23934.html</link>
		<description><![CDATA[一、双重循环：#include&lt;iostream&gt;using namespace std;int main(){&nbsp;int s=0,t=0,n;&nbsp;cin&gt;&gt;n;&nbsp;for(int i=0;i&lt;n;i++)&nbsp;&nbsp; for(int j=1;j&lt;=n-i;j++)&nbsp;&nbsp;&nbsp;&nbsp; s=s+j;&nbsp; t=t+s;&nbsp;cout&lt;&lt;"S(n)="&lt;&lt;t&lt;&lt;endl;&nbsp;return 0;}二、单循环：#include &lt;iostream&gt;using namespace std;int main(){&nbsp;&nbsp; &nbsp;int n;&nbsp;&nbsp; &nbsp;cin&gt;&gt;n;&nbsp;&nbsp;&nbsp; int temp=0,value=0;&nbsp;&nbsp; &nbsp;for(int i = 0; i &lt;= n; i++)&nbsp;&nbsp; &nbsp;{&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;temp=temp+i;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;value=value+temp;&nbsp;&nbsp; &nbsp;}&nbsp;&nbsp; &nbsp;cout&lt;&lt;value&lt;&lt;endl;&nbsp;&nbsp; &nbsp;return 0;}三、#include &lt;iostream.h&gt;void main(){&nbsp;&nbsp; &nbsp;int n;&nbsp;&nbsp; &nbsp;cin&gt;&gt;n;&nbsp;&nbsp; &nbsp;int temp = 0;&nbsp;&nbsp; &nbsp;int j = 0;&nbsp;&nbsp; &nbsp;for(int i = n; i &gt; 0; i--,j++)&nbsp;&nbsp; &nbsp;{&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&]]></description>
		<author><![CDATA[2588]]></author>
		<pubDate>2007-03-13 14:38:00</pubDate>
		</item>
				<item>
		<title><![CDATA[一个递归函数(原创)]]></title>
		<link>http://blog.pfan.cn/2588/23933.html</link>
		<description><![CDATA[一个计算S(n)=1*2*2+2*3*3+3*4*4+4*5*5+......+(n-1)*n*n 的递归函数：#include&lt;iostream&gt;using namespace std;int main(){&nbsp;long sum(int);&nbsp;int n;&nbsp;cin&gt;&gt;n;&nbsp;int s=sum(n);&nbsp;cout&lt;&lt;"S(n)="&lt;&lt;s&lt;&lt;endl;&nbsp;return 0;}long sum(int n){&nbsp;if(n&lt;2)&nbsp;&nbsp; return 0;&nbsp;else&nbsp;&nbsp; return (n-1)*n*n+sum(n-1);}]]></description>
		<author><![CDATA[2588]]></author>
		<pubDate>2007-03-13 15:10:00</pubDate>
		</item>
		</channel>
</rss>