Autor |
Wiadomość |
lisek
Dołączył: 01 Lis 2007
Posty: 3
Przeczytał: 0 tematów
Pomógł: 1 raz
Ostrzeżeń: 0/5
Skąd: iz3
|
Wysłany:
Wto 15:39, 13 Lis 2007 |
 |
A tu program z Fibonaccim w ansi c
Kod: |
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
fib(int);
int main(int argc, char *argv[])
{
clrscr();
int k;
if(argc==2)
{
k=atof(argv[1]);
}
else
{
printf("Podaj ktory element ciagu fibonaccigo chcesz uzyskac:\n\r");
scanf("%d", &k);
}
printf("%d",k);
printf( "\telement ciagu fibonaciego wynosi:\t");
if (k>0)
printf("%4d", fib(k));
printf( "\n\rNacisnij dowolny klawisz\t");
getch();
return 0;
}
fib(int element)
{
if(element<=0)
return 0;
if(element<=1)
return 1;
else
return("%4d ",fib(element-1))+("%4d",fib(element-2));
}
|
|
Post został pochwalony 0 razy
|
|
 |
 |
|
 |
|
fora.pl - załóż własne forum dyskusyjne za darmo
Powered by phpBB
© 2001/3 phpBB Group :: FI Theme ::
Wszystkie czasy w strefie EET (Europa)
| |