update
This commit is contained in:
@@ -6,11 +6,3 @@ lightness.o : lightness.c lightness.h
|
||||
|
||||
carre.o : carre.c lightness.h
|
||||
gcc -ansi -pedantic -c carre.c
|
||||
|
||||
### REGLES ESSENTIELLES ###
|
||||
|
||||
but : carre
|
||||
|
||||
### REGLES OPTIONELLES ###
|
||||
run : but
|
||||
./carre
|
@@ -4,14 +4,15 @@
|
||||
|
||||
#include "lightness.h"
|
||||
|
||||
#define LIGHT 0
|
||||
#define DARK 1
|
||||
#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;
|
||||
|
@@ -1,5 +1,4 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "lightness.h"
|
||||
|
||||
int lightness(void) {
|
||||
|
@@ -3,9 +3,6 @@
|
||||
|
||||
#define LIGHT 0
|
||||
#define DARK 1
|
||||
#define LIGHT_RED 217
|
||||
#define LIGHT_GREEN 157
|
||||
#define LIGHT_BLUE 147
|
||||
|
||||
int lightness(void);
|
||||
|
||||
|
8
DEV.1.1/CM2/CM2A/Makefile
Normal file
8
DEV.1.1/CM2/CM2A/Makefile
Normal file
@@ -0,0 +1,8 @@
|
||||
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
|
BIN
DEV.1.1/CM2/CM2A/reitne
Normal file
BIN
DEV.1.1/CM2/CM2A/reitne
Normal file
Binary file not shown.
@@ -1,2 +0,0 @@
|
||||
Adresse : 0x00 0x01 0x02 0x03
|
||||
Valeur : 0x12 0x34 0x56 0x78
|
17
DEV.1.1/CM2/CM2B/1.Décomposition.c
Normal file
17
DEV.1.1/CM2/CM2B/1.Décomposition.c
Normal file
@@ -0,0 +1,17 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
long int x, y;
|
||||
ldiv_t result;
|
||||
|
||||
sscanf(argv[1], "%ld", &x);
|
||||
sscanf(argv[2], "%ld", &y);
|
||||
|
||||
result = ldiv(x, y);
|
||||
printf("quotient : %ld\n", result.quot);
|
||||
printf("reste : %ld\n", result.rem);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
8
DEV.1.1/CM2/CM2B/2.Division/Makefile
Normal file
8
DEV.1.1/CM2/CM2B/2.Division/Makefile
Normal file
@@ -0,0 +1,8 @@
|
||||
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
|
47
DEV.1.1/CM2/CM2B/2.Division/carre.c
Normal file
47
DEV.1.1/CM2/CM2B/2.Division/carre.c
Normal file
@@ -0,0 +1,47 @@
|
||||
#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;
|
||||
}
|
12
DEV.1.1/CM2/CM2B/2.Division/hue.c
Normal file
12
DEV.1.1/CM2/CM2B/2.Division/hue.c
Normal file
@@ -0,0 +1,12 @@
|
||||
#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;
|
||||
}
|
||||
}
|
10
DEV.1.1/CM2/CM2B/2.Division/hue.h
Normal file
10
DEV.1.1/CM2/CM2B/2.Division/hue.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#ifndef HUE_H
|
||||
#define HUE_H
|
||||
|
||||
#define RED 1
|
||||
#define GREEN 2
|
||||
#define BLUE 4
|
||||
|
||||
int hue(void);
|
||||
|
||||
#endif /*HUE_H*/
|
Reference in New Issue
Block a user