diff --git a/test~coding~readingCppPrograms.fr/data/struct_profond_1.cpp b/test~coding~readingCppPrograms.fr/data/struct_profond_1.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f3195d9d1e26cb74c7cebc58005bf83080566a52 --- /dev/null +++ b/test~coding~readingCppPrograms.fr/data/struct_profond_1.cpp @@ -0,0 +1,34 @@ +#include <iostream> +#include <cmath> + +using namespace std; + +struct Point2D { + double x; + double y; +}; + +struct Cercle { + Point2D centre; + double rayon; +}; + +int main() { + Point2D p1 = {-2, -3}; + Point2D p2 = {-4, 4}; + Cercle c1, c2; + + c1.centre = p2; + c1.rayon = fabs(p1.x - p2.x); + + c2.centre = p1; + c2.rayon = fabs(p1.y - p2.y); + + c2.centre.x += c1.centre.x; + c2.centre.y += c1.centre.y; + c2.rayon += c1.rayon; + + cout << c2.centre.x << " " << c2.centre.y << " " << c2.rayon << endl; + + return 0; +} \ No newline at end of file diff --git a/test~coding~readingCppPrograms.fr/data/struct_profond_2.cpp b/test~coding~readingCppPrograms.fr/data/struct_profond_2.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f016db66cad03da650a468f8cdf512bed22eff38 --- /dev/null +++ b/test~coding~readingCppPrograms.fr/data/struct_profond_2.cpp @@ -0,0 +1,34 @@ +#include <iostream> +#include <cmath> + +using namespace std; + +struct Point2D { + double x; + double y; +}; + +struct Cercle { + Point2D centre; + double rayon; +}; + +int main() { + Point2D p1 = { 5, -3}; + Point2D p2 = {-8, -5}; + Cercle c1, c2; + + c1.centre = p2; + c1.rayon = fabs(p1.x - p2.x); + + c2.centre = p1; + c2.rayon = fabs(p1.y - p2.y); + + c2.centre.x += c1.centre.x; + c2.centre.y += c1.centre.y; + c2.rayon += c1.rayon; + + cout << c2.centre.x << " " << c2.centre.y << " " << c2.rayon << endl; + + return 0; +} \ No newline at end of file diff --git a/test~coding~readingCppPrograms.fr/data/struct_profond_3.cpp b/test~coding~readingCppPrograms.fr/data/struct_profond_3.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c22d894e8ef49e2188d1ac99250051f9787c1ae9 --- /dev/null +++ b/test~coding~readingCppPrograms.fr/data/struct_profond_3.cpp @@ -0,0 +1,34 @@ +#include <iostream> +#include <cmath> + +using namespace std; + +struct Point2D { + double x; + double y; +}; + +struct Cercle { + Point2D centre; + double rayon; +}; + +int main() { + Point2D p1 = {-7, 4}; + Point2D p2 = {-5, -7}; + Cercle c1, c2; + + c1.centre = p2; + c1.rayon = fabs(p1.x - p2.x); + + c2.centre = p1; + c2.rayon = fabs(p1.y - p2.y); + + c2.centre.x += c1.centre.x; + c2.centre.y += c1.centre.y; + c2.rayon += c1.rayon; + + cout << c2.centre.x << " " << c2.centre.y << " " << c2.rayon << endl; + + return 0; +} \ No newline at end of file diff --git a/test~coding~readingCppPrograms.fr/data/struct_simple_1.cpp b/test~coding~readingCppPrograms.fr/data/struct_simple_1.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d633670aeff955169f08938537e3bd8f414962a0 --- /dev/null +++ b/test~coding~readingCppPrograms.fr/data/struct_simple_1.cpp @@ -0,0 +1,21 @@ +#include <iostream> +#include <cmath> + +using namespace std; + +struct Point2D { + double x; + double y; +}; + +int main() { + Point2D p1 = {-2, -3}; + Point2D p2 = {-4, 4}; + + double dx = fabs(p1.x - p2.x); + double dy = fabs(p1.y - p2.y); + + cout << dx << " " << dy << endl; + + return 0; +} \ No newline at end of file diff --git a/test~coding~readingCppPrograms.fr/data/struct_simple_2.cpp b/test~coding~readingCppPrograms.fr/data/struct_simple_2.cpp new file mode 100644 index 0000000000000000000000000000000000000000..236af534c11cd0368dc26bafdd9d65ea4141c583 --- /dev/null +++ b/test~coding~readingCppPrograms.fr/data/struct_simple_2.cpp @@ -0,0 +1,21 @@ +#include <iostream> +#include <cmath> + +using namespace std; + +struct Point2D { + double x; + double y; +}; + +int main() { + Point2D p1 = { 5, -3}; + Point2D p2 = {-8, -5}; + + double dx = fabs(p1.x - p2.x); + double dy = fabs(p1.y - p2.y); + + cout << dx << " " << dy << endl; + + return 0; +} \ No newline at end of file diff --git a/test~coding~readingCppPrograms.fr/data/struct_simple_3.cpp b/test~coding~readingCppPrograms.fr/data/struct_simple_3.cpp new file mode 100644 index 0000000000000000000000000000000000000000..868a1525f604c6dfd63413a4d98da75baf71f3f0 --- /dev/null +++ b/test~coding~readingCppPrograms.fr/data/struct_simple_3.cpp @@ -0,0 +1,21 @@ +#include <iostream> +#include <cmath> + +using namespace std; + +struct Point2D { + double x; + double y; +}; + +int main() { + Point2D p1 = {-7, 4}; + Point2D p2 = {-5, -7}; + + double dx = fabs(p1.x - p2.x); + double dy = fabs(p1.y - p2.y); + + cout << dx << " " << dy << endl; + + return 0; +} \ No newline at end of file diff --git a/test~coding~readingCppPrograms.fr/data/struct_tableau_1.cpp b/test~coding~readingCppPrograms.fr/data/struct_tableau_1.cpp new file mode 100644 index 0000000000000000000000000000000000000000..dde6d15ec9e7a89ffa92d1b3a1310ebbf15fbe4d --- /dev/null +++ b/test~coding~readingCppPrograms.fr/data/struct_tableau_1.cpp @@ -0,0 +1,31 @@ +#include <iostream> +#include <vector> + + +using namespace std; + +struct Mesure { + string id_mesure; + vector<double> valeurs; +}; + + +int main() { + Mesure m1, m2, m3, moyennes; + + m1.id_mesure = "essai_1"; + m1.valeurs = {4.3, 8.5, 3.7, 7.6}; + m2.id_mesure = "essai_2"; + m2.valeurs = {3.9, 8.4, 3.6, 7.7}; + m3.id_mesure = "essai_3"; + m3.valeurs = {4.1, 8.6, 3.8, 7.5}; + + moyennes.id_mesure = "valeurs_moyennes"; + moyennes.valeurs = vector<double>(m1.valeurs.size()); + for (unsigned int i = 0; i < moyennes.valeurs.size(); i++) + moyennes.valeurs[i] = (m1.valeurs[i] + m2.valeurs[i] + m3.valeurs[i])/3.; + + cout << moyennes.valeurs[1] << endl; + + return 0; +} \ No newline at end of file diff --git a/test~coding~readingCppPrograms.fr/data/struct_tableau_2.cpp b/test~coding~readingCppPrograms.fr/data/struct_tableau_2.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0d4f2b3336707b462d651724fb72d8822fbd8fc5 --- /dev/null +++ b/test~coding~readingCppPrograms.fr/data/struct_tableau_2.cpp @@ -0,0 +1,31 @@ +#include <iostream> +#include <vector> + + +using namespace std; + +struct Mesure { + string id_mesure; + vector<double> valeurs; +}; + + +int main() { + Mesure m1, m2, m3, moyennes; + + m1.id_mesure = "essai_1"; + m1.valeurs = {4.3, 8.5, 3.7, 7.6}; + m2.id_mesure = "essai_2"; + m2.valeurs = {3.9, 8.4, 3.6, 7.7}; + m3.id_mesure = "essai_3"; + m3.valeurs = {4.1, 8.6, 3.8, 7.5}; + + moyennes.id_mesure = "valeurs_moyennes"; + moyennes.valeurs = vector<double>(m1.valeurs.size()); + for (unsigned int i = 0; i < moyennes.valeurs.size(); i++) + moyennes.valeurs[i] = (m1.valeurs[i] + m2.valeurs[i] + m3.valeurs[i])/3.; + + cout << moyennes.valeurs[2] << endl; + + return 0; +} \ No newline at end of file diff --git a/test~coding~readingCppPrograms.fr/data/struct_tableau_3.cpp b/test~coding~readingCppPrograms.fr/data/struct_tableau_3.cpp new file mode 100644 index 0000000000000000000000000000000000000000..746f999abb7b31da06cef856f3086a7bb3cf3ce7 --- /dev/null +++ b/test~coding~readingCppPrograms.fr/data/struct_tableau_3.cpp @@ -0,0 +1,31 @@ +#include <iostream> +#include <vector> + + +using namespace std; + +struct Mesure { + string id_mesure; + vector<double> valeurs; +}; + + +int main() { + Mesure m1, m2, m3, moyennes; + + m1.id_mesure = "essai_1"; + m1.valeurs = {4.3, 8.5, 3.7, 7.6}; + m2.id_mesure = "essai_2"; + m2.valeurs = {3.9, 8.4, 3.6, 7.7}; + m3.id_mesure = "essai_3"; + m3.valeurs = {4.1, 8.6, 3.8, 7.5}; + + moyennes.id_mesure = "valeurs_moyennes"; + moyennes.valeurs = vector<double>(m1.valeurs.size()); + for (unsigned int i = 0; i < moyennes.valeurs.size(); i++) + moyennes.valeurs[i] = (m1.valeurs[i] + m2.valeurs[i] + m3.valeurs[i])/3.; + + cout << moyennes.valeurs[3] << endl; + + return 0; +} \ No newline at end of file