Add: Evaluation file

This commit is contained in:
2025-10-15 17:52:28 +02:00
commit 0612a4033f
8 changed files with 232 additions and 0 deletions

57
Ex3/TriSpecial.c Normal file
View File

@@ -0,0 +1,57 @@
#include <stdio.h>
#include <stdlib.h>
int racinecarre(int n){
/* int x = n/4; /* Precision pour essayer de se rapprocher*/
if (n < 0){
return -1;
}
for(int i = 0; i <= n; i++ ){
if (i * i == n) { /* 2 * 2 = 4 */
return i;
}
if (i * i > n) {
break;
}
/* x = (x + ( n / x)) /2; */
}
return -1;
}
int TriSpecial(int tab[]){
int nbr, somme;
int quantite = racinecarre(nbr);
/* calcul quantité pas finie */
somme = 0;
if(quantite % 2 == 0){
for (int i = 0; i < nbr; i++){
nbr = i;
somme = somme + tab[i] * nbr + 1;
}
}else {
for (int i = 0; i < nbr; i++){
racinecarre(i);
int somme = somme + racinecarre(tab[i]) + i + 1;
}
}
}
/* Pas finie */
int main(void)
{
int tab1[4] = {3, 5, 25, 16};
TriSpecial(tab1);
printf("Tri %d, %d, %d , %d ", tab1[0], tab1[1], tab1[2], tab1[3]);
printf("\n");
}

BIN
Ex3/a.out Executable file

Binary file not shown.