update
This commit is contained in:
@@ -1,26 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
long int dividende, diviseur;
|
||||
ldiv_t result;
|
||||
|
||||
if (argc < 3) {
|
||||
printf("Usage: %s <dividend> <divisor>\n", argv[0]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
sscanf(argv[1], "%ld", ÷nde);
|
||||
sscanf(argv[2], "%ld", &diviseur);
|
||||
|
||||
if (diviseur == 0) {
|
||||
printf("Erreur : le diviseur ne peut pas être zéro.\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
result = ldiv(dividende, diviseur);
|
||||
printf("quotient : %ld\n", result.quot);
|
||||
printf("reste : %ld\n", result.rem);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
@@ -1,8 +0,0 @@
|
||||
carre : carre.o lightness.o
|
||||
gcc -ansi -pedantic -o carre carre.o lightness.o
|
||||
|
||||
lightness.o : lightness.c lightness.h
|
||||
gcc -ansi -pedantic -c lightness.c
|
||||
|
||||
carre.o : carre.c lightness.h
|
||||
gcc -ansi -pedantic -c carre.c
|
Binary file not shown.
@@ -1,49 +0,0 @@
|
||||
#include<stdlib.h>
|
||||
#include<stdio.h>
|
||||
#include<time.h>
|
||||
|
||||
#include "lightness.h"
|
||||
|
||||
#define RED 1
|
||||
#define GREEN 2
|
||||
#define BLUE 4
|
||||
#define DARK_RED 124
|
||||
#define DARK_GREEN 34
|
||||
#define DARK_BLUE 19
|
||||
#define LIGHT_RED 217
|
||||
#define LIGHT_GREEN 157
|
||||
#define LIGHT_BLUE 147
|
||||
|
||||
int hue(void) {
|
||||
int choice = rand()%3;
|
||||
if (choice == 0) {
|
||||
return RED;
|
||||
} else if (choice == 1) {
|
||||
return GREEN;
|
||||
} else /* if (choice == 2) */ {
|
||||
return BLUE;
|
||||
}
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
int l, c, v;
|
||||
|
||||
srand(time(NULL));
|
||||
l = lightness();
|
||||
c = hue();
|
||||
|
||||
if (c == RED) {
|
||||
v = (l == LIGHT) ? LIGHT_RED : DARK_RED;
|
||||
} else if (c == GREEN) {
|
||||
v = (l == LIGHT) ? LIGHT_GREEN : DARK_GREEN;
|
||||
} else /* if (c == BLUE) */ {
|
||||
v = (l == LIGHT) ? LIGHT_BLUE : DARK_BLUE;
|
||||
}
|
||||
|
||||
printf("┏━━━━┓\n");
|
||||
printf("┃\33[48;5;%dm \33[m┃\n", v);
|
||||
printf("┃\33[48;5;%dm \33[m┃\n", v);
|
||||
printf("┗━━━━┛\n");
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
@@ -1,10 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include "lightness.h"
|
||||
|
||||
int lightness(void) {
|
||||
if (time(NULL)%2) {
|
||||
return LIGHT;
|
||||
} else {
|
||||
return DARK;
|
||||
}
|
||||
}
|
@@ -1,10 +0,0 @@
|
||||
#ifndef LIGHTNESS_H
|
||||
#define LIGHTNESS_H
|
||||
|
||||
#define LIGHT 0
|
||||
#define DARK 1
|
||||
|
||||
int lightness(void);
|
||||
|
||||
|
||||
#endif /*LIGHTNESS_H*/
|
@@ -1,34 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(void){
|
||||
FILE *fic = fopen("reitne.txt", "r");
|
||||
char lettre[256];
|
||||
int i;
|
||||
|
||||
if(fic == NULL){
|
||||
exit(1);
|
||||
}
|
||||
|
||||
while(fgets(lettre, 255, fic) != NULL){
|
||||
for(i=0;i<256;i++){
|
||||
|
||||
if (lettre[i] == 'x' && lettre[i-1] == 0){
|
||||
/* printf("%d\n", lettre[i-1]/lettre[i+1]);*/
|
||||
printf("Bonjour");
|
||||
|
||||
}else if(fgets(lettre,255,fic)){
|
||||
printf("");
|
||||
|
||||
}
|
||||
}
|
||||
printf("%s", lettre);
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
fclose(fic);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -1,8 +0,0 @@
|
||||
carre : carre.o lightness.o
|
||||
gcc -ansi -pedantic -o carre carre.o lightness.o
|
||||
|
||||
lightness.o : lightness.c lightness.h
|
||||
gcc -ansi -pedantic -c lightness.c
|
||||
|
||||
carre.o : carre.c lightness.h
|
||||
gcc -ansi -pedantic -c carre.c
|
Binary file not shown.
@@ -1,8 +0,0 @@
|
||||
carre : carre.o hue.o
|
||||
gcc -ansi -pedantic -o carre carre.o hue.o
|
||||
|
||||
hue.o : hue.c hue.h
|
||||
gcc -ansi -pedantic -c hue.c
|
||||
|
||||
carre.o : carre.c hue.h
|
||||
gcc -ansi -pedantic -c carre.c
|
@@ -1,47 +0,0 @@
|
||||
#include<stdlib.h>
|
||||
#include<stdio.h>
|
||||
#include<time.h>
|
||||
|
||||
#include "hue.h"
|
||||
|
||||
#define LIGHT 0
|
||||
#define DARK 1
|
||||
#define LIGHT_RED 217
|
||||
#define DARK_RED 124
|
||||
#define LIGHT_GREEN 157
|
||||
#define DARK_GREEN 34
|
||||
#define LIGHT_BLUE 147
|
||||
#define DARK_BLUE 19
|
||||
|
||||
int lightness(void) {
|
||||
if (time(NULL)%2) {
|
||||
return LIGHT;
|
||||
} else {
|
||||
return DARK;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(void) {
|
||||
int l, c, v;
|
||||
|
||||
srand(time(NULL));
|
||||
l = lightness();
|
||||
c = hue();
|
||||
|
||||
if (c == RED) {
|
||||
v = (l == LIGHT) ? LIGHT_RED : DARK_RED;
|
||||
} else if (c == GREEN) {
|
||||
v = (l == LIGHT) ? LIGHT_GREEN : DARK_GREEN;
|
||||
} else /* if (c == BLUE) */ {
|
||||
v = (l == LIGHT) ? LIGHT_BLUE : DARK_BLUE;
|
||||
}
|
||||
|
||||
printf("┏━━━━┓\n");
|
||||
printf("┃\33[48;5;%dm \33[m┃\n", v);
|
||||
printf("┃\33[48;5;%dm \33[m┃\n", v);
|
||||
printf("┗━━━━┛\n");
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
@@ -1,12 +0,0 @@
|
||||
#include "hue.h"
|
||||
|
||||
int hue(void) {
|
||||
int choice = rand()%3;
|
||||
if (choice == 0) {
|
||||
return RED;
|
||||
} else if (choice == 1) {
|
||||
return GREEN;
|
||||
} else /* if (choice == 2) */ {
|
||||
return BLUE;
|
||||
}
|
||||
}
|
@@ -1,10 +0,0 @@
|
||||
#ifndef HUE_H
|
||||
#define HUE_H
|
||||
|
||||
#define RED 1
|
||||
#define GREEN 2
|
||||
#define BLUE 4
|
||||
|
||||
int hue(void);
|
||||
|
||||
#endif /*HUE_H*/
|
8
DEV.1.1/CM2/Makefile
Normal file
8
DEV.1.1/CM2/Makefile
Normal file
@@ -0,0 +1,8 @@
|
||||
moyenne : ex2.o moyenne_val.o
|
||||
gcc -ansi -pedantic moyenne ex2.o moyenne_val.o
|
||||
|
||||
moyenne_val.o : moyenne_val.c moyenne_val.h
|
||||
gcc -ansi -pedantic moyenne_val.c
|
||||
|
||||
ex2.o : ex2.c moyenne_val.h
|
||||
gcc -ansi -pedantic ex2.c
|
15
DEV.1.1/CM2/ex1.c
Normal file
15
DEV.1.1/CM2/ex1.c
Normal file
@@ -0,0 +1,15 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
struct stat buffer;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < argc; i++){
|
||||
printf("%d\n",argc);
|
||||
}
|
||||
|
||||
taille = strtol(argv)
|
||||
printf("%jd octets\n",buffer.st_size);
|
||||
}
|
19
DEV.1.1/CM2/ex2.c
Normal file
19
DEV.1.1/CM2/ex2.c
Normal file
@@ -0,0 +1,19 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "moyenne_val.h"
|
||||
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
int i, j, taille, tab[];
|
||||
for (i = 0; i <= argc; i++){
|
||||
taille = i;
|
||||
|
||||
}
|
||||
|
||||
for(i=0; i <= taille; i++){
|
||||
tabl_val[][i] =
|
||||
/*La fonction avait initialement pour but de mettre chaque élément dans un tableau*/
|
||||
}
|
||||
moyenne_val(taille, argv);
|
||||
}
|
18
DEV.1.1/CM2/moyenne_val.c
Normal file
18
DEV.1.1/CM2/moyenne_val.c
Normal file
@@ -0,0 +1,18 @@
|
||||
#include <stdio.h>
|
||||
#include "moyenne_val.h"
|
||||
|
||||
int moyenne_tab(int tab[], int taille){
|
||||
int i, moyenne_sum, somme = 0;
|
||||
|
||||
for(i=0; i<=taille; i++){
|
||||
somme += tab[i];
|
||||
}
|
||||
moyenne_sum = somme/taille;
|
||||
printf("Moyenne : %d", moyenne_sum);
|
||||
}
|
||||
|
||||
int moyenne_val(int taille ){
|
||||
int i, tabl_val[] ;
|
||||
|
||||
moyenne_tab(tabl_val, taille);
|
||||
}
|
7
DEV.1.1/CM2/moyenne_val.h
Normal file
7
DEV.1.1/CM2/moyenne_val.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#ifndef MOYENNE_VAL
|
||||
#define MOYENNE_VAL
|
||||
|
||||
int moyenne_tab(int tab[], int taille);
|
||||
int moyenne_val(int taille);
|
||||
|
||||
#endif /*MOYENNE_VAL*/
|
BIN
DEV.1.1/CM2/srivasta_CM2.tar.gz
Normal file
BIN
DEV.1.1/CM2/srivasta_CM2.tar.gz
Normal file
Binary file not shown.
Reference in New Issue
Block a user