diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..7769823df4a5afdd12fda125dbf55fd9af876576
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,83 @@
+
+# Created by https://www.toptal.com/developers/gitignore/api/c,visualstudiocode
+# Edit at https://www.toptal.com/developers/gitignore?templates=c,visualstudiocode
+
+### C ###
+# Prerequisites
+*.d
+
+# Object files
+*.o
+*.ko
+*.obj
+*.elf
+
+# Linker output
+*.ilk
+*.map
+*.exp
+
+# Precompiled Headers
+*.gch
+*.pch
+
+# Libraries
+*.lib
+*.a
+*.la
+*.lo
+
+# Shared objects (inc. Windows DLLs)
+*.dll
+*.so
+*.so.*
+*.dylib
+
+# Executables
+*.exe
+*.out
+*.app
+*.i*86
+*.x86_64
+*.hex
+
+# Debug files
+*.dSYM/
+*.su
+*.idb
+*.pdb
+
+# Kernel Module Compile Results
+*.mod*
+*.cmd
+.tmp_versions/
+modules.order
+Module.symvers
+Mkfile.old
+dkms.conf
+
+### VisualStudioCode ###
+.vscode/*
+!.vscode/settings.json
+!.vscode/tasks.json
+!.vscode/launch.json
+!.vscode/extensions.json
+*.code-workspace
+
+# Local History for Visual Studio Code
+.history/
+
+### VisualStudioCode Patch ###
+# Ignore all local history of files
+.history
+.ionide
+
+# Support for Project snippet scope
+!.vscode/*.code-snippets
+
+# End of https://www.toptal.com/developers/gitignore/api/c,visualstudiocode
+
+# Custom gitignore for project
+main
+cmake-build-debug
+.idea
\ No newline at end of file
diff --git a/README.md b/README.md
index 7ecf3ff428c8c5e4bdd7167aac6d22af4685f53b..969b7cdef3d5be3462f3eb11b128a93cae8a3ab5 100644
--- a/README.md
+++ b/README.md
@@ -1,92 +1,145 @@
-# kmeans
+# K-means
+Travail réalisé par : Dario GENGA
 
+Bref rappel de l'énoncé :
+## But
 
+Le but de ce travail est d'implémenter la méthode des k-moyennes
+pour partitionner des données de façon non supervisée.
 
-## Getting started
+# Implémentation
 
-To make it easy for you to get started with GitLab, here's a list of recommended next steps.
 
-Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
+## Format d'entrée
 
-## Add your files
+L'entrée sera un fichier spécifié en argument au programme.
+Si aucun argument est fourni, le fichier d'entrée sera l'entrée standard (stdin).
 
-- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
-- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
+Le fichier contiendra:
 
+- sur la première ligne, le nombre de dimensions des points de l'ensemble
+- sur la deuxième ligne, le nombre de clusters voulu
+- un point par ligne, sous forme de N valeurs séparées par des virgules
+
+```txt
+<nombre de dimensions>
+<nombre de clusters>
+x1,x2,...,xn
+y1,y2,...,yn
+...
 ```
-cd existing_repo
-git remote add origin https://gitedu.hesge.ch/dario.genga/kmeans.git
-git branch -M main
-git push -uf origin main
+
+
+## Format de sortie
+
+La sortie sera écrite dans un fichier spécifié en argument au programme.
+Si aucun argument est fourni, le fichier de sortie sera la sortie standard (stdout).
+
+Le fichier contiendra:
+
+- sur la première ligne, le nombre de dimensions des points de l'ensemble
+- sur la deuxième ligne, le nombre de clusters
+- une étoile "*" signifie le début d'un cluster
+- pour chaque étoile, une liste de points appartenant au même cluster,
+  avec le même format que les points d'entrée
+
+```txt
+<nombre de dimensions>
+<nombre de clusters>
+*
+x1,x2,...,xn
+y1,y2,...,yn
+...
+*
+z1,z2,...,zn
+t1,t2,...,tn
+...
 ```
 
-## Integrate with your tools
 
-- [ ] [Set up project integrations](https://gitedu.hesge.ch/dario.genga/kmeans/-/settings/integrations)
+## Interface utilisateur
+
+Le programme fonctionnera entièrement en ligne de commande.
+Les formats d'entrée et de sortie ont été choisis pour être
+"pipe-friendly", ce qui donne un degré de flexibilité supplémentaire
+à l'utilisateur.
+
+
+## Déroulement de l'exécution du programme
+
+- appel de la commande avec éventuellement le passage des
+  fichiers d'entrée et de sortie en argument
+- initialisation du nombre de dimensions de notre univers
+- allocation de la mémoire pour les K groupes
+- chargement des données d'entrée en mémoire
+  (possibilité d'intervertir ce point avec le précédent)
+- application de l'algorithme k-means
+- écriture des résultats formatés dans le fichier de sortie
+  (ou de la sortie standard, selon les arguments passés au programme)
+
+
+## Fonctions à implémenter
 
-## Collaborate with your team
+Il faut absolument implémenter les fonctionnalités suivantes:
 
-- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
-- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
-- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
-- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
-- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
+- gestion des arguments en ligne de commande
+- lecture et écriture de fichiers formatés
+- initialisation aléatoire et/ou intelligente des centroïdes
+- au moins trois fonctions de calcul de similarité / "distance" entre deux points
+- calcul du centre de gravité (_centroïde_) d'une partition
+- les étapes de l'algorithme k-means
 
-## Test and Deploy
 
-Use the built-in continuous integration in GitLab.
+## Travail supplémentaire possible
 
-- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
-- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
-- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
-- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
-- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
+### Affichage en temps réel
 
-***
+Au lieu d'afficher uniquement le résultat final, il s'agirait
+d'afficher chaque étape effectuée afin de pouvoir observer
+l'algorithme en action.
 
-# Editing this README
+### Déterminer le nombre de clusters optimal
 
-When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!).  Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template.
+Faire des recherches sur les méthodes permettant d'optimiser
+le nombre de clusters et les implémenter.
+Si l'utilisation de cette fonctionnalité est le souhait de l'utilisateur,
+un seul caractère non-numérique est utilisé en lieu du nombre
+de clusters souhaité.
+De légères modifications du format sont envisageables pour autant
+qu'elles soient justifiées.
 
-## Suggestions for a good README
-Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
+### Interface graphique
 
-## Name
-Choose a self-explaining name for your project.
+On peut imaginer créer une interface graphique permettant de visualiser
+le résultat dans une fenêtre graphique.
+Pour cela, une option serait de mettre à profit la librairie gfx
+utilisée pendant les labos de physique.
 
-## Description
-Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
 
-## Badges
-On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
+## Vérification du travail réalisé
 
-## Visuals
-Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
+Il serait bon de mettre en place des tests unitaires pour les
+fonctions implémentées.
 
-## Installation
-Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
+On implémente un algorithme non supervisé.
+Il est donc difficile de vérifier si le résultat obtenu est "correct".
+Néanmoins, un point placé dans le mauvais groupe est facile à identifier
+par comparaison des distances du point aux différents centroïdes.
 
-## Usage
-Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
 
-## Support
-Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
+# Travail à rendre
 
-## Roadmap
-If you have ideas for releases in the future, it is a good idea to list them in the README.
+- repo git contenant le code réalisé
+- présentation du travail à l'aide d'un support (projection)
+- démonstration du programme
 
-## Contributing
-State if you are open to contributions and what your requirements are for accepting them.
 
-For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
+# Références
 
-You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
+https://www.editions-eni.fr/livre/le-machine-learning-avec-python-de-la-theorie-a-la-pratique-9782409031816/extrait-du-livre.pdf
 
-## Authors and acknowledgment
-Show your appreciation to those who have contributed to the project.
+https://towardsdatascience.com/k-means-clustering-algorithm-applications-evaluation-methods-and-drawbacks-aa03e644b48a
 
-## License
-For open source projects, say how it is licensed.
+https://towardsmachinelearning.org/k-means/
 
-## Project status
-If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
+https://vitalflux.com/elbow-method-silhouette-score-which-better/
diff --git a/enonce.pdf b/enonce.pdf
new file mode 100644
index 0000000000000000000000000000000000000000..6aa6e44ae99ea8be792f0572920be9dbc4af889d
Binary files /dev/null and b/enonce.pdf differ
diff --git a/kmeans.c b/kmeans.c
new file mode 100644
index 0000000000000000000000000000000000000000..a5885bcfa5291f0ec7701122682d7eb987ab738d
--- /dev/null
+++ b/kmeans.c
@@ -0,0 +1,4 @@
+// Project : K-means
+// Author : Dario GENGA
+
+#include "kmeans.h"
diff --git a/kmeans.h b/kmeans.h
new file mode 100644
index 0000000000000000000000000000000000000000..df7b8bce52179e86253bd138a8e5940ad8606a12
--- /dev/null
+++ b/kmeans.h
@@ -0,0 +1,112 @@
+// Project : K-means
+// Author : Dario GENGA
+
+#ifndef _KMEANS_M
+#define _KMEANS_M
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <math.h>
+
+/// A group who contains points.
+typedef struct _cluster {
+    /// The center of gravity of the cluster.
+    struct _point* centroid;
+    /// The color representing the cluster.
+    int color;
+} cluster;
+
+/// A point in the universe, which represents a data.
+typedef struct _point {
+    /// The coordinates of the point.
+    double* value;
+    /// The cluster who contains the point.
+    struct _cluster* cluster;
+    /// The color to use to draw the point.
+    int color;
+    /// A label representing the group to which belongs te point. Only used for testing.
+    char* label;
+} point;
+
+/// A universe who contains data, of points, and clusters who contains the data.
+typedef struct _kmeans {
+    /// The number of clusters in the universe.
+    int k;
+    /// A 'k' size array of clusters, who contains the data.
+    struct _cluster* clusters_array;
+    /// An array of points, representing the data in the universe.
+    struct _point** points_array;
+    /// The number of points in the universe.
+    int nb_points;
+} kmeans;
+
+/// Create the kmeans universe.
+/// \param k The number of clusters in the universe.
+/// \param data The array of points
+/// \param nb_points The number of points in the universe.
+/// \return The kmeans object of the universe.
+kmeans kmeans_create(int k, point** data, int nb_points);
+
+/// Create a point.
+/// \param value The coordinates of the point.
+/// \return The point objet initialized with its coordinates
+point point_create(double* value);
+
+/// Create a cluster.
+/// \param centroid The point representing the center of gravity of the cluster.
+/// \return The cluster object.
+kmeans cluster_create(point centroid);
+
+/// Initialize the universe with the file specified in argument when starting the program. If no arguments has been
+/// specified, use the standard input instead.
+/// \param universe The universe to initialize.
+void init_from_cmd_arguments(kmeans *universe);
+
+/// Load the universe with the data in the file source.
+/// \param universe The universe that will contains the data.
+/// \param source_file The path to the file to be read.
+void read_data_source(kmeans *universe, char* source_file);
+
+/// Save the universe and its data in the file specified.
+/// \param universe The universe to save.
+/// \param output_file The path of the file where we save the universe. Create the file if it doesn't exist, else write over it.
+void write_data_output(kmeans *universe, char* output_file);
+
+/// Initialize the clusters in the universe by determining their center of gravity.
+/// \param universe The universe who contains the clusters.
+void init_clusters(kmeans *universe);
+
+/// Compute the distance between two points of same dimensions.
+/// \param p1 The first point.
+/// \param p2 The second point.
+/// \return The distance between the two points.
+double compute_distance(point* p1, point p2);
+
+/// Calculate the position of the center of gravity of the cluster.
+/// \param clstr The cluster.
+/// \param universe The universe who contains the points of the cluster.
+void compute_center_of_gravity(cluster* clstr, kmeans* universe);
+
+/// Assign the point to the most coherent cluster.
+/// \param p The point to be assigned.
+/// \param universe The universe who contains the point and the clusters.
+void assign_points_to_cluster(point* p, kmeans* universe);
+
+/// Start the clustering with the kmeans algorithm.
+/// \param universe The kmeans universe.
+void start_clustering(kmeans* universe);
+
+/// Free the memory of the cluster.
+/// \param clstr The cluster to free.
+void destroy_cluster(cluster* clstr);
+
+/// Free the memory of the point.
+/// \param p The point to free.
+void destroy_point(point* p);
+
+/// Free the memory of universe.
+/// \param kmeans The universe to free.
+void destroy_universe(kmeans kmeans);
+
+#endif
diff --git a/main.c b/main.c
new file mode 100644
index 0000000000000000000000000000000000000000..90224f3a4abbb041d524829453a57acb0622149b
--- /dev/null
+++ b/main.c
@@ -0,0 +1,11 @@
+// Project : K-means
+// Author : Dario GENGA
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "kmeans.h"
+
+int main() {
+
+    return EXIT_SUCCESS;
+}
diff --git a/makefile b/makefile
new file mode 100644
index 0000000000000000000000000000000000000000..afe312ca80c25a4bdf2c387656b92d572ff7ec28
--- /dev/null
+++ b/makefile
@@ -0,0 +1,12 @@
+LIB=-lm
+CC=gcc -Wall -Wextra -g
+
+main: kmeans.o main.o
+	$(CC) $^ -fsanitize=address -fsanitize=leak -o $@ $(LIB)
+
+kmeans.o: kmeans.c kmeans.h
+	$(CC) -c $< $(LIB)
+main.o: main.c
+	$(CC) -c $< $(LIB)
+clean:
+	rm -f *.o main