随笔分类 -  C++

记录学习C++的历程,从零开始
斐波那契(Fibonacci)数列
摘要:计算并返回斐波那契(Fibonacci)数列中第n项的值。[代码] 阅读全文

posted @ 2009-02-11 15:06 哪热 阅读(357) 评论(0) 推荐(0)

素数
摘要:验证6到1000中的所以偶数均能表示成两个素数之和。[代码] 阅读全文

posted @ 2009-02-11 14:19 哪热 阅读(278) 评论(0) 推荐(0)

遍历多维数组(Traverse Multidimensioned Arrays)
摘要:分别使用下标和指针遍历二维数组。 使用指针遍历 Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->#include using namespace std; int main() { int ia[3][4] = { ... 阅读全文

posted @ 2008-05-04 23:57 哪热 阅读(283) 评论(0) 推荐(0)

消除标点符号
摘要:编一个程序,从string 对象中去掉标点符号。要求输入到程序的字符串必须含有标点符号,输出结果则是去掉标点符号后的string 对象。 消除标点 Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->#include #include #inc... 阅读全文

posted @ 2008-04-24 16:29 哪热 阅读(428) 评论(2) 推荐(0)

打印背靠背图案
摘要:打印下列图案: # $ ## $$ ### $$$ #### $$$$ ##### $$$$$ 背靠背 Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->#include using ... 阅读全文

posted @ 2008-04-23 23:54 哪热 阅读(360) 评论(0) 推荐(0)

打印菱形
摘要:打印下面的图案: * *** ***** ******* ***** *** * 菱形打印 Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->#include using namespace std; in... 阅读全文

posted @ 2008-04-23 23:47 哪热 阅读(341) 评论(3) 推荐(0)

打印STS图形
摘要:用循环语句打印下列图案: STSTSTSTSTSTSTSTS STSTSTSTSTSTSTS STSTSTSTSTSTS STSTSTSTSTS STSTSTSTS STSTSTS STSTS STS S STS Code highlighting pro... 阅读全文

posted @ 2008-04-23 23:39 哪热 阅读(153) 评论(0) 推荐(0)

小球落地
摘要:一小球从100米的高度落下,每次落地后弹起的高度是原高度的一半,再落下。编程求第10次落地后,小球一共经过多少距离?第10次落地后弹起的高度是多少? 小球落地 Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->#include using n... 阅读全文

posted @ 2008-04-23 23:31 哪热 阅读(277) 评论(0) 推荐(0)

矩阵打印2
摘要:用循环语句打印下列矩阵: (1,1) (1,2) (1,3) (1,4) (1,5) (1,6) (1,7) (2,1) (2,2) (2,3) (2,4) (2,5) (2,6) (2,7) (3,1) (3,2) (3,3) (3,4) (3,5) (3,6) (3,7) (4,... 阅读全文

posted @ 2008-04-23 23:21 哪热 阅读(138) 评论(0) 推荐(0)

矩阵打印1
摘要:用循环语句打印下列矩阵: 1 0 1 2 3 4 5 6 2 1 2 3 4 5 6 0 3 2 3 4 5 6 0 1 4 3 4 5 6 0 1 2 5 4 5 6 ... 阅读全文

posted @ 2008-04-23 23:13 哪热 阅读(132) 评论(0) 推荐(0)

母牛生母牛
摘要:若有一头母牛,从第四年开始每年生一头小母牛,按这个规律,第n年共有多少头母牛? Cow Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->#include using namespace std; int main() { int n... 阅读全文

posted @ 2008-04-23 22:49 哪热 阅读(211) 评论(0) 推荐(0)

素数(Prime Number)
摘要:输入一个数k,判断是不是素数 PrimeNumber Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->#include #include using namespace std; int main() { int k; ... 阅读全文

posted @ 2008-04-23 00:41 哪热 阅读(187) 评论(0) 推荐(0)

完数
摘要:一个数如果恰好等于它的因子之和,这个数就称为"完数"。例如,6的因子为1、2、3,而6=1+2+3,因此6是"完数"。编程找出1000之内的所有完数。 完数 Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->#include using n... 阅读全文

posted @ 2008-04-23 00:38 哪热 阅读(233) 评论(0) 推荐(0)

水仙花数
摘要:打印出所有的"水仙花数"(Narcissus), 所谓"水仙花数"是指一个3位数,其各位数字立方和等于该数本身。例如, 153就是一水仙花数,因为153 = 13+53+33 Narcissus Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--... 阅读全文

posted @ 2008-04-23 00:34 哪热 阅读(385) 评论(0) 推荐(0)

猴子吃桃
摘要:猴子第一天摘下若干桃子,当即吃了一半,还不过瘾,又多吃了一个。第二天早上又将剩下的桃子吃掉一半,又多吃了一个。以后每天早上都吃了前一天剩下的一半零一个。到第10天早上想再吃时,见只剩下一个桃子了。求第一天共摘多少桃子。 猴子吃桃 Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeH... 阅读全文

posted @ 2008-04-23 00:29 哪热 阅读(316) 评论(0) 推荐(0)

百钱百鸡问题
摘要:一百元买一百只鸡,公鸡7元一只,母鸡5元一只,小鸡1元3只,要求每样都要至少有一只。 百钱百鸡 Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->#include using namespace std; int main() { for(in... 阅读全文

posted @ 2008-04-23 00:19 哪热 阅读(192) 评论(0) 推荐(0)

输入X,计算级数
摘要:输入X,计算级数 1 + x – x2/2! + x3/3! -… + (-1)n+1xn/n! x的级数 Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->#include #include using namespace std; int ... 阅读全文

posted @ 2008-04-23 00:13 哪热 阅读(388) 评论(0) 推荐(0)

求PI
摘要:用高斯公式求PI: PI/4 = 1 – 1/3 + 1/5 – 1/7 +……. PI Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->#include #include using namespace std; int main(... 阅读全文

posted @ 2008-04-22 23:44 哪热 阅读(207) 评论(0) 推荐(0)

导航