programowanie w c
romanooo: ogarnia tu ktoś programowanie w c

miałbym małe pytanie
13 sty 21:53
Jack:
pytaj, nie gadaj
13 sty 21:55
romanooo: #include<stdio.h>
#include<math.h>
#include<stdlib.h>
void sequence();
void calculation();
void excel();
int n=1000,i;
double tab[1000];
double a=0,b;
double s=pow(3,0.5);
double t=1+a;
void sequence()
{
for (i=1;i<=5000;i++)
{
tab[i]=a;
a=(1/(1+1/(2+a)));
}
printf("a = %lg\n",a);
}
void calculation()
{
printf("Left side of the equation = square root of three = %lg\n",s);
printf("Right side of the equation = %lg\n\n\n",t);
if (s==t)
printf("Left side of the equation is equal to the right side,\n for big number of sequence
elements,\n so RHS approximates square root of three\n\n");
}
/*void excel()
{
}*/
void main()
{
printf("***proof that 1 + chain fraction: 1/(1+1/(2+(1/(1+1/(2+...))))\n approximates square
root of 3***\n\n");
sequence();
calculation();
//excel();
}
13 sty 21:57
Jack:
dobra, w czym rzecz?

Nie chce mi się wklejać do VB − nie działa jak powinno?
13 sty 21:59
romanooo: zaczne że naskrobałem coś takiego,
| | 1 | |
mam tym pokazać że P{3}=1+ |
| } |
| | | |
13 sty 22:00
romanooo: problem jest w tym void sequence bo nie potrafie chyba dobrze zapisać tego ułamka
13 sty 22:01
romanooo: znaczy jak bym miał zamiast dwójek same jedynki
to by było
a=1/(1+a) i by wszystko działało, jest szansa na podpowiedź
13 sty 22:02
romanooo: już kombinowałem z podstawianiem
b=1/(1+a)
a=1/(1+b)
ale albo to jest źle albo nie umiem dobrze wyciągnąć odpowiedzi
13 sty 22:06
romanooo: proszę bardzo ładnie o jakąś pomoc
13 sty 22:30
13 sty 23:03
romanooo: #include<stdio.h>
#include<math.h>
#include<stdlib.h>
void sequence();
void calculation();
void excel();
int n=1000;
int i;
double tab[1000];
double a=0;
double s=pow(3,0.5);
void sequence()
{
for (i=1;i<1000;i++)
{
tab[i]=a;
a=(1/(1+1/(2+a)));
}
printf("a = %lg\n",a);
}
void calculation()
{
double t=1+a;
printf("Left side of the equation = square root of three = %lg\n",s);
printf("Right side of the equation = %lg\n\n\n",t);
if (s==t)
printf("Left side of the equation is equal to the right side,\n for big number of sequence
elements,\n so RHS approximates square root of three\n\n");
}
/*void excel()
{
}*/
void main()
{
printf("***proof that 1 + chain fraction: 1/(1+1/(2+(1/(1+1/(2+...))))\n approximates square
root of 3***\n\n");
sequence();
calculation();
//excel();
}
14 sty 14:52
romanooo: poprawiłem i teraz wszystko pięknie działa

poprostu miałem dla pętli miałem zadeklarowane
5000 powtórzeń a do tablicy wpisywało tylko 1000
14 sty 14:53