update
This commit is contained in:
30
DEV/DEV1.1_suite/CM2/Q1_Recherche.c
Normal file
30
DEV/DEV1.1_suite/CM2/Q1_Recherche.c
Normal file
@@ -0,0 +1,30 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int count0(double* tableau, int taille){
|
||||
int numElement;
|
||||
int compteurDe0=0;
|
||||
for (numElement=0; numElement<taille; numElement++){
|
||||
if ((int) tableau[numElement]==0){
|
||||
compteurDe0++;
|
||||
}
|
||||
}
|
||||
return compteurDe0;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv){
|
||||
int numArg;
|
||||
int nb0;
|
||||
double* tableau= (double*) malloc((argc-1)*sizeof(double));
|
||||
for (numArg=0; numArg<argc-1; numArg++){
|
||||
tableau[numArg]=strtod(argv[numArg+1],NULL);
|
||||
}
|
||||
nb0 = count0(tableau,argc-1);
|
||||
if (nb0 > 1){
|
||||
printf("%d valeurs nulles\n",nb0);
|
||||
}
|
||||
else{
|
||||
printf("%d valeur nulle\n",nb0);
|
||||
}
|
||||
return 0;
|
||||
}
|
0
DEV/DEV1.1_suite/CM2/Q1_Recherche.c~
Normal file
0
DEV/DEV1.1_suite/CM2/Q1_Recherche.c~
Normal file
47
DEV/DEV1.1_suite/CM2/Q2_Reproduction.c
Normal file
47
DEV/DEV1.1_suite/CM2/Q2_Reproduction.c
Normal file
@@ -0,0 +1,47 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char** argv){
|
||||
FILE* fichier1;
|
||||
FILE* fichier2;
|
||||
char contenu1[2];
|
||||
char contenu2[2];
|
||||
size_t resultat1=1;
|
||||
size_t resultat2=1;
|
||||
if (argc<=2){
|
||||
printf("Error: Merci de fournir 2 nom de fichier\n");
|
||||
return 1;
|
||||
}
|
||||
else{
|
||||
fichier1 = fopen(argv[1], "r");
|
||||
if (fichier1==NULL){
|
||||
fprintf(stderr,"Error: impossible d'ouvrir le fichier %s\n",argv[1]);
|
||||
return 1;
|
||||
}
|
||||
else{
|
||||
fichier2 = fopen(argv[2], "r");
|
||||
if (fichier2==NULL){
|
||||
fprintf(stderr,"Error: impossible d'ouvrir le fichier %s\n",argv[2]);
|
||||
return 1;
|
||||
}
|
||||
else{
|
||||
while (resultat1==1 && resultat2==1){
|
||||
resultat1 = fread(contenu1, sizeof(char), 1, fichier1);
|
||||
resultat2 = fread(contenu2, sizeof(char), 1, fichier2);
|
||||
if (contenu1[0]!=contenu2[0]){
|
||||
resultat1 = -1;
|
||||
}
|
||||
}
|
||||
if (resultat1 == resultat2){
|
||||
printf("Fichiers identiques !\n");
|
||||
}
|
||||
else{
|
||||
printf("Fichiers différents !\n");
|
||||
}
|
||||
fclose(fichier1);
|
||||
fclose(fichier2);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
47
DEV/DEV1.1_suite/CM2/Q2_Reproduction.c~
Normal file
47
DEV/DEV1.1_suite/CM2/Q2_Reproduction.c~
Normal file
@@ -0,0 +1,47 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char** argv){
|
||||
FILE* fichier1;
|
||||
FILE* fichier2;
|
||||
char contenu1[2];
|
||||
char contenu2[2];
|
||||
size_t resultat1=1;
|
||||
size_t resultat2=1;
|
||||
if (argc<=2){
|
||||
printf("Error: Merci de fournir 2 nom de fichier\n");
|
||||
return 1;
|
||||
}
|
||||
else{
|
||||
fichier1 = fopen(argv[1], "r");
|
||||
if (fichier1==NULL){
|
||||
fprintf("Error: impossible d'ouvrir le fichier %s\n",argv[1],stderr);
|
||||
return 1;
|
||||
}
|
||||
else{
|
||||
fichier2 = fopen(argv[2], "r");
|
||||
if (fichier2==NULL){
|
||||
fprintf("Error: impossible d'ouvrir le fichier %s\n",argv[2],stderr);
|
||||
return 1;
|
||||
}
|
||||
else{
|
||||
while (resultat1==1 && resultat2==1){
|
||||
resultat1 = fread(contenu1, sizeof(char), 1, fichier1);
|
||||
resultat2 = fread(contenu2, sizeof(char), 1, fichier2);
|
||||
if (contenu1[0]!=contenu2[0]){
|
||||
resultat1 = -1;
|
||||
}
|
||||
}
|
||||
if (resultat1 == resultat2){
|
||||
printf("Fichiers identiques !\n");
|
||||
}
|
||||
else{
|
||||
printf("Fichiers différents !\n");
|
||||
}
|
||||
fclose(fichier1);
|
||||
fclose(fichier2);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
14
DEV/DEV1.1_suite/CM2/Q3_Ralentis.c
Normal file
14
DEV/DEV1.1_suite/CM2/Q3_Ralentis.c
Normal file
@@ -0,0 +1,14 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
int main(void){
|
||||
struct timespec tempsDAttente;
|
||||
char* message="ERREUR";
|
||||
int i;
|
||||
for (i=0; i<6; i++){
|
||||
tempsDAttente.it_value = tempsDAttente.it_interval+1000000000;
|
||||
nanosleep(tempsDAttente,NULL);
|
||||
fprintf(stderr,message[i]);
|
||||
}
|
||||
}
|
0
DEV/DEV1.1_suite/CM2/Q3_Ralentis.c~
Normal file
0
DEV/DEV1.1_suite/CM2/Q3_Ralentis.c~
Normal file
Reference in New Issue
Block a user