colors update !
This commit is contained in:
37
polynome.c
37
polynome.c
@@ -2,6 +2,8 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
#include "polynome.h"
|
#include "polynome.h"
|
||||||
|
|
||||||
enum STATUS Calcul_Delta(Poly* poly) {
|
enum STATUS Calcul_Delta(Poly* poly) {
|
||||||
@@ -122,21 +124,42 @@ enum STATUS Dessiner_Graph(Poly* poly) {
|
|||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//wow, much colors ! https://www.codeproject.com/Tips/5255355/How-to-Put-Color-on-Windows-Console
|
||||||
if (roundf(y) == j) {
|
if (roundf(y) == j) {
|
||||||
if (j == 0) {
|
if (j == 0) {
|
||||||
printf("-o--");
|
if (use_colors) {
|
||||||
|
printf("-\033[36m\033[1mo\033[0m--");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printf("-o--");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printf(" o ");
|
if (use_colors) {
|
||||||
|
printf("\033[36m\033[1m o \033[0m");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printf(" o ");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (roundf(y2) == j) {
|
if (roundf(y2) == j) {
|
||||||
if (j == 0) {
|
if (j == 0) {
|
||||||
printf("-u--");
|
if (use_colors) {
|
||||||
|
printf("-\033[92m\033[1mu\033[0m--");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printf("-u--");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printf(" u ");
|
if (use_colors) {
|
||||||
|
printf("\033[92m\033[1m u \033[0m");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printf(" u ");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -178,7 +201,7 @@ enum STATUS Dessiner_Graph(Poly* poly) {
|
|||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
if (argc < 4) {
|
if (argc < 4) {
|
||||||
fprintf(stderr, "%s", "[-] usage : poly.exe a b c\n");
|
fprintf(stderr, "%s", "[-] usage : poly.exe a b c [--colors]\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,6 +209,10 @@ int main(int argc, char* argv[]) {
|
|||||||
float b = atof(argv[2]);
|
float b = atof(argv[2]);
|
||||||
float c = atof(argv[3]);
|
float c = atof(argv[3]);
|
||||||
|
|
||||||
|
if (argc > 4) {
|
||||||
|
use_colors = true;
|
||||||
|
}
|
||||||
|
|
||||||
printf("[+] Processing %.3fx^2%.3fx%.3f\n", a, b, c);
|
printf("[+] Processing %.3fx^2%.3fx%.3f\n", a, b, c);
|
||||||
|
|
||||||
Poly* poly = malloc(sizeof(Poly));
|
Poly* poly = malloc(sizeof(Poly));
|
||||||
|
|||||||
@@ -28,5 +28,6 @@ enum STATUS Calcul_Derivee(Poly* poly, float x, float *out);
|
|||||||
#define LONGUEUR_X 20
|
#define LONGUEUR_X 20
|
||||||
#define LONGUEUR_Y 20
|
#define LONGUEUR_Y 20
|
||||||
void Dessiner_Separateur();
|
void Dessiner_Separateur();
|
||||||
|
bool use_colors = false;
|
||||||
enum STATUS Dessiner_Graph(Poly* poly);
|
enum STATUS Dessiner_Graph(Poly* poly);
|
||||||
int main();
|
int main();
|
||||||
Reference in New Issue
Block a user