ajout controle
This commit is contained in:
45
Exercice2.c
Normal file
45
Exercice2.c
Normal file
@@ -0,0 +1,45 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
|
||||
int racineCarree(int n){
|
||||
if(n < 0){
|
||||
return -1;
|
||||
}
|
||||
|
||||
for(int i = 0; i <= n; i++){
|
||||
if((i*i) == n){
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void racineCarreeTab(int tab[], int taille){
|
||||
for(int i = 0; i < taille; i++){
|
||||
tab[i] = racineCarree(tab[i]);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int main(void) {
|
||||
srand(time(NULL));
|
||||
int Ex2Taille = 10000;
|
||||
int Ex2Tableau[Ex2Taille];
|
||||
for (int i = 0; i < Ex2Taille; i++) {
|
||||
Ex2Tableau[i] = rand() % 1000000;
|
||||
}
|
||||
|
||||
printf("Exercice 2 : \n");
|
||||
racineCarreeTab(Ex2Tableau, Ex2Taille);
|
||||
//for(int i = 0; i < Ex2Taille; i++){
|
||||
//printf("%d ", Ex2Tableau[i]);
|
||||
//}
|
||||
//printf("\n");
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user