1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
#include <iostream>
#include <stdio.h>
#include <math.h>
int main()
{
float m1, m2, d, i, p, F, a1, a2, s1, s2, t, count, pardist;
printf("mass n'1\n");
scanf("%f", &m1);
printf("\nmass n'2\n");
scanf("%f", &m2);
printf("\ndistance\n");
scanf("%f", &d);
printf("precision (the lower the value the more precise; must not be 0)\n");
scanf("%f", &t);
count = 0;
distparz = d;
for (;;)
{
F = (6,67 * 0,0000000001 * m1 * m2) / distpar*distpar;
a1 = F / m1;
a2 = F / m2;
s1 = 1 / 2 * a1 * t * t;
s2 = 1 / 2 * a1 * t * t;
count++;
pardist = pardist - s1 - s2;
if(pardist == s1 + s2) break;
}
cont = cont * t;
printf("time ");
printf("%f", &count);
printf("s\n");
system("pause");
}
|