I am new to programing and i would like a script where it gives me 4 distinct random numbers between 0:1 so i could use pythagoras and make an average value of it. After some tries i managed to create numbers between 0:1, however they are all the same value, how do i make them diferent from each other? Sorry for my bad english.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main() {
int x1,x2,y1,y2,sum,pythagoras;
//x1,x2,y1,y2 must be different values
//sum = (x2-x1)^2 + (y2-y1)^2
//pythagoras = sqrt(soma)
int tempo = time(NULL);
srand(time);
double number = ((double) rand() * 2) / ( double ) RAND_MAX;
printf("x1 = %.3f", number);
printf(" x2 = %.3f", number);
printf(" y1 = %.3f", number);
printf(" y2 = %.3f", number);
}
thanks in advance.
My question is about:
Aucun commentaire:
Enregistrer un commentaire