斐波那契数列求和程序怎么编写?

[复制链接]
查看11 | 回复3 | 2013-8-10 12:25:22 | 显示全部楼层 |阅读模式
楼上的给 的是C语言版的,我给一个C#版的,不知道你要哪种语言!using System;using System.Collections.Generic;using System.Text;namespace Fibonacci数列前20项{
class Program
{
static void Main(string[] args)
{
int x, y, i;
x = y = 1;
i = 1;
Console.WriteLine("{0}", x);
...
回复

使用道具 举报

千问 | 2013-8-10 12:25:22 | 显示全部楼层
C语言编写的,算法是这样的,要是用其他语言写的话变一变语法就可以了。//打印斐波那契数列的前10项 #include#define MAX 9 int main(){ int fib[MAX],i=2; fib[0]=fib[1]=1; printf("斐波那契数列的前10项是:\n%d\t%d\t",f...
回复

使用道具 举报

千问 | 2013-8-10 12:25:22 | 显示全部楼层
#include using namespace std;int f(int n){if(n==1||n==2)return 1;return f(n-1)+f(n-2);}int main(){int n;cin>>n;cout<<f(n);return 0;}...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行