debut TP19

This commit is contained in:
2023-11-27 14:59:48 +01:00
parent d8c802ece8
commit d64b38f93d
8 changed files with 42 additions and 6 deletions

Binary file not shown.

View File

@@ -3,29 +3,29 @@
int main(void) { int main(void) {
int pris=0,val=1,val1,occ,nbr_val=0; int pris=0,val=1,val1,occ=0,nbr_val=0;
double* tab=NULL; double* tab=NULL;
double* tab_val=NULL; double* tab_val=NULL;
tab = (double*) malloc(sizeof(double)); tab = (double*) malloc(sizeof(double));
printf("Réel à entrer: "); printf("Réel à entrer: ");
pris=scanf("%lf",tab[nbr_val]); pris=scanf("%lf",tab[nbr_val]);
while(pris!=0){ while(pris==1){
tab = (double*) realloc(tab,nbr_val*sizeof(double)); tab = (double*) realloc(tab,nbr_val*sizeof(double));
printf("Réel à entrer: "); printf("Réel à entrer: ");
pris=scanf("%lf",tab[nbr_val]); pris=scanf("%lf",tab[nbr_val]);
nbr_val++; nbr_val++;
} }
tab_val = (double*) malloc(nbr_val*sizeof(double)); tab_val = (double*) malloc((nbr_val+1)*sizeof(double));
printf("%3f ",tab[0]); printf("%3s ",tab[0]);
tab_val[0]=tab[0]; tab_val[0]=tab[0];
for(val=1;val<nbr_val;val++){ for(val=1;val<nbr_val;val++){
occ=0; occ=0;
for(val1=0;val1<nbr_val;val1++){ for(val1=0;val1<=occ;val1++){
if (tab[val]==tab_val[val1]) if (tab[val]==tab_val[val1])
occ++; occ++;
} }
if (occ==0) if (occ==0)
printf("%3f ",tab[val]); printf("%3s ",tab[val]);
tab_val[val]=tab[val]; tab_val[val]=tab[val];
} }
free(tab); free(tab);

BIN
DEV1.1/TP19/date Executable file

Binary file not shown.

11
DEV1.1/TP19/date.c Normal file
View File

@@ -0,0 +1,11 @@
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(void){
time_t times =time(NULL);
struct tm *timeI=localtime(&times);
printf("La date est: %02d - %02d - %02d\n", timeI->tm_year + 1900,timeI->tm_mon, timeI->tm_mday);
return EXIT_SUCCESS;
}

BIN
DEV1.1/TP19/numero Executable file

Binary file not shown.

11
DEV1.1/TP19/numero.c Normal file
View File

@@ -0,0 +1,11 @@
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <pwd.h>
int main(void) {
struct passwd *info=getpwnam("felix-vi");
printf("Votre uid est %lu\n",(unsigned long) info->pw_uid);
return EXIT_SUCCESS;
}

BIN
DEV1.1/TP19/tailles Executable file

Binary file not shown.

14
DEV1.1/TP19/tailles.c Normal file
View File

@@ -0,0 +1,14 @@
#include <stdio.h>
#include <stdlib.h>
struct taille{
char a;
char b;
char c;
};
typedef struct taille e;
int main(void){
printf("%lu\n", sizeof(e));
}