This commit is contained in:
Menouer MELIANI 2023-02-08 11:18:16 +01:00
parent 639fd8c410
commit 7021891e9c
60 changed files with 1218 additions and 0 deletions

2
.gitignore vendored
View File

@ -73,3 +73,5 @@ tags
# Persistent undo
[._]*.un~
DEV1.1/meliani_CM1.tar.gz
DEV1.1S/meliani_CM3.tar.gz

27
DEV1.1/CM1/calculs.c Normal file
View File

@ -0,0 +1,27 @@
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(void){
int NOMBRE = 5;
double CIBLE = 51.7;
double tab[NOMBRE];
int i;
double res = 100000;
int proche = 0;
for(i = 0; i< NOMBRE; i++){
printf("Entrez une valeur : ");
scanf("%lf", &tab[i]);
printf("case n° %d : ", i);
printf("%.2lf\n", tab[i]);
}
res = fabs(tab[0] - CIBLE);
for(i = 1; i < NOMBRE; i++){
if (fabs(tab[i] - CIBLE) <= res){
res = fabs(tab[i] - CIBLE);
proche = i;
}
}
printf("La valeur la plus proche est dans la case n° %d\n", proche);
return 0;
}

26
DEV1.1/CM1/cases.c Normal file
View File

@ -0,0 +1,26 @@
#include <stdio.h>
#include <stdlib.h>
int main(void){
int cases;
int i;
int a;
printf("Entrez le nombre de cases : ");
scanf("%d", &cases);
if (cases > 0){
printf("┌──");
for(i=0; i < cases-1; i++){
printf("┬──");
}
printf("\n");
for(i=0; i <= cases; i++){
printf("");
}
printf("\n");
printf("└──");
for(i=0; i< cases-1; i++){
printf("┴──");
}
printf("\n");
}
return 0;
}

8
DEV1.1/CM1/chaton.c Normal file
View File

@ -0,0 +1,8 @@
#include <stdio.h>
#include <stdlib.h>
int main(void){
printf(" (\\_/)\n");
printf("=(^.^)=\n");
printf("(\")_(\")");
return 0;
}

47
DEV1.1/CM1/comptes.c Normal file
View File

@ -0,0 +1,47 @@
#include <stdio.h>
#include <stdlib.h>
int main(void){
int argent;
int livre = 0;
int deniers = 0;
int sous = 0;
printf("Combien de deniers ? \n");
scanf("%d", &argent);
while (argent >= 240){
livre++;
argent = argent-240;
}
while (argent >=12){
sous++;
argent = argent-12;
}
while (argent >= 1){
deniers++;
argent = argent-1;
}
if(livre != 0 && livre == 1){
printf("%d", livre);
printf(" livre\n");
}
if(livre > 1){
printf("%d", livre);
printf(" livres\n");
}
if(sous != 0 && sous == 1){
printf("%d", sous);
printf(" sou\n");
}
if(sous > 1){
printf("%d", sous);
printf(" sous\n");
}
if(deniers != 0 && deniers == 1){
printf("%d", deniers);
printf(" denier");
}
if(deniers > 1){
printf("%d", deniers);
printf(" deniers");
}
return 0;
}

13
DEV1.1/CM1/constante.c Normal file
View File

@ -0,0 +1,13 @@
#include <stdio.h>
#include <stdlib.h>
int main(void){
char a = (char) '9';
printf("%c\n", a);
long int b = 9L;
printf("%ld\n", b);
long double c = 9.0L;
printf("%.0Lf\n", c);
int d = 0x9;
printf("%d\n", d);
return 0;
}

8
DEV1.1S/CM/MakeFile Normal file
View File

@ -0,0 +1,8 @@
exo1 : fonction.o exo1.o
gcc -o exo1 fonction.o exo1.o
fonction.o : fonction.c fonction.h
gcc -c fonction.c
exo.o : exo1.c exo1.h
gcc -c exo1.c

17
DEV1.1S/CM/exo1.c Normal file
View File

@ -0,0 +1,17 @@
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <fonction.h>
int main(int argc, char *argv[]){
double tab[10];
int i;
for(i=1; i<argc; i++){
tab[i-1] = strtod(argv[i], NULL);
printf("%lf\n", tab[i-1]);
}
int a = valnull(tab , argc);
printf("%d", a-1);
printf("valeurs nulles")
return 0;
}

7
DEV1.1S/CM/exo1.h Normal file
View File

@ -0,0 +1,7 @@
#ifndef _MAIN_H
#define _MAIN_H
int main(int argc, char *argv[])
#endif

20
DEV1.1S/CM/exo2.c Normal file
View File

@ -0,0 +1,20 @@
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]){
FILE* fichier1, fichier2;
char tab1, tab2;
int diff;
fichier1 = fopen($argv[1], "r");
fichier2 = fopen($argv[2], "r")
while(diff != 0){
fread(&tab1, sizeof(char), 1, fichier1)
fread(&tab2, sizeof(char), 1, fichier2)
if (strcmp(tab2,tab1) != 0;){
diff = 1;
}
}
fclose(fichier1);
fclose(fichier2);
return 0;
}

22
DEV1.1S/CM/exo3.c Normal file
View File

@ -0,0 +1,22 @@
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(int argc, char *argv[]){
struct timespec temps;
printf("E");
temps.tv_nsec;
printf("R");
temps.tv_nsec;
printf("R");
temps.tv_nsec;
printf("E");
temps.tv_nsec;
printf("U");
temps.tv_nsec;
printf("R");
return 0
}

13
DEV1.1S/CM/fonction.c Normal file
View File

@ -0,0 +1,13 @@
#include <stdio.h>
#include <stdlib.h>
#include <fonction.h>
int valnull(double* tab, int taille){
int i;
int accumulateur = 0;
for(i=0; i<taille; i++){
if (fabs(tab[i]) == 0.0){
accumulateur += 1;
}
}
return accumulateur;
}

6
DEV1.1S/CM/fonction.h Normal file
View File

@ -0,0 +1,6 @@
#ifndef _FONCTION_H
#define _FONCTION_H
int valnull(char tableau, int taille)
#endif

Binary file not shown.

44
DEV1.1S/CM3/recherche.c Normal file
View File

@ -0,0 +1,44 @@
#include <stdlib.h>
#include <stdio.h>
int rechercheValeur(int valeur, int* tableau, int taille){
int n= -1;
if (taille == 0){
if (valeur == tableau[taille]){
n = taille;
}
return n;
}
if (valeur == tableau[taille]){
n = taille;
return n;
}
return rechercheValeur(valeur, tableau , taille-1);
}
int main(int argc, char const *argv[])
{
int test, test1, test2, test3, test4;
int oui = 5;
int tab1[5] = {3, 7 ,4 ,8, 9};
int tab2[5] = {6, 7 ,4 ,8, 9};
int tab3[5] = {2, 7 ,4 ,8, 6};
int tab4[5] = {6, 7 ,6 ,6, 9};
test = rechercheValeur(6, tab1 , oui);
test2 = rechercheValeur(6, tab2, oui);
test3 = rechercheValeur(6, tab3, oui);
test4 = rechercheValeur(6, tab4, oui);
printf("Test vide : ");
printf("%d\n", test);
printf("Test 1 fois au début : ");
printf("%d\n", test2);
printf("Test 1 fois a la fin : ");
printf("%d\n", test3);
printf("Test 3 fois au total : ");
printf("%d\n", test4);
return 0;
}

29
DEV1.1S/CM3/recoupement.c Normal file
View File

@ -0,0 +1,29 @@
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char const *argv[])
{
int* chiffres;
int valeur;
int arret = 0;
int accumulateur = 0;
int i;
chiffres = (int*) malloc(100*sizeof(int));
while(arret == 0){
for(i=0; i<= accumulateur; i++){
if ((chiffres[accumulateur] / chiffres[i]) == 2){
arret == 1;
printf("Perdu)");
i == 100000000;
}
}
if (arret != 1){
printf("Entrez une valeur : ");
scanf("%d", valeur);
chiffres[accumulateur] == valeur;
}
}
return EXIT_SUCCESS;
}

26
DEV1.1S/CM3/reduction.c Normal file
View File

@ -0,0 +1,26 @@
#include <stdio.h>
#include <stdlib.h>
#include <stack.h>
#include <stack.c>
void sans_zero(stack pile){
int stock;
while (empty(pile) == 0){
stock = pop(pile);
if(stock != 0){
push(pile, stock)
}
}
}
int main(int argc, char const *argv[])
{
int pile = create_stack()
int push = push(pile, 1);
push = push(pile , 2);
push = push(pile , 0);
push = push(pile , 1);
push = push(pile , 0);
sans_zero(pile);
return 0;
}

60
DEV1.1S/CM3/stack.c Normal file
View File

@ -0,0 +1,60 @@
#include <stdlib.h>
#include "stack.h"
struct s_link {
unsigned value;
struct s_link *next;
};
typedef struct s_link link;
struct s_stack {
link *first;
};
/* crée une pile vide */
stack create_stack(void) {
return (stack) calloc(1, sizeof(struct s_stack));
}
/* ajoute un élément à la pile. Renvoie 1 en cas de succès */
int push(stack the_stack, unsigned the_value) {
link *new = (link*) malloc(sizeof(link));
if (new == NULL) {
return 0;
}
new->value = the_value;
new->next = the_stack->first;
the_stack->first = new;
return 1;
}
/* renvoie 1 si la pile est vide */
int empty(stack the_stack) {
return the_stack->first == NULL;
}
/* retire un élément de la pile. Renvoie l'élément retiré, ou -1 en cas d'échec */
long pop(stack the_stack) {
if(the_stack->first == NULL) {
return -1;
}
link l = *(the_stack->first);
free(the_stack->first);
the_stack->first = l.next;
return l.value;
}
/* détruit une pile en libérant les ressources associées */
void destroy_stack(stack the_stack) {
link *current, *saved;
current = the_stack->first;
while(current != NULL) {
saved = current->next;
free(current);
current = saved;
}
free(the_stack);
}

22
DEV1.1S/CM3/stack.h Normal file
View File

@ -0,0 +1,22 @@
#ifndef STACK_H
#define STACK_H
/* le type stack représente une pile */
typedef struct s_stack *stack;
/* crée une pile vide. Renvoie NULL en cas d'échec */
stack create_stack(void);
/* ajoute un élément à la pile. Renvoie 0 en cas d'échec */
int push(stack, unsigned);
/* renvoie 1 si la pile est vide */
int empty(stack);
/* retire un élément de la pile. Renvoie l'élément retiré, ou -1 en cas d'échec */
long pop(stack);
/* détruit une pile en libérant les ressources associées */
void destroy_stack(stack);
#endif /* STACK_H */

View File

@ -0,0 +1,18 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char const *argv[])
{
if (strcmp(argv[2], "cm") == 0){
double val =strtod(argv[1], NULL);
val = val / 2.54;
printf("%.2lf%s", val,"in");
}
if (strcmp(argv[2], "in") == 0){
double val = strtod(argv[1], NULL);
val = val*2.54;
printf("%.2lf%s",val,"cm");
}
return EXIT_SUCCESS;
}

View File

@ -0,0 +1,46 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
int main(int argc, char const *argv[]){
int date;
int mois;
int annee;
printf("Entrez une date : ");
scanf("%d", &date);
scanf("%d", &mois);
scanf("%d", &annee);
struct tm jour;
jour.tm_sec = 0;
jour.tm_min = 0;
jour.tm_hour = 0;
jour.tm_mday = date;
jour.tm_mon = mois;
jour.tm_year = annee;
printf("%d\n", jour.tm_wday);
if (jour.tm_wday == 0){
printf("c'est un dimanche");
}
if (jour.tm_wday == 1){
printf("c'est un lundi");
}
if (jour.tm_wday == 2){
printf("c'est un mardi");
}
if (jour.tm_wday == 3){
printf("c'est un mercredi");
}
if (jour.tm_wday == 4){
printf("c'est un jeudi");
}
if (jour.tm_wday == 5){
printf("c'est un vendredi");
}
if (jour.tm_wday == 6){
printf("c'est un samedi");
}
return 0;
}

View File

@ -0,0 +1,12 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main (void){
FILE* fichier;
fichier = fopen("dev/random", "r");
int tab[2];
fread(&tab[0],sizeof(int),1,fichier);
printf("%d\n", tab[0]);
fclose(fichier);
return 0;
}

View File

@ -0,0 +1 @@
marie-helene.renaud@u-pec.fr

View File

@ -0,0 +1,30 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char* inverse(const char* s){
int i;
int e=0;
char* crocs;
int longueur = (int) strlen(s);
crocs = (char*) malloc(longueur+1);
for (i=longueur-1;i>=0;--i) {
crocs[e] = s[i];
e++;
crocs[longueur] = '\0';
}
return crocs;
}
int main(int argc, char** argv) {
int c;
for(c=1; c< argc; c++){
if (strcmp(argv[c], inverse(argv[c]))== 0){
printf("est un palindrome \n");
}
else{
printf("non \n");
}
}
return 0;
}

43
DEV1.1S/TP01/singleton.c Normal file
View File

@ -0,0 +1,43 @@
#include <stdio.h>
#include <stdlib.h>
int main(void){
float* tab;
int i = 0;
int a;
int fin = 0;
int lin = 2;
int valeur;
tab = (float*) malloc(2*sizeof(float));
printf("Donnez une réponse : ");
valeur = scanf("%f", &tab[i]);
if(valeur == 1){
i++;
}
while(valeur != 1){
printf("Donnez une valeur : ");
valeur = scanf("%f", tab[i]);
if (valeur == 1 ){
i++;
}
if (i%2 == 0){
lin = lin +2;
tab = (float*) realloc(tab, lin);
}
int taille = strlen(tab);
}
for(i=0;i<taille;i++){
fin =0;
for(a=0; a<taille; a++){
if (tab[i] == tab[a] && a != i){
a==taille;
fin = 1;
}
}
if(fin == 0){
printf("%d ", tab[i]);
}
}
printf("\n");
return 0;
}

22
DEV1.1S/TP02/complexes.c Normal file
View File

@ -0,0 +1,22 @@
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(void){
struct crocs{
double x;
double y;
double i = sqrt(-1);
double z = x+y*i;
}
double val1;
double val2;
double res;
double eee;
printf("Donnez une valeur : ");
scanf("%f", &val1);
printf("Donnez une deuxième valeur : ");
scanf("%f", &val2);
struct crocs cars = {val1;val2;eee;res}
printf("%f", res);
return EXIT_SUCCESS;
}

14
DEV1.1S/TP02/date.c Normal file
View File

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

14
DEV1.1S/TP02/groupe.c Normal file
View File

@ -0,0 +1,14 @@
#include <stdio.h>
#include <stdlib.h>
#include <grp.h>
#include <sys/types.h>
#include <string.h>
int main(void){
int i = 0;
struct group* groupe = getgrnam("students22");
while(groupe->gr_mem[i] != NULL){
printf("%s", groupe->gr_mem[i]);
i++;
}
return EXIT_SUCCESS;
}

15
DEV1.1S/TP02/tailles.c Normal file
View File

@ -0,0 +1,15 @@
#include <stdio.h>
#include <stdlib.h>
int main(void){
struct tailles{
char* a;
char* b;
char* c;
};
struct tailles chaine = {"e","ab","c"};
int res = sizeof(chaine);
printf("%d\n", res);
return EXIT_SUCCESS;
}

59
DEV1.1S/TP03/challenger.c Normal file
View File

@ -0,0 +1,59 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void){
FILE* fichier;
fichier = fopen("top10", "r");
int tab[10];
char oui[30];
int i;
int a;
int alt = 4;
for(i=0; i<10; i++){
fread(&tab[i], sizeof(int), 1,fichier);
fread(&oui[i*3], 1, 3, fichier);
}
for(i=0; i<10;i++){
printf("%9d ", tab[i]);
printf("%c", oui[i*3]);
printf("%c", oui[i*3+1]);
printf("%c\n", oui[i*3+2]);
}
fclose(fichier);
int score;
char pseudo;
int emplacement;
printf("Donnez un score : ");
scanf("%7d", &score);
printf("Donnez un pseudo : ");
scanf("%c", &pseudo);
if(strlen(pseudo) != 3){
scanf("%c", &pseudo);
}
for(i=0; i<10; i++){
if (score > tab[i]){
emplacement = i;
i =10;
}
}
for(i=10; i>=emplacement; i--){
tab[i] == tab[i]+1;
}
tab[emplacement] = score;
emplacement = emplacement+3;
for(i=30; i<= emplacement; i--){
oui[i] == oui[i+3];
}
for(i=0; i<3; i++){
oui[emplacement] == pseudo[i];
emplacement++;
}
printf("%d",tab);
printf("%c", oui);
return EXIT_SUCCESS;
}
/*[004867123,41545574]
[B,O,B,<,O,>]
004867123 BOB
41545574 <O>*/

27
DEV1.1S/TP03/records.c Normal file
View File

@ -0,0 +1,27 @@
#include <stdio.h>
#include <stdlib.h>
int main(void){
FILE* fichier;
fichier = fopen("top10", "r");
int tab[10];
char oui[30];
int i;
int a;
int alt = 4;
for(i=0; i<10; i++){
fread(&tab[i], sizeof(int), 1,fichier);
fread(&oui[i*3], 1, 3, fichier);
}
for(i=0; i<10;i++){
printf("%9d ", tab[i]);
printf("%c", oui[i*3]);
printf("%c", oui[i*3+1]);
printf("%c\n", oui[i*3+2]);
}
fclose(fichier);
return EXIT_SUCCESS;
}
/*[004867123,41545574]
[B,O,B,<,O,>]
004867123 BOB
41545574 <O>*/

BIN
DEV1.1S/TP03/top10 Normal file

Binary file not shown.

42
DEV1.1S/TPLC/exo1.c Normal file
View File

@ -0,0 +1,42 @@
-0.ZP+#include <stdio.h>
#include <stdlib.h>
#include <time.h>
struct mail{
int valeur;
struct mail* suivant;
};
typedef struct mail maillon;
void afficher(maillon* premier) {
maillon* p;
for(p = premier; p != NULL; p = p->suivant)
printf("%d ", p->valeur);
}
maillon* ajouter_debut(maillon* premier, int nouveau) {
maillon* p = (maillon*) malloc(sizeof(maillon));
if (p) {
p->suivant = premier;
p->valeur = nouveau;
}
return p;
}
int main(int argc, char const *argv[]){
maillon* vide= NULL;
srand(time(NULL));
int i;
int stock;
int maximilien = 111;
for(i=0; i<10; i++){
stock = 111+random()%889;
vide = ajouter_debut(vide , stock);
if(stock > maximilien){
maximilien = stock;
}
}
afficher(vide);
printf("\n%d\n", maximilien);
return 0;
}

42
DEV1.1S/TPLC/exo2.c Normal file
View File

@ -0,0 +1,42 @@
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
struct mail{
int valeur;
struct mail* suivant;
};
typedef struct mail maillon;
void afficher(maillon* premier) {
maillon* p;
for(p = premier; p != NULL; p = p->suivant)
printf("%d ", p->valeur);
}
maillon* ajouter_debut(maillon* premier, int nouveau) {
maillon* p = (maillon*) malloc(sizeof(maillon));
if (p) {
p->suivant = premier;
p->valeur = nouveau;
}
return p;
}
int main(int argc, char const *argv[]){
maillon* vide= NULL;
srand(time(NULL));
int i;
int stock;
int maximilien = 111;
for(i=0; i<10; i++){
stock = 111+random()%889;
vide = ajouter_debut(vide , stock);
if(stock > maximilien){
maximilien = stock;
}
}
afficher(vide);
printf("\n%d\n", maximilien);
return 0;
}

52
DEV1.1S/TPLC/test.c Normal file
View File

@ -0,0 +1,52 @@
#include <stdio.h>
#include <stdlib.h>
struct mail{
int valeur;
struct mail* suivant;
};
typedef struct mail maillon;
void afficher(maillon* premier) {
maillon* p;
for(p = premier; p != NULL; p = p->suivant)
printf("%d ", p->valeur);
}
maillon* ajouter_debut(maillon* premier, int nouveau) {
maillon* p = (maillon*) malloc(sizeof(maillon));
if (p) {
p->suivant = premier;
p->valeur = nouveau;
}
return p;
}
void delete(int v, maillon* vide){
maillon* m;
m=vide;
int i;
for (i=0;i<v-2;i++){
m = m->suivant;
}
free(m->suivant);
m->suivant=NULL;
}
int main(int argc, char const *argv[]){
maillon* vide= NULL;
maillon* m;
int i;
for(i=1; i<4; i++){
vide = ajouter_debut(vide , i);
}
afficher(vide);
printf("\n");
delete(3, vide);
afficher(vide);
printf("\n");
return 0;
}
/*Q7d8s6dp&#*/

44
DEV1.1S/TPPILE/chainee.c Normal file
View File

@ -0,0 +1,44 @@
#include <stdio.h>
#include <stdlib.h>
struct maillon_ {
char c;
struct maillon_* prev;
};
typedef struct maillon_ maillon;
typedef maillon* pile;
void push(pile* p, char c) {
maillon* m = calloc(1, sizeof(maillon));
m->c = c;
m->prev = *p;
*p = m;
}
char pop(pile* p) {
char c = (*p)->c;
*p = (*p)->prev;
return c;
}
int empty(pile p) {
return p == NULL;
}
char top(pile p) {
return p->c;
}
void clear(pile* p) {
*p = NULL;
}
pile create() {
return NULL;
}
void destroy(pile* p) {
free(p);
}

View File

@ -0,0 +1,47 @@
#include <stdio.h>
#include <stdlib.h>
struct pile_ {
char* tab;
int size;
};
typedef struct pile_ pile;
void push(pile* p, char c) {
(p->tab)[p->size] = c;
p->size++;
p->tab = realloc(p->tab, (p->size)+1);
}
char pop(pile* p) {
char c = (p->tab)[p->size-1];
p->size--;
p->tab = realloc(p->tab, (p->size)+1);
return c;
}
int empty(pile p) {
return p.size == 0;
}
char top(pile p) {
return (p.tab)[(p.size) - 1];
}
void clear(pile* p) {
free(p->tab);
p->tab = calloc(1, sizeof(int));
p->size = 0;
}
pile create() {
pile* p = (calloc(1, sizeof(pile)));
p->tab = calloc(1, sizeof(char));
p->size = 0;
return *p;
}
pile destroy(pile* p) {
free(p);
}

34
DEV1.1S/TPPILE/file.c Normal file
View File

@ -0,0 +1,34 @@
#include <stdio.h>
#include <stdlib.h>
struct maillon_ {
char c;
struct maillon_* next;
};
typedef struct maillon_ maillon;
typedef maillon* file;
void push(file* f, char c) {
maillon* m = calloc(1, sizeof(maillon));
m->c = c;
if (*f == NULL) {
*f = m;
} else {
file* start = f;
file ff = *f;
while (ff->next != NULL) ff = ff->next;
ff->next = m;
f = start;
}
}
char pop(file* f) {
char c = (*f)->c;
*f = (*f)->next;
}
int empty(file f) {
return f == NULL;
}

0
DEV1.1S/TPREC/exo2.c Normal file
View File

13
DEV1.1S/TPREC/fibonacci.c Normal file
View File

@ -0,0 +1,13 @@
#include <stdio.h>
#include <stdlib.h>
int fib(int n) {
if (n > 1) return n + fib(n-1);
else if (n == 1) return 1;
else return 0;
}
int main(void) {
fib(15);
return EXIT_SUCCESS;
}

17
DEV1.1S/TPREC/tableau.c Normal file
View File

@ -0,0 +1,17 @@
#include <stdio.h>
#include <stdlib.h>
void printTable(double* t, int n) {
if (n > 0) {
printf("%.5lf", *t);
if (n > 1) printf(", ");
printTable(t+1, n-1);
} else puts("");
}
int main(void) {
double t[5] = {1.72, 5.28, 9.025, 36.14, 3.14159};
printTable(t, 5);
return EXIT_SUCCESS;
}

BIN
DEV2.1/TP01/Bonjour.class Normal file

Binary file not shown.

27
DEV2.1/TP01/Bonjour.java Normal file
View File

@ -0,0 +1,27 @@
/**
* Cette classe est une simple coquille pour recevoir la méthode principale
*
* @version 1.1 09 March 2014
* @author Luc Hernandez
*/
public class Bonjour {
/**
* Affiche &laquo;Bonjour !&raquo;
*
* @param args la liste des arguments de la ligne de commande (inutilisée ici)
*/
public static void main(String[] args) {
int a = 12;
long b = 124L;
boolean c = true;
char d = 'E';
float e = 1.2f;
double f = 38.12;
byte g = 0;
short h = 0;
System.out.println(a+" "+b+" "+c+" "+d+" "+e+" "+f+" "+g);
}
}

BIN
DEV2.1/TP01/Grille.class Normal file

Binary file not shown.

10
DEV2.1/TP01/Grille.java Normal file
View File

@ -0,0 +1,10 @@
public class Grille{
public static void main(String[] args) {
System.out.println("+-+-+");
int a = Integer.parseInt(args[0]);
for (int i=0; i< a; i++){
System.out.println("| | |");
System.out.println("+-+-+");
}
}
}

BIN
DEV2.1/TP01/Somme.class Normal file

Binary file not shown.

10
DEV2.1/TP01/Somme.java Normal file
View File

@ -0,0 +1,10 @@
public class Somme{
public static void main(String[] args){
int somme = 0;
for(String i : args){
int nombre = Integer.parseInt(i);
somme+=nombre;
}
System.out.println(somme);
}
}

BIN
DEV2.1/TP01/exo2.class Normal file

Binary file not shown.

7
DEV2.1/TP01/exo2.java Normal file
View File

@ -0,0 +1,7 @@
public class exo2{
public static void main(String[] args) {
for(String i : args){
System.out.println("Bonjour " + i);
}
}
}

BIN
DEV2.1/TP01/tri.class Normal file

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More