摘要:计算并返回斐波那契(Fibonacci)数列中第n项的值。[代码]
阅读全文
摘要:验证6到1000中的所以偶数均能表示成两个素数之和。[代码]
阅读全文
摘要:分别使用下标和指针遍历二维数组。 使用指针遍历 Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->#include using namespace std; int main() { int ia[3][4] = { ...
阅读全文
摘要:编一个程序,从string 对象中去掉标点符号。要求输入到程序的字符串必须含有标点符号,输出结果则是去掉标点符号后的string 对象。 消除标点 Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->#include #include #inc...
阅读全文
摘要:打印下列图案: # $ ## $$ ### $$$ #### $$$$ ##### $$$$$ 背靠背 Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->#include using ...
阅读全文
摘要:打印下面的图案: * *** ***** ******* ***** *** * 菱形打印 Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->#include using namespace std; in...
阅读全文
摘要:用循环语句打印下列图案: STSTSTSTSTSTSTSTS STSTSTSTSTSTSTS STSTSTSTSTSTS STSTSTSTSTS STSTSTSTS STSTSTS STSTS STS S STS Code highlighting pro...
阅读全文
摘要:一小球从100米的高度落下,每次落地后弹起的高度是原高度的一半,再落下。编程求第10次落地后,小球一共经过多少距离?第10次落地后弹起的高度是多少? 小球落地 Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->#include using n...
阅读全文
摘要:用循环语句打印下列矩阵: (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,...
阅读全文
摘要:用循环语句打印下列矩阵: 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 ...
阅读全文
摘要:若有一头母牛,从第四年开始每年生一头小母牛,按这个规律,第n年共有多少头母牛? Cow Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->#include using namespace std; int main() { int n...
阅读全文
摘要:输入一个数k,判断是不是素数 PrimeNumber Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->#include #include using namespace std; int main() { int k; ...
阅读全文
摘要:一个数如果恰好等于它的因子之和,这个数就称为"完数"。例如,6的因子为1、2、3,而6=1+2+3,因此6是"完数"。编程找出1000之内的所有完数。 完数 Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->#include using n...
阅读全文
摘要:打印出所有的"水仙花数"(Narcissus), 所谓"水仙花数"是指一个3位数,其各位数字立方和等于该数本身。例如, 153就是一水仙花数,因为153 = 13+53+33 Narcissus Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--...
阅读全文
摘要:猴子第一天摘下若干桃子,当即吃了一半,还不过瘾,又多吃了一个。第二天早上又将剩下的桃子吃掉一半,又多吃了一个。以后每天早上都吃了前一天剩下的一半零一个。到第10天早上想再吃时,见只剩下一个桃子了。求第一天共摘多少桃子。 猴子吃桃 Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeH...
阅读全文
摘要:一百元买一百只鸡,公鸡7元一只,母鸡5元一只,小鸡1元3只,要求每样都要至少有一只。 百钱百鸡 Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->#include using namespace std; int main() { for(in...
阅读全文
摘要:输入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 ...
阅读全文
摘要:用高斯公式求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(...
阅读全文