52 lines
1.2 KiB
C
52 lines
1.2 KiB
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
int racinecarree(float nombre) {
|
|
int pasDeRacine = -1;
|
|
for(int i = 1; i<nombre-1; i++) {
|
|
if(nombre/i == i) {
|
|
return i;
|
|
}
|
|
}
|
|
return pasDeRacine;
|
|
}
|
|
|
|
// void racineCarreeTab(float tab[], int tablength) {
|
|
// float tabRacines[tablength];
|
|
// printf("[ ");
|
|
// for (int i=0; i < tablength; i++) {
|
|
// tabRacines[i]=racinecarree(tab[i]);
|
|
// printf(" %d,", tabRacines[i]);
|
|
// }
|
|
// printf(" ]");
|
|
// return;
|
|
// }
|
|
|
|
int main() {
|
|
float nombre;
|
|
// float mode;
|
|
// int tablength;
|
|
|
|
// printf("Voulez vous entrer sous la forme d'un nombre (1) ou d'un tableau (2) ? \n");
|
|
// scanf("%d", &mode);
|
|
// if (mode==1) {
|
|
scanf("%f", &nombre);
|
|
printf("%d \n", racinecarree(nombre));
|
|
// }
|
|
|
|
// if (mode==2) {
|
|
// printf("De combien d'éléments voulez-vous trouver leur racine carrée ? \n");
|
|
// scanf("%d", tablength);
|
|
|
|
// float tab[tablength];
|
|
|
|
// for (int i = 0; i < tablength; i++) {
|
|
// scanf("%f", &nombre);
|
|
// tab[i] = nombre;
|
|
// }
|
|
|
|
// racineCarreeTab(tab[tablength], tablength);
|
|
// }
|
|
|
|
|
|
}
|