First commit
This commit is contained in:
33
IUT/Info1/TD/Exercices/.vscode/launch.json
vendored
Normal file
33
IUT/Info1/TD/Exercices/.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "(gdb) Launch",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "enter program name, for example ${workspaceFolder}/a.out",
|
||||
"args": [],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${fileDirname}",
|
||||
"environment": [],
|
||||
"externalConsole": false,
|
||||
"MIMode": "gdb",
|
||||
"setupCommands": [
|
||||
{
|
||||
"description": "Enable pretty-printing for gdb",
|
||||
"text": "-enable-pretty-printing",
|
||||
"ignoreFailures": true
|
||||
},
|
||||
{
|
||||
"description": "Set Disassembly Flavor to Intel",
|
||||
"text": "-gdb-set disassembly-flavor intel",
|
||||
"ignoreFailures": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
]
|
||||
}
|
||||
54
IUT/Info1/TD/Exercices/.vscode/settings.json
vendored
Normal file
54
IUT/Info1/TD/Exercices/.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
{
|
||||
"files.associations": {
|
||||
"*.py": "python",
|
||||
"iostream": "cpp",
|
||||
"cmath": "cpp",
|
||||
"iomanip": "cpp",
|
||||
"ostream": "cpp",
|
||||
"atomic": "cpp",
|
||||
"bit": "cpp",
|
||||
"cctype": "cpp",
|
||||
"charconv": "cpp",
|
||||
"clocale": "cpp",
|
||||
"compare": "cpp",
|
||||
"concepts": "cpp",
|
||||
"cstddef": "cpp",
|
||||
"cstdint": "cpp",
|
||||
"cstdio": "cpp",
|
||||
"cstdlib": "cpp",
|
||||
"cstring": "cpp",
|
||||
"ctime": "cpp",
|
||||
"cwchar": "cpp",
|
||||
"exception": "cpp",
|
||||
"format": "cpp",
|
||||
"initializer_list": "cpp",
|
||||
"ios": "cpp",
|
||||
"iosfwd": "cpp",
|
||||
"istream": "cpp",
|
||||
"iterator": "cpp",
|
||||
"limits": "cpp",
|
||||
"locale": "cpp",
|
||||
"memory": "cpp",
|
||||
"new": "cpp",
|
||||
"stdexcept": "cpp",
|
||||
"streambuf": "cpp",
|
||||
"system_error": "cpp",
|
||||
"tuple": "cpp",
|
||||
"type_traits": "cpp",
|
||||
"typeinfo": "cpp",
|
||||
"utility": "cpp",
|
||||
"xfacet": "cpp",
|
||||
"xiosbase": "cpp",
|
||||
"xlocale": "cpp",
|
||||
"xlocbuf": "cpp",
|
||||
"xlocinfo": "cpp",
|
||||
"xlocmes": "cpp",
|
||||
"xlocmon": "cpp",
|
||||
"xlocnum": "cpp",
|
||||
"xloctime": "cpp",
|
||||
"xmemory": "cpp",
|
||||
"xstring": "cpp",
|
||||
"xtr1common": "cpp",
|
||||
"xutility": "cpp"
|
||||
}
|
||||
}
|
||||
28
IUT/Info1/TD/Exercices/.vscode/tasks.json
vendored
Normal file
28
IUT/Info1/TD/Exercices/.vscode/tasks.json
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"tasks": [
|
||||
{
|
||||
"type": "cppbuild",
|
||||
"label": "C/C++: gcc build active file",
|
||||
"command": "/usr/bin/g++",
|
||||
"args": [
|
||||
"-fdiagnostics-color=always",
|
||||
"-g",
|
||||
"*.cpp",
|
||||
"-o",
|
||||
"${fileDirname}/${fileBasenameNoExtension}"
|
||||
],
|
||||
"options": {
|
||||
"cwd": "${fileDirname}"
|
||||
},
|
||||
"problemMatcher": [
|
||||
"$gcc"
|
||||
],
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
},
|
||||
"detail": "Task generated by Debugger."
|
||||
}
|
||||
],
|
||||
"version": "2.0.0"
|
||||
}
|
||||
23
IUT/Info1/TD/Exercices/1.1_ecluse/1.1.md
Normal file
23
IUT/Info1/TD/Exercices/1.1_ecluse/1.1.md
Normal file
@@ -0,0 +1,23 @@
|
||||
Lexique:
|
||||
Un bateau se trouve en amont
|
||||
L'écluse est au niveau bas
|
||||
Les feux sont rouges
|
||||
Les vannes sont fermées
|
||||
Algorithme:
|
||||
Début
|
||||
On ouvre les vannes coté amont
|
||||
On attends que l'écluse soit à niveau
|
||||
On ferme les vannes coté amont
|
||||
On ouvre la porte amont
|
||||
On passe le feu amont au vert
|
||||
Le bateau rentre dans l'écluse
|
||||
On passe le feu amont au rouge
|
||||
On ferme la porte amont
|
||||
On ouvre les vannes coté aval
|
||||
on attends que l'écluse soit à niveau aval
|
||||
On ferme les vannes aval
|
||||
On ouvre la porte aval
|
||||
on passe leu feu aval au vert
|
||||
Le bateau sort
|
||||
On passe le feu aval au rouge
|
||||
On ferme la porte aval
|
||||
44
IUT/Info1/TD/Exercices/10.4_saisie_tab_trie/10.4.md
Normal file
44
IUT/Info1/TD/Exercices/10.4_saisie_tab_trie/10.4.md
Normal file
@@ -0,0 +1,44 @@
|
||||
{
|
||||
R : Permet d'ajouter une valeur à un tableau, dans l'ordre croissant
|
||||
E/S : tab 1 tableau de réels
|
||||
S : Vide
|
||||
}
|
||||
Saisie_ordonnee : une fonction (tab : un tableau de réels) -> vide
|
||||
Lexique {Local à Saisie_ordonnee}
|
||||
nombre : un réel
|
||||
Algorithme {Local à Saisie_ordonnee}
|
||||
Début
|
||||
Ecrire("Saisir un réel")
|
||||
lire(nombre)
|
||||
tab[0] <- nombre
|
||||
|
||||
Ecrire("Saisir un réel")
|
||||
lire(nombre)
|
||||
Si nombre < tab[0]:
|
||||
Faire tab[1] <- tab[0]
|
||||
tab[0] <- nombre
|
||||
Sinon tab[1] <- nombre
|
||||
|
||||
Ecrire("Saisir un réel")
|
||||
lire(nombre)
|
||||
Si nombre > tab[1]:
|
||||
Faire tab[2] <- nombre
|
||||
Sinon
|
||||
tab[2] <- tab[1]
|
||||
Si nombre > tab[0]:
|
||||
tab[1] <- nombre
|
||||
Sinon
|
||||
tab[1] <- tab[0]
|
||||
tab[0] <- nombre
|
||||
|
||||
Lexique {Principal}
|
||||
tab : un tableau de 3 réel
|
||||
i : un entier
|
||||
Algorithme {Principal}
|
||||
Début
|
||||
Saisie_ordonnee(tab)
|
||||
|
||||
Faire tant que n < 2
|
||||
Ecrire(tab[i])
|
||||
i <- i + 1
|
||||
Fin
|
||||
169
IUT/Info1/TD/Exercices/10.5_tableau_boucle/10.5.md
Normal file
169
IUT/Info1/TD/Exercices/10.5_tableau_boucle/10.5.md
Normal file
@@ -0,0 +1,169 @@
|
||||
{Fonction 1
|
||||
R : copier les élements d’un tableau d’entiers dans un autre.
|
||||
E : tab_in un tableau d'entiers, taille_pratique_in un entier, taille_réele_out
|
||||
E/S : tab_out un tableau d'entiers
|
||||
S : Vide
|
||||
}
|
||||
copy : une fonction(
|
||||
tab_in : un tableau d'entiers,
|
||||
taille_pratique_in : un entier,
|
||||
tab_out : un tableau d'entiers,
|
||||
taille_réele_out : un entier
|
||||
) -> vide
|
||||
Lexique :
|
||||
i : un entier
|
||||
Algorithme :
|
||||
Début
|
||||
Si taille_pratique_in <= taille_réele_out
|
||||
Alors i <- 0
|
||||
Tant que i < taille_pratique_in
|
||||
Faire tab_out[i] <- tab_in[i]
|
||||
i <- i + 1
|
||||
Fin
|
||||
|
||||
|
||||
|
||||
|
||||
{Fonction 2
|
||||
R : afficher les élements d’un tableau d’entiers sous la forme : {e1,e2,e3,...,en}
|
||||
E : tab un tableau d'entiers, taille_pratique un entier
|
||||
S : Vide
|
||||
}
|
||||
afficher_tableau : une fonction(
|
||||
tab : un tableau d'entiers,
|
||||
taille_pratique : un entier
|
||||
) -> vide
|
||||
Lexique :
|
||||
i : un entier
|
||||
Algorithme :
|
||||
Début
|
||||
i <- 0
|
||||
Tant que i < taille
|
||||
Faire Ecrire(tab[i], ",") {On aura une virgule à la fin, mais l'enlever complexifierai inutilemment l'algorithme}
|
||||
i <- i + 1
|
||||
Fin
|
||||
|
||||
|
||||
|
||||
|
||||
{Fonction 3
|
||||
R : tester si deux tableaux sont identiques
|
||||
E : tab1 un tableau d'entiers, taille_pratique_1 un entier, tab2 un tableau d'entiers, taille_pratique_2 un entier
|
||||
S : vrai si les 2 tableau sont identiques
|
||||
}
|
||||
sont_identiques : une fonction(
|
||||
tab1 : un tableau d'entiers,
|
||||
tab2 : un tableau d'entiers,
|
||||
taille_pratique_1 : un entier,
|
||||
taille_pratique_2 : un entier
|
||||
) -> un booléen
|
||||
Lexique :
|
||||
i : un entier
|
||||
Algorithme :
|
||||
Début
|
||||
Si taille_pratique_1 != taille_pratique_2
|
||||
Alors Retourner(Faux)
|
||||
i <- 0
|
||||
Tant que i < taille_pratique_1
|
||||
Faire Si tab1[i] != tab2[i]:
|
||||
Alors Retourner(Faux)
|
||||
Retourner(Vrai)
|
||||
Fin
|
||||
|
||||
|
||||
|
||||
|
||||
{Fonction 4
|
||||
R : calculer la moyenne des élements d’un tableau
|
||||
E : tab un tableau d'entiers, taille_pratique un entier
|
||||
S : un réel : la moyenne de tab
|
||||
}
|
||||
moyenne_tableau : une fonction(
|
||||
tab : un tableau de réels,
|
||||
taille_pratique : un entier
|
||||
) -> un réel
|
||||
Lexique :
|
||||
i : un entier
|
||||
somme : un réel
|
||||
Algorithme :
|
||||
Début
|
||||
i <- 0
|
||||
somme <- 0
|
||||
Tant Que i < taille_pratique
|
||||
Faire somme <- somme + tab[i]
|
||||
Retourner(somme/taille_pratique)
|
||||
Fin
|
||||
|
||||
|
||||
|
||||
|
||||
{Fonction 5
|
||||
R : remplacer les valeurs d’un tableau par sa somme cumulée
|
||||
E : tab le tableau d'entiers, taille_pratique un entier
|
||||
E/S : tab le tableau de réels
|
||||
S : vide
|
||||
}
|
||||
somme_cumulee : une fonction(
|
||||
tab : un tableau d'entiers
|
||||
taille_pratique : un entier
|
||||
) -> vide
|
||||
Lexique :
|
||||
i : un entier
|
||||
j : un entier
|
||||
somme : un réel
|
||||
Algorithme :
|
||||
Début
|
||||
i <- 0
|
||||
Tant Que i < taille_pratique
|
||||
j <- 0
|
||||
somme <- 0
|
||||
Tant Que j <= i
|
||||
Faire somme <- somme + tab[j]
|
||||
j <- j + 1
|
||||
tab[i] <- somme
|
||||
|
||||
i <- i + 1
|
||||
Fin
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Lexique :
|
||||
Saisie_entiers : une fonction(tab: un tableau d'entiers, taille_réele : un entier) -> un entier
|
||||
copy : une fonction(tab_in : un tableau d'entiers,taille_pratique_in : un entier,tab_out : un tableau d'entiers, taille_réele_out : un entier) -> vide
|
||||
afficher_tableau : une fonction(tab : un tableau d'entiers, taille_pratique : un entier ) -> vide
|
||||
sont_identiques : une fonction(tab1 : un tableau d'entiers, tab2 : un tableau d'entiers, taille_pratique_1 : un entier, taille_pratique_2 : un entier) -> un booléen
|
||||
moyenne_tableau : une fonction(tab : un tableau d'entiers, taille_pratique : un entier) -> un réel
|
||||
somme_cumulee : une fonction(tab : un tableau d'entiers, taille_pratique : un entier) -> vide
|
||||
|
||||
# Fonctions 1, 2, 3, 4 et 5
|
||||
tab1 : un tableau de 1000 entiers
|
||||
taille_réele_1 : la constante entière := 1000
|
||||
taille_pratique_1 : un entier
|
||||
|
||||
tab1_copie : un tableau de 1000 entiers
|
||||
taille_réele_copie_1 : la constante entière := 1000
|
||||
|
||||
tab2 : un tableau de 1000 entiers
|
||||
taille_réele_2 : la constante entière := 1000
|
||||
taille_pratique_2 : un entier
|
||||
|
||||
Algorithme :
|
||||
Début
|
||||
taille_pratique_1 <- Saisie_entiers(tab1)
|
||||
taille_pratique_copie_1 <- taille_pratique_1
|
||||
copy(tab1, taille_pratique_1, tab1_copie, taille_réele_copie_1)
|
||||
afficher_tableau(tab1_copie, taille_pratique_copie_1)
|
||||
|
||||
taille_pratique_2 <- Saisie_entiers(tab2)
|
||||
Ecrire(
|
||||
"tab1 et tab2 sont identiques : ",
|
||||
sont_identiques(tab1, tab2, taille_pratique_1, taille_pratique_2)
|
||||
)
|
||||
|
||||
Ecrire("La moyenne de tab1 est : ", moyenne_tableau(tab1, taille_pratique_1))
|
||||
|
||||
somme_cumulee(tab1_copie, taille_pratique_copie_1)
|
||||
afficher_tableau(tab1_copie, taille_pratique_copie_1)
|
||||
Fin
|
||||
122
IUT/Info1/TD/Exercices/10.5_tableau_boucle/10.5.txt
Normal file
122
IUT/Info1/TD/Exercices/10.5_tableau_boucle/10.5.txt
Normal file
@@ -0,0 +1,122 @@
|
||||
{Fonction 1
|
||||
R : copier les élements d’un tableau d’entiers dans un autre.
|
||||
E : tab_in un tableau d'entiers, taille_pratique_in un entier, taille_réele_out
|
||||
E/S : tab_out un tableau d'entiers
|
||||
S : Vide}
|
||||
copy : une fonction(tab_in : un tableau d'entiers,
|
||||
taille_pratique_in : un entier,
|
||||
tab_out : un tableau d'entiers,
|
||||
taille_réele_out : un entier) -> vide
|
||||
Lexique :
|
||||
i : un entier
|
||||
Algorithme :
|
||||
Début
|
||||
Si taille_pratique_in <= taille_réele_out
|
||||
Alors i <- 0
|
||||
Tant que i < taille_pratique_in
|
||||
Faire tab_out[i] <- tab_in[i]
|
||||
i <- i + 1
|
||||
Fin
|
||||
{Fonction 2
|
||||
R : afficher les élements d’un tableau d’entiers sous la forme : {e1,e2,e3,...,en}
|
||||
E : tab un tableau d'entiers, taille_pratique un entier
|
||||
S : Vide}
|
||||
afficher_tableau : une fonction(tab : un tableau d'entiers,
|
||||
taille_pratique : un entier) -> vide
|
||||
Lexique :
|
||||
i : un entier
|
||||
Algorithme :
|
||||
Début
|
||||
i <- 0
|
||||
Tant que i < taille
|
||||
Faire Ecrire(tab[i], ",") {On aura une virgule à la fin, mais l'enlever complexifierai inutilemment l'algorithme}
|
||||
i <- i + 1
|
||||
Fin
|
||||
{Fonction 3
|
||||
R : tester si deux tableaux sont identiques
|
||||
E : tab1 un tableau d'entiers, taille_pratique_1 un entier, tab2 un tableau d'entiers, taille_pratique_2 un entier
|
||||
S : vrai si les 2 tableau sont identiques}
|
||||
sont_identiques : une fonction(tab1 : un tableau d'entiers,
|
||||
tab2 : un tableau d'entiers,
|
||||
taille_pratique_1 : un entier,
|
||||
taille_pratique_2 : un entier) -> un booléen
|
||||
Lexique :
|
||||
i : un entier
|
||||
Algorithme :
|
||||
Début
|
||||
Si taille_pratique_1 != taille_pratique_2
|
||||
Alors Retourner(Faux)
|
||||
i <- 0
|
||||
Tant que i < taille_pratique_1
|
||||
Faire Si tab1[i] != tab2[i]:
|
||||
Alors Retourner(Faux)
|
||||
Retourner(Vrai)
|
||||
Fin
|
||||
{Fonction 4
|
||||
R : calculer la moyenne des élements d’un tableau
|
||||
E : tab un tableau d'entiers, taille_pratique un entier
|
||||
S : un réel : la moyenne de tab}
|
||||
moyenne_tableau : une fonction(tab : un tableau de réels,
|
||||
taille_pratique : un entier) -> un réel
|
||||
Lexique :
|
||||
i : un entier
|
||||
somme : un réel
|
||||
Algorithme :
|
||||
Début i <- 0
|
||||
somme <- 0
|
||||
Tant Que i < taille_pratique
|
||||
Faire somme <- somme + tab[i]
|
||||
Retourner(somme/taille_pratique)
|
||||
Fin
|
||||
{Fonction 5
|
||||
R : remplacer les valeurs d’un tableau par sa somme cumulée
|
||||
E : tab le tableau d'entiers, taille_pratique un entier
|
||||
E/S : tab le tableau de réels
|
||||
S : vide}
|
||||
somme_cumulee : une fonction(tab : un tableau d'entiers
|
||||
taille_pratique : un entier) -> vide
|
||||
Lexique :
|
||||
i : un entier
|
||||
j : un entier
|
||||
somme : un réel
|
||||
Algorithme :
|
||||
Début i <- 0
|
||||
Tant Que i < taille_pratique
|
||||
Faire j <- 0
|
||||
somme <- 0
|
||||
Tant Que j <= i
|
||||
Faire somme <- somme + tab[j]
|
||||
tab[i] <- somme
|
||||
i <- i + 1
|
||||
Fin
|
||||
Lexique :
|
||||
Saisie_entiers : une fonction(tab: un tableau d'entiers, taille_réele : un entier) -> un entier
|
||||
copy : une fonction(tab_in : un tableau d'entiers,taille_pratique_in : un entier,tab_out : un tableau d'entiers, taille_réele_out : un entier) -> vide
|
||||
afficher_tableau : une fonction(tab : un tableau d'entiers, taille_pratique : un entier ) -> vide
|
||||
sont_identiques : une fonction(tab1 : un tableau d'entiers, tab2 : un tableau d'entiers, taille_pratique_1 : un entier, taille_pratique_2 : un entier) -> un booléen
|
||||
moyenne_tableau : une fonction(tab : un tableau d'entiers, taille_pratique : un entier) -> un réel
|
||||
somme_cumulee : une fonction(tab : un tableau d'entiers, taille_pratique : un entier) -> vide
|
||||
tab1 : un tableau de 1000 entiers
|
||||
taille_réele_1 : la constante entière := 1000
|
||||
taille_pratique_1 : un entier
|
||||
tab1_copie : un tableau de 1000 entiers
|
||||
taille_réele_copie_1 : la constante entière := 1000
|
||||
tab2 : un tableau de 1000 entiers
|
||||
taille_réele_2 : la constante entière := 1000
|
||||
taille_pratique_2 : un entier
|
||||
tab_1_et_2_identiques : un booléen
|
||||
moyenne_tab1 : un réel
|
||||
somme_cumulee_tab1_copie : un entier
|
||||
Algorithme :
|
||||
Début
|
||||
taille_pratique_1 <- Saisie_entiers(tab1)
|
||||
copy(tab1, taille_pratique_1, tab1_copie, taille_réele_copie_1)
|
||||
afficher_tableau(tab1_copie, taille_pratique_copie_1)
|
||||
taille_pratique_2 <- Saisie_entiers(tab2)
|
||||
tab_1_et_2_identiques <- sont_identiques(tab1, tab2, taille_pratique_1, taille_pratique_2)
|
||||
Ecrire(tab_1_et_2_identiques)
|
||||
moyenne_tab1 <- moyenne_tableau(tab1, taille_pratique_1)
|
||||
Ecrire(moyenne_tab1)
|
||||
somme_cumulee_tab1_copie <- somme_cumulee(tab_copie, taille_pratique_copie_1)
|
||||
Ecrire(somme_cumulee_tab1_copie)
|
||||
Fin
|
||||
39
IUT/Info1/TD/Exercices/10.5_tableau_boucle/main.cpp
Normal file
39
IUT/Info1/TD/Exercices/10.5_tableau_boucle/main.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "tableaux.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
const unsigned int taille_reelle1 = 1000;
|
||||
unsigned int taille_pratique1;
|
||||
unsigned int tab1[taille_reelle1];
|
||||
|
||||
const unsigned int taille_reelle_copie_1 = 1000;
|
||||
unsigned int taille_pratique_copie1;
|
||||
unsigned int tab1_copie[taille_reelle_copie_1];
|
||||
|
||||
const unsigned int taille_reelle2 = 1000;
|
||||
unsigned int taille_pratique2;
|
||||
unsigned int tab2[taille_reelle2];
|
||||
|
||||
taille_pratique1 = saisie_entiers(tab1, taille_reelle1);
|
||||
taille_pratique_copie1 = taille_pratique1;
|
||||
|
||||
copie(tab1, tab1_copie, taille_pratique1, taille_reelle_copie_1);
|
||||
afficher_tableau(tab1_copie, taille_pratique_copie1);
|
||||
|
||||
taille_pratique2 = saisie_entiers(tab2, taille_reelle2);
|
||||
cout << "tab1 et tab2 sont identiques : "
|
||||
<< sont_identiques(tab1, tab2, taille_pratique1, taille_pratique2)
|
||||
<< endl;
|
||||
|
||||
cout << "La moyenne de tab1 est : "
|
||||
<< moyenne_tableau(tab1, taille_pratique1)
|
||||
<< endl;
|
||||
|
||||
somme_cumulee(tab1_copie, taille_pratique_copie1);
|
||||
afficher_tableau(tab1_copie, taille_pratique_copie1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
103
IUT/Info1/TD/Exercices/10.5_tableau_boucle/tableaux.cpp
Normal file
103
IUT/Info1/TD/Exercices/10.5_tableau_boucle/tableaux.cpp
Normal file
@@ -0,0 +1,103 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "tableaux.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
// Fonction 0
|
||||
unsigned int saisie_entiers(
|
||||
unsigned int taille_reelle,
|
||||
unsigned int tab[]
|
||||
) {
|
||||
unsigned int i = 0;
|
||||
int saisie;
|
||||
cout << "Saisir jusqu'a " << taille_reelle << " entiers positifs. Terminer la saisie par -1" << endl;
|
||||
do {
|
||||
cin >> saisie;
|
||||
if (saisie != -1) {
|
||||
tab[i] = saisie;
|
||||
i++;
|
||||
}
|
||||
} while (saisie != -1 && i < taille_reelle);
|
||||
return i;
|
||||
}
|
||||
|
||||
// Fonction 1
|
||||
void copie(
|
||||
const unsigned int tab_in[],
|
||||
unsigned int tab_out[],
|
||||
unsigned int taille_pratique_in,
|
||||
unsigned int taille_reelle_out
|
||||
) {
|
||||
if (taille_pratique_in <= taille_reelle_out) {
|
||||
for (unsigned int i = 0; i < taille_pratique_in; i++) {
|
||||
tab_out[i] = tab_in[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Fonction 2
|
||||
void afficher_tableau(
|
||||
const unsigned int tab[],
|
||||
unsigned int taille_pratique
|
||||
) {
|
||||
unsigned int i = 0;
|
||||
|
||||
cout << "{" << tab[i];
|
||||
|
||||
for (i = 1; i+1 < taille_pratique; i++) {
|
||||
cout << "," << tab[i];
|
||||
}
|
||||
|
||||
cout << "}";
|
||||
}
|
||||
|
||||
// Fonction 3
|
||||
bool sont_identiques(
|
||||
const unsigned int tab1[],
|
||||
const unsigned int tab2[],
|
||||
unsigned int taille_pratique1,
|
||||
unsigned int taille_pratique2
|
||||
) {
|
||||
if (taille_pratique1 != taille_pratique2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < taille_pratique1; i++) {
|
||||
if (tab1[i] != tab2[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Fonction 4
|
||||
float moyenne_tableau(
|
||||
const unsigned int tab[],
|
||||
unsigned int taille_pratique
|
||||
) {
|
||||
int somme = 0;
|
||||
|
||||
for (unsigned int i = 0; i < taille_pratique; i++) {
|
||||
somme += tab[i];
|
||||
}
|
||||
|
||||
return (float)somme/taille_pratique;
|
||||
}
|
||||
|
||||
// Fonction 5
|
||||
void somme_cumulee(
|
||||
unsigned int tab[],
|
||||
unsigned int taille_pratique
|
||||
) {
|
||||
int somme;
|
||||
|
||||
for (unsigned int i = 0; i < taille_pratique; i++) {
|
||||
somme = 0;
|
||||
for (unsigned int j = 0; j <= i; i++) {
|
||||
somme += tab[j];
|
||||
}
|
||||
tab[i] = somme;
|
||||
}
|
||||
}
|
||||
33
IUT/Info1/TD/Exercices/10.5_tableau_boucle/tableaux.h
Normal file
33
IUT/Info1/TD/Exercices/10.5_tableau_boucle/tableaux.h
Normal file
@@ -0,0 +1,33 @@
|
||||
unsigned int saisie_entiers(
|
||||
unsigned int tab[],
|
||||
unsigned int taille_reelle
|
||||
);
|
||||
|
||||
void copie(
|
||||
const unsigned int tab_in[],
|
||||
unsigned int tab_out[],
|
||||
unsigned int taille_pratique_in,
|
||||
unsigned int taille_reelle_out
|
||||
);
|
||||
|
||||
void afficher_tableau(
|
||||
const unsigned int tab[],
|
||||
unsigned int taille_pratique
|
||||
);
|
||||
|
||||
bool sont_identiques(
|
||||
const unsigned int tab1[],
|
||||
const unsigned int tab2[],
|
||||
unsigned int taille_pratique1,
|
||||
unsigned int taille_pratique2
|
||||
);
|
||||
|
||||
float moyenne_tableau(
|
||||
const unsigned int tab[],
|
||||
unsigned int taille_pratique
|
||||
);
|
||||
|
||||
void somme_cumulee(
|
||||
unsigned int tab[],
|
||||
unsigned int taille_pratique
|
||||
);
|
||||
85
IUT/Info1/TD/Exercices/10.6/10.6.md
Normal file
85
IUT/Info1/TD/Exercices/10.6/10.6.md
Normal file
@@ -0,0 +1,85 @@
|
||||
|
||||
{
|
||||
R : Permute 2 lignes passées en paramètre dans un tableau
|
||||
E : index_ligne1 et index_ligne2 les entiers correspondants au lignes, nb_lignes : un entier nb_colonnes un entiers,
|
||||
E/S : tab un tableau de tableaux
|
||||
S : Vide
|
||||
}
|
||||
permutation_lignes : une fonction (tab: un tableau de tableaux de 6 entiers, index_ligne1 : un entier, index_ligne2 : un entier, nb_lignes : un entier, nb_colonnes : un entier) -> Vide
|
||||
Lexique :
|
||||
i : un entier
|
||||
temporaire : un entier
|
||||
Algorithme :
|
||||
Début
|
||||
Si (index_ligne1 < nb_lignes) ET (index_ligne1 >= 0) ET (index_ligne2 < nb_lignes) ET (index_ligne2 >= 0)
|
||||
Faire
|
||||
i <- 0
|
||||
Tant Que i < nb_colonnes
|
||||
Faire temporaire <- tab[index_ligne1][i]
|
||||
tab[index_ligne1][i] <- tab[index_ligne2][i]
|
||||
tab[index_ligne2][i] <- temporaire
|
||||
i <- i + 1
|
||||
FinTantQue
|
||||
FinSi
|
||||
Fin
|
||||
|
||||
|
||||
{
|
||||
R : Permute 2 colonnes passées en paramètre dans un tableau
|
||||
E : index_col1 et index_col2 les entiers correspondants au colonnes, nb_lignes : un entier nb_colonnes un entiers,
|
||||
E/S : tab un tableau de tableaux
|
||||
S : Vide
|
||||
}
|
||||
permutation_colonnes : une fonction (tab: un tableau de tableaux, index_col1 : un entier, index_col2 : un entier, nb_lignes : un entier, nb_colonnes : un entier) -> Vide
|
||||
Lexique :
|
||||
i : un entier
|
||||
temporaire : un entier
|
||||
Algorithme :
|
||||
Début
|
||||
Si (index_col1 < nb_colonnes) ET (index_col1 >= 0) ET (index_col2 < nb_lignes) ET (index_col2 >= 0)
|
||||
Faire
|
||||
i <- 0
|
||||
Tant Que i < nb_lignes
|
||||
Faire temporaire <- tab[i][index_col1]
|
||||
tab[i][index_col1] <- tab[i][index_col2]
|
||||
tab[i][index_col2] <- temporaire
|
||||
i <- i + 1
|
||||
FinTantQue
|
||||
FinSi
|
||||
Fin
|
||||
|
||||
{
|
||||
R : Affiche un tableau à 2 dimensions
|
||||
E : tab un tableau de tableau de 6 entiers, nb_lignes et nb_colonnes 2 entiers
|
||||
S : Vide
|
||||
On ne sais pas faire varier le nombre de colonnes
|
||||
}
|
||||
afficher_tableau : un fonction(tab : un tableau de tableaux de 6 entiers, nb_lignes : un entier, nb_colonnes : un entier) -> Vide
|
||||
Lexique :
|
||||
i : un entier
|
||||
j : un entier
|
||||
Algorithme :
|
||||
Début
|
||||
Si (nb_lignes > 0) ET (nb_colonnes > 0) ET (nb_colonnes < 6)
|
||||
i <- 0
|
||||
Faire Tant Que i < nb_lignes
|
||||
Faire Ecrire("| ")
|
||||
j <- 0
|
||||
Tant que j < nb_colonnes
|
||||
Faire Ecrire(tab[i][j], " ")
|
||||
FinTantQue
|
||||
Ecrire("|")
|
||||
FinTantQue
|
||||
FinSi
|
||||
Fin
|
||||
|
||||
|
||||
|
||||
|
||||
Lexique :
|
||||
tab : un tableau de 4 tableau de 6 entiers := {
|
||||
{02; 03; 05; 07; 11; 13};
|
||||
{17; 19; 23; 29; 31; 37};
|
||||
{41; 43; 47; 53; 59; 61};
|
||||
{67; 71; 73; 79; 83; 89}
|
||||
}
|
||||
BIN
IUT/Info1/TD/Exercices/10.6/a.exe
Normal file
BIN
IUT/Info1/TD/Exercices/10.6/a.exe
Normal file
Binary file not shown.
26
IUT/Info1/TD/Exercices/10.6/main.cpp
Normal file
26
IUT/Info1/TD/Exercices/10.6/main.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#include "tab.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
const unsigned int nb_lignes = 4;
|
||||
const unsigned int nb_colonnes = 6;
|
||||
unsigned int tab[nb_lignes][nb_colonnes] = {
|
||||
{2, 3, 5, 7, 11, 13},
|
||||
{17, 19, 23, 29, 31, 37},
|
||||
{41, 43, 47, 53, 59, 61},
|
||||
{67, 71, 73, 79, 83, 89}
|
||||
};
|
||||
|
||||
afficher_tableau(tab, nb_lignes, nb_colonnes);
|
||||
|
||||
permutation_lignes(tab, 0, 2, nb_lignes, nb_colonnes);
|
||||
|
||||
afficher_tableau(tab, nb_lignes, nb_colonnes);
|
||||
|
||||
permutation_colonnes(tab, 1, 4, nb_lignes, nb_colonnes);
|
||||
|
||||
afficher_tableau(tab, nb_lignes, nb_colonnes);
|
||||
|
||||
return 0;
|
||||
}
|
||||
63
IUT/Info1/TD/Exercices/10.6/tab.cpp
Normal file
63
IUT/Info1/TD/Exercices/10.6/tab.cpp
Normal file
@@ -0,0 +1,63 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "tab.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
void permutation_lignes(
|
||||
unsigned int tab[][6],
|
||||
unsigned int index_ligne1,
|
||||
unsigned int index_ligne2,
|
||||
unsigned int nb_lignes,
|
||||
unsigned int nb_colonnes
|
||||
) {
|
||||
unsigned int temp;
|
||||
|
||||
if ((index_ligne1 < nb_lignes) && (index_ligne2 < nb_lignes)) {
|
||||
for (unsigned int i = 0; i < nb_colonnes; i++) {
|
||||
temp = tab[index_ligne1][i];
|
||||
tab[index_ligne1][i] = tab[index_ligne2][i];
|
||||
tab[index_ligne2][i] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void permutation_colonnes(
|
||||
unsigned int tab[][6],
|
||||
unsigned int index_colonne1,
|
||||
unsigned int index_colonne2,
|
||||
unsigned int nb_lignes,
|
||||
unsigned int nb_colonnes
|
||||
) {
|
||||
unsigned int temp;
|
||||
|
||||
if ((index_colonne1 < nb_colonnes) && (index_colonne2 < nb_colonnes)) {
|
||||
for (unsigned int i = 0; i < nb_lignes; i++) {
|
||||
temp = tab[i][index_colonne1];
|
||||
tab[i][index_colonne1] = tab[i][index_colonne2];
|
||||
tab[i][index_colonne2] = temp;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void afficher_tableau(
|
||||
unsigned int tab[][6],
|
||||
unsigned int nb_lignes,
|
||||
unsigned int nb_colonnes
|
||||
) {
|
||||
if ((nb_lignes == 0) || (nb_colonnes == 0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < nb_lignes; i++) {
|
||||
cout << "| ";
|
||||
|
||||
for (unsigned int j = 0; j < nb_colonnes; j++) {
|
||||
cout << tab[i][j] << " ";
|
||||
}
|
||||
|
||||
cout << "|" << endl;
|
||||
}
|
||||
|
||||
}
|
||||
5
IUT/Info1/TD/Exercices/10.6/tab.h
Normal file
5
IUT/Info1/TD/Exercices/10.6/tab.h
Normal file
@@ -0,0 +1,5 @@
|
||||
void permutation_lignes(unsigned int tab[][6], unsigned int index_ligne1, unsigned int index_ligne2, unsigned int nb_lignes, unsigned int nb_colonnes);
|
||||
|
||||
void permutation_colonnes(unsigned int tab[][6], unsigned int index_colonne1, unsigned int index_colonne2, unsigned int nb_lignes, unsigned int nb_colonnes);
|
||||
|
||||
void afficher_tableau(unsigned int tab[][6], unsigned int nb_lignes, unsigned int nb_colonnes);
|
||||
28
IUT/Info1/TD/Exercices/10.9/.vscode/tasks.json
vendored
Normal file
28
IUT/Info1/TD/Exercices/10.9/.vscode/tasks.json
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"tasks": [
|
||||
{
|
||||
"type": "cppbuild",
|
||||
"label": "C/C++: g++ build active file",
|
||||
"command": "/usr/bin/g++",
|
||||
"args": [
|
||||
"-fdiagnostics-color=always",
|
||||
"-g",
|
||||
"*.cpp",
|
||||
"-o",
|
||||
"${fileDirname}/${fileBasenameNoExtension}"
|
||||
],
|
||||
"options": {
|
||||
"cwd": "${fileDirname}"
|
||||
},
|
||||
"problemMatcher": [
|
||||
"$gcc"
|
||||
],
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
},
|
||||
"detail": "Task generated by Debugger."
|
||||
}
|
||||
],
|
||||
"version": "2.0.0"
|
||||
}
|
||||
10
IUT/Info1/TD/Exercices/10.9/10.9.md
Normal file
10
IUT/Info1/TD/Exercices/10.9/10.9.md
Normal file
@@ -0,0 +1,10 @@
|
||||
nomprenom : une fonction (nom : un tableau de caractères, prenom : un tableau de caractères) -> un tableau de caractères
|
||||
Lexique :
|
||||
nom_abrege : un tableau de caractères
|
||||
FCH : le caractère constant de fin de chaine de caractère
|
||||
Algorithme :
|
||||
Début
|
||||
|
||||
|
||||
|
||||
Fin
|
||||
BIN
IUT/Info1/TD/Exercices/10.9/fonction
Normal file
BIN
IUT/Info1/TD/Exercices/10.9/fonction
Normal file
Binary file not shown.
33
IUT/Info1/TD/Exercices/10.9/fonction.cpp
Normal file
33
IUT/Info1/TD/Exercices/10.9/fonction.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#include "fonction.h"
|
||||
|
||||
void nomprenom(
|
||||
const char nom[],
|
||||
const char prenom[],
|
||||
char pseudo[]
|
||||
) {
|
||||
unsigned int pos = 0;
|
||||
|
||||
for (unsigned int i = 0; i < 3 && nom[i] != '\000'; i++) {
|
||||
pseudo[pos] = prenom[i];
|
||||
}
|
||||
|
||||
pseudo[pos] = '-';
|
||||
pos++;
|
||||
|
||||
for (unsigned int i = 0; i < 3 && prenom[i] != '\000'; i++) {
|
||||
pseudo[pos] = nom[i];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Prof:
|
||||
|
||||
for i, i < 3 && prenom i != /0
|
||||
pseudo[pos] = prenom[i]
|
||||
|
||||
|
||||
|
||||
|
||||
*/
|
||||
1
IUT/Info1/TD/Exercices/10.9/fonction.h
Normal file
1
IUT/Info1/TD/Exercices/10.9/fonction.h
Normal file
@@ -0,0 +1 @@
|
||||
void nomprenom(const char nom[], const char prenom[], char pseudo[]);
|
||||
BIN
IUT/Info1/TD/Exercices/10.9/main
Normal file
BIN
IUT/Info1/TD/Exercices/10.9/main
Normal file
Binary file not shown.
23
IUT/Info1/TD/Exercices/10.9/main.cpp
Normal file
23
IUT/Info1/TD/Exercices/10.9/main.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "fonction.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
char nom[1000];
|
||||
char prenom[1000];
|
||||
|
||||
const unsigned int _TAILLE_MAX = 8;
|
||||
char pseudo[_TAILLE_MAX];
|
||||
|
||||
cout << "Saisir nom et prenom" << endl;
|
||||
|
||||
cin >> prenom >> nom;
|
||||
|
||||
nomprenom(nom, prenom, pseudo);
|
||||
|
||||
cout << pseudo;
|
||||
|
||||
return 0;
|
||||
}
|
||||
9
IUT/Info1/TD/Exercices/12.3.4_coureur/fonction.cpp
Normal file
9
IUT/Info1/TD/Exercices/12.3.4_coureur/fonction.cpp
Normal file
@@ -0,0 +1,9 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "fonction.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
struct coureur spawner(void) {
|
||||
|
||||
}
|
||||
10
IUT/Info1/TD/Exercices/12.3.4_coureur/fonction.h
Normal file
10
IUT/Info1/TD/Exercices/12.3.4_coureur/fonction.h
Normal file
@@ -0,0 +1,10 @@
|
||||
struct coureur {
|
||||
char name[10];
|
||||
unsigned int number;
|
||||
unsigned int distance;
|
||||
double ref_time;
|
||||
double time;
|
||||
};
|
||||
|
||||
struct coureur spawner(void);
|
||||
void affiche_coureur(struct coureur);
|
||||
0
IUT/Info1/TD/Exercices/12.3.4_coureur/main.cpp
Normal file
0
IUT/Info1/TD/Exercices/12.3.4_coureur/main.cpp
Normal file
83
IUT/Info1/TD/Exercices/13.1_complexes/complexes.cpp
Normal file
83
IUT/Info1/TD/Exercices/13.1_complexes/complexes.cpp
Normal file
@@ -0,0 +1,83 @@
|
||||
#include <iostream>
|
||||
#include <math.h>
|
||||
|
||||
#include "complexes.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
struct complexe saisir_complexe() {
|
||||
struct complexe z;
|
||||
|
||||
cout << "Saisir la partie réele" << endl;
|
||||
cin >> z.Re;
|
||||
|
||||
cout << "Saisir la partie imaginaire" << endl;
|
||||
cin >> z.Im;
|
||||
|
||||
return z;
|
||||
}
|
||||
|
||||
void affiche_complexe(struct complexe z) {
|
||||
cout << z.Re << " + (" << z.Im << ")i" << endl;
|
||||
}
|
||||
|
||||
struct complexe conjuge(struct complexe z) {
|
||||
return {z.Re, -z.Im};
|
||||
}
|
||||
|
||||
struct complexe oppose(struct complexe z) {
|
||||
return {-z.Re, -z.Im};
|
||||
}
|
||||
|
||||
struct complexe inverse(struct complexe z) {
|
||||
struct complexe z_inv;
|
||||
if (z.Im == 0) {
|
||||
z_inv.Im = -z.Im/(z.Re*z.Re + z.Im*z.Im);
|
||||
}
|
||||
if (z.Re == 0) {
|
||||
z_inv.Re = z.Re/(z.Re*z.Re + z.Im*z.Im);
|
||||
}
|
||||
|
||||
return z_inv;
|
||||
}
|
||||
|
||||
float module(struct complexe z) {
|
||||
float mod = sqrt(pow(z.Re, 2)+pow(z.Im, 2));
|
||||
return mod;
|
||||
}
|
||||
|
||||
float argument(struct complexe z) {
|
||||
float mod = module(z);
|
||||
float arg_abs;
|
||||
float arg_sign;
|
||||
|
||||
arg_abs = acos(z.Re/mod);
|
||||
arg_sign = asin(z.Im/mod);
|
||||
|
||||
if (arg_sign < 0) {
|
||||
return -arg_abs;
|
||||
}
|
||||
return arg_abs;
|
||||
}
|
||||
|
||||
struct complexe add_complexe(
|
||||
struct complexe z,
|
||||
struct complexe zp
|
||||
) {
|
||||
return {z.Re + zp.Re, z.Im + zp.Im};
|
||||
}
|
||||
|
||||
struct complexe mult_complexe(
|
||||
struct complexe z,
|
||||
struct complexe zp
|
||||
) {
|
||||
return {z.Re * zp.Re - z.Im * zp.Im, z.Re * zp.Im + z.Im * zp.Re};
|
||||
}
|
||||
|
||||
struct complexe div_complexe(
|
||||
struct complexe z,
|
||||
struct complexe zp
|
||||
) {
|
||||
return mult_complexe(z, inverse(zp));
|
||||
}
|
||||
|
||||
33
IUT/Info1/TD/Exercices/13.1_complexes/complexes.h
Normal file
33
IUT/Info1/TD/Exercices/13.1_complexes/complexes.h
Normal file
@@ -0,0 +1,33 @@
|
||||
struct complexe {
|
||||
float Re;
|
||||
float Im;
|
||||
};
|
||||
|
||||
struct complexe saisir_complexe();
|
||||
|
||||
void affiche_complexe(struct complexe);
|
||||
|
||||
struct complexe conjuge(struct complexe);
|
||||
|
||||
struct complexe oppose(struct complexe);
|
||||
|
||||
struct complexe inverse(struct complexe);
|
||||
|
||||
float module(struct complexe);
|
||||
|
||||
float argument(struct complexe);
|
||||
|
||||
struct complexe add_complexe(
|
||||
struct complexe,
|
||||
struct complexe
|
||||
);
|
||||
|
||||
struct complexe mult_complexe(
|
||||
struct complexe,
|
||||
struct complexe
|
||||
);
|
||||
|
||||
struct complexe div_complexe(
|
||||
struct complexe,
|
||||
struct complexe
|
||||
);
|
||||
32
IUT/Info1/TD/Exercices/13.1_complexes/main.cpp
Normal file
32
IUT/Info1/TD/Exercices/13.1_complexes/main.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "complexes.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
struct complexe _ = saisir_complexe();
|
||||
|
||||
struct complexe z = {5, 7};
|
||||
struct complexe zp = {1, 2};
|
||||
|
||||
affiche_complexe(z);
|
||||
|
||||
affiche_complexe(conjuge(z));
|
||||
|
||||
affiche_complexe(oppose(z));
|
||||
|
||||
affiche_complexe(inverse(z));
|
||||
|
||||
cout << module(z) << endl;
|
||||
|
||||
cout << argument(z) << endl;
|
||||
|
||||
affiche_complexe(add_complexe(z, zp));
|
||||
|
||||
affiche_complexe(mult_complexe(z, zp));
|
||||
|
||||
affiche_complexe(div_complexe(z, zp));
|
||||
|
||||
return 0;
|
||||
}
|
||||
BIN
IUT/Info1/TD/Exercices/2.10_interpolation/2.10
Normal file
BIN
IUT/Info1/TD/Exercices/2.10_interpolation/2.10
Normal file
Binary file not shown.
29
IUT/Info1/TD/Exercices/2.10_interpolation/2.10.cpp
Normal file
29
IUT/Info1/TD/Exercices/2.10_interpolation/2.10.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
float Interpolation(float yb, float ya, float alpha) {
|
||||
float yc;
|
||||
|
||||
yc = alpha * yb + (1 - alpha) * ya;
|
||||
return yc;
|
||||
}
|
||||
|
||||
float CalculAlpha(float xa, float xb, float xc) {
|
||||
float alpha;
|
||||
|
||||
alpha = (xc - xa)/(xb - xa);
|
||||
return alpha;
|
||||
}
|
||||
|
||||
int main() {
|
||||
float xa, ya, xb, yb, xc, yc;
|
||||
float alpha;
|
||||
|
||||
cout << "Saisir xa, ya, xb, yb, xc" << endl;
|
||||
cin >> xa >> ya >> xb >> yb >> xc;
|
||||
|
||||
alpha = CalculAlpha(xa, xb, xc);
|
||||
yc = Interpolation(yb, ya, alpha);
|
||||
|
||||
cout << "yc vaut " << yc << endl;
|
||||
}
|
||||
29
IUT/Info1/TD/Exercices/2.10_interpolation/2.10.md
Normal file
29
IUT/Info1/TD/Exercices/2.10_interpolation/2.10.md
Normal file
@@ -0,0 +1,29 @@
|
||||
Interpolation: une fonction (yb: un réel, ya: un réel, alpha: un réel) -> un réel
|
||||
CalculAlpha: une fonction (xa: un réel, xb: un réel, xc: un réel) -> un réel
|
||||
|
||||
Interpolation (yb: un réel, ya: un réel, alpha: un réel) -> un réel
|
||||
Lexique: {Local à Interpolation}
|
||||
yc: un réel
|
||||
Algortihme: {Local à Interpolation}
|
||||
yc <- alpha * yb + (1 - alpha) * ya
|
||||
Retourner(yc)
|
||||
|
||||
CalculAlpha (xa: un réel, xb: un réel, xc: un réel) -> un réel
|
||||
Lexique : {Local à CalculAlpha}
|
||||
alpha: un réel
|
||||
Algorithme : {Local à CalculAlpha}
|
||||
alpha <- (xc - xa)/(xb - xa)
|
||||
Retourner(alpha)
|
||||
|
||||
Principal
|
||||
Lexique :
|
||||
xa, ya, xb, yb, xc, yc: 6 réels
|
||||
alpha: un réel
|
||||
Algorithme
|
||||
Ecrire("Saisir xa, ya, xb, yb, xc")
|
||||
Lire(xa, ya, xb, yb, xc)
|
||||
|
||||
alpha <- CalculAlpha(xa, xb, xc)
|
||||
yc <- Interpolation(yb, ya, alpha)
|
||||
|
||||
Ecrire("yc vaut ", yc)
|
||||
18
IUT/Info1/TD/Exercices/2.11_hms/2.11.md
Normal file
18
IUT/Info1/TD/Exercices/2.11_hms/2.11.md
Normal file
@@ -0,0 +1,18 @@
|
||||
## Ex 2.11
|
||||
Lexique :
|
||||
EntreeSecondes : réel
|
||||
TempsMinutes : réel
|
||||
TempsHeures : réel
|
||||
Temporaire : réel
|
||||
Algorithme:
|
||||
Debut
|
||||
Ecrire("Saisir un temps en secondes")
|
||||
Lire(EntreeSecondes)
|
||||
TempsHeure <- EntreeSecondes div 3600
|
||||
Temporaire <- EntreeSecondes reste 3600
|
||||
|
||||
TempsMinutes <- Temporaire div 60
|
||||
Temporaire <- Temporaire reste 60
|
||||
|
||||
Ecrire("Temps : ", TempsHeure, ":", TempsMinutes, ":", Temporaire)
|
||||
Fin
|
||||
22
IUT/Info1/TD/Exercices/2.11_hms/main.cpp
Normal file
22
IUT/Info1/TD/Exercices/2.11_hms/main.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
unsigned int sec;
|
||||
unsigned int h;
|
||||
unsigned int m;
|
||||
unsigned int s;
|
||||
|
||||
cout << "Saisir le nombre de secondes à convetir en h:m:s" << endl;
|
||||
cin >> sec;
|
||||
|
||||
h = sec / 3600;
|
||||
m = sec % 3600;
|
||||
m = m / 60;
|
||||
s = sec % 60;
|
||||
|
||||
cout << sec << "s correpondent à " << h << ':' << m << ':' << s << endl;
|
||||
|
||||
system("pause");
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
unsigned int sec;
|
||||
unsigned int h;
|
||||
unsigned int m;
|
||||
unsigned int s;
|
||||
|
||||
cout << "Saisir le nombre de secondes à convetir en h:m:s" << endl;
|
||||
cin >> sec;
|
||||
|
||||
h = sec / 3600;
|
||||
m = sec % 3600;
|
||||
m = m / 60;
|
||||
s = sec % 60;
|
||||
|
||||
cout << sec << "s correpondent à " << h << ":" << m << ":" << s << endl;
|
||||
|
||||
system("pause");
|
||||
return 0;
|
||||
}
|
||||
BIN
IUT/Info1/TD/Exercices/2.12_consommation/2.12
Normal file
BIN
IUT/Info1/TD/Exercices/2.12_consommation/2.12
Normal file
Binary file not shown.
29
IUT/Info1/TD/Exercices/2.12_consommation/2.12.cpp
Normal file
29
IUT/Info1/TD/Exercices/2.12_consommation/2.12.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
float distance;
|
||||
float consommation;
|
||||
float vitesseMoyenne;
|
||||
float prixEssence;
|
||||
float tempsPasse;
|
||||
float coutTotal;
|
||||
|
||||
cout << "Saisir la distance en km" << endl;
|
||||
cin >> distance;
|
||||
|
||||
cout << "Saisir la consommation en L/100km" << endl;
|
||||
cin >> consommation;
|
||||
|
||||
cout << "Saisir la vitesse moyenne en km/h" << endl;
|
||||
cin >> vitesseMoyenne;
|
||||
|
||||
cout << "Saisir le prix de l'essence au litre en €" << endl;
|
||||
cin >> prixEssence;
|
||||
|
||||
tempsPasse = distance / vitesseMoyenne;
|
||||
coutTotal = (distance / 100) * consommation * prixEssence;
|
||||
|
||||
cout << "Temps passé en voiture : " << tempsPasse << "h" << endl;
|
||||
cout << "Cout total du Carburant : " << coutTotal << "€" << endl;
|
||||
}
|
||||
25
IUT/Info1/TD/Exercices/2.12_consommation/2.12.md
Normal file
25
IUT/Info1/TD/Exercices/2.12_consommation/2.12.md
Normal file
@@ -0,0 +1,25 @@
|
||||
## Ex 2.12
|
||||
Lexique:
|
||||
Distance : réel
|
||||
Consommation : réel
|
||||
VitesseMoyenne : réel
|
||||
PrixEssence : réel
|
||||
TempsPasse : réel
|
||||
CoutTotal : réel
|
||||
Algorithme:
|
||||
Debut
|
||||
Ecrire("Saisir la distance")
|
||||
Lire(Distance)
|
||||
Ecrire("Saisir la consommation")
|
||||
Lire(Consommation)
|
||||
Ecire("Saisir la vitesse moyenne")
|
||||
Lire(VitesseMoyenne)
|
||||
Ecrire("Saisir le prix de l'essence au litre")
|
||||
Lire(PrixEssence)
|
||||
|
||||
TempsPasse <- Distance / VitesseMoyenne
|
||||
CoutTotal <- (Distance / 100) * Consommation * PrixEssence
|
||||
|
||||
Ecrire("Temps passé en voiture : ", TempsPasse, "h")
|
||||
Ecrire("Cout total du carburant : ", CoutTotal)
|
||||
Fin
|
||||
15
IUT/Info1/TD/Exercices/2.2_operateurs/2.2.md
Normal file
15
IUT/Info1/TD/Exercices/2.2_operateurs/2.2.md
Normal file
@@ -0,0 +1,15 @@
|
||||
1)
|
||||
a = 5
|
||||
b = 6-5 = -1
|
||||
a = 5 + 1 = 6
|
||||
b = -1 * 4 = -4
|
||||
a = -2*(-4)-4 = 8-4 = 4
|
||||
a = a/3 = Interdit
|
||||
|
||||
2) La dernière instruction n'est pas autorisée car a es tde type entier et l'opérateur / renvoie toujours un réel
|
||||
3) a <- a div 3
|
||||
|
||||
1 bis) 50 et 25
|
||||
2 bis) 73 et 17
|
||||
3 bis) 0 et 47
|
||||
4) 50.73
|
||||
16
IUT/Info1/TD/Exercices/2.3_echange_variables/2.3.md
Normal file
16
IUT/Info1/TD/Exercices/2.3_echange_variables/2.3.md
Normal file
@@ -0,0 +1,16 @@
|
||||
Lexique :
|
||||
a : un entier
|
||||
b : un entier
|
||||
c : un entier
|
||||
Algorithme :
|
||||
Ecrire("Saisir a")
|
||||
Lire(a)
|
||||
Ecrire("Saisir b")
|
||||
Lire(b)
|
||||
|
||||
c <- a
|
||||
a <- b
|
||||
b <- c
|
||||
|
||||
Ecrire("Avant : ", b, " ", a)
|
||||
Ecrire("Après : ", a, " ", b)
|
||||
18
IUT/Info1/TD/Exercices/2.4_superficie/2.4.cpp
Normal file
18
IUT/Info1/TD/Exercices/2.4_superficie/2.4.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
float longeur;
|
||||
float largeur;
|
||||
float aire;
|
||||
float const CONVERTION_METRE_HA = 0.0001;
|
||||
|
||||
cout << "Saisir la longeur et la largeur du terrain" << endl;
|
||||
cin >> longeur >> largeur;
|
||||
|
||||
aire = longeur * largeur * CONVERTION_METRE_HA;
|
||||
|
||||
cout << "La superficie du terrain est de " << aire << "ha" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
14
IUT/Info1/TD/Exercices/2.4_superficie/2.4.md
Normal file
14
IUT/Info1/TD/Exercices/2.4_superficie/2.4.md
Normal file
@@ -0,0 +1,14 @@
|
||||
Lexique :
|
||||
CONVERTION_METRE_HA : une constante réelle := 0.0001
|
||||
longeur : un réel
|
||||
largeur : un réel
|
||||
aire : un réel
|
||||
Algortihme :
|
||||
Début
|
||||
Ecrire("Saisir la longeur et la largeur du terrain")
|
||||
Lire(longeur, largeur)
|
||||
|
||||
aire <- longeur * largeur * CONVERTION_METRE_HA
|
||||
|
||||
Ecrire("La superficie du terrain est de " : aire, "ha")
|
||||
Fin
|
||||
21
IUT/Info1/TD/Exercices/2.5_hms/2.5.cpp
Normal file
21
IUT/Info1/TD/Exercices/2.5_hms/2.5.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
unsigned int heures;
|
||||
unsigned int minutes;
|
||||
unsigned int secondes;
|
||||
|
||||
cout << "Saisir les heures" << endl;
|
||||
cin >> heures;
|
||||
cout << "Saisir les minutes" << endl;
|
||||
cin >> minutes;
|
||||
cout << "Saisir les secondes" << endl;
|
||||
cin >> secondes;
|
||||
|
||||
secondes = secondes + minutes * 60 + heures * 3600;
|
||||
|
||||
cout << secondes << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
17
IUT/Info1/TD/Exercices/2.5_hms/2.5.md
Normal file
17
IUT/Info1/TD/Exercices/2.5_hms/2.5.md
Normal file
@@ -0,0 +1,17 @@
|
||||
Lexique :
|
||||
heures : un entier
|
||||
minutes : un entier
|
||||
secondes : un entier
|
||||
Algorithme :
|
||||
Début
|
||||
Ecrire("Saisir les heures")
|
||||
Lire(heures)
|
||||
Ecrire("Saisir les minutes")
|
||||
Lire(minutes)
|
||||
Ecrire("Saisir les secondes")
|
||||
Lire(secondes)
|
||||
|
||||
secondes <- secondes + minutes * 60 + heures * 3600;
|
||||
|
||||
Ecrire(secondes)
|
||||
Fin
|
||||
19
IUT/Info1/TD/Exercices/2.6_moyenne/2.6.cpp
Normal file
19
IUT/Info1/TD/Exercices/2.6_moyenne/2.6.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
float note1;
|
||||
float note2;
|
||||
float note3;
|
||||
int const nombreDeNotes = 3;
|
||||
float moyenne;
|
||||
|
||||
cout << "Saisir les 3 notes" << endl;
|
||||
cin >> note1 >> note2 >> note3;
|
||||
|
||||
moyenne = (note1 + note2 + note3) / nombreDeNotes;
|
||||
|
||||
cout << "Le moyenne est de " << moyenne << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
15
IUT/Info1/TD/Exercices/2.6_moyenne/2.6.md
Normal file
15
IUT/Info1/TD/Exercices/2.6_moyenne/2.6.md
Normal file
@@ -0,0 +1,15 @@
|
||||
Lexique :
|
||||
note1 : un réel
|
||||
note2 : un réel
|
||||
note3 : un réel
|
||||
nombreDeNotes : constante entière := 3
|
||||
moyenne : un réel
|
||||
Algorithme :
|
||||
Début
|
||||
Ecrire("Saisir les 3 notes")
|
||||
Lire(note1, note2, note3)
|
||||
|
||||
moyenne <- (note1 + note2 + note3) / nombreDeNotes
|
||||
|
||||
Ecrire("La moyenne des notes est ", moyenne)
|
||||
Fin
|
||||
17
IUT/Info1/TD/Exercices/2.7_conv_francs/2.7.cpp
Normal file
17
IUT/Info1/TD/Exercices/2.7_conv_francs/2.7.cpp
Normal file
@@ -0,0 +1,17 @@
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
float sommeFRF;
|
||||
float const CONVERTION_FRF_EUR = 6.55957;
|
||||
float sommeEUR;
|
||||
|
||||
cout << "Saisir la somme en francs" << endl;
|
||||
cin >> sommeFRF;
|
||||
|
||||
sommeEUR = sommeFRF / CONVERTION_FRF_EUR;
|
||||
|
||||
cout << sommeFRF << " francs français font : " << sommeEUR << "€";
|
||||
|
||||
return 0;
|
||||
}
|
||||
13
IUT/Info1/TD/Exercices/2.7_conv_francs/2.7.md
Normal file
13
IUT/Info1/TD/Exercices/2.7_conv_francs/2.7.md
Normal file
@@ -0,0 +1,13 @@
|
||||
Lexique :
|
||||
sommeFRF : un réel
|
||||
CONVERTION_FRF_EUR : constante réelle := 6.55957
|
||||
sommeEUR : un réel
|
||||
Algorithme :
|
||||
Début
|
||||
Ecrire("Saisir la somme en francs")
|
||||
Lire(sommeFRF)
|
||||
|
||||
sommeEUR <- sommeFRF / CONVERTION_FRF_EUR
|
||||
|
||||
Ecrire(sommeFRF, " francs français font : ", sommeEUR, "€")
|
||||
Fin
|
||||
18
IUT/Info1/TD/Exercices/2.8_tva/2.8.cpp
Normal file
18
IUT/Info1/TD/Exercices/2.8_tva/2.8.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
float prixUnitaireHTArticles;
|
||||
float quantiteArticles;
|
||||
float tauxTVAPourcent;
|
||||
float prixArticlesTTC;
|
||||
|
||||
cout << "Entrez prix unitaire HT, quantité d'articles et taux de TVA en pourcentage" << endl;
|
||||
cin >> prixUnitaireHTArticles >> quantiteArticles >> tauxTVAPourcent;
|
||||
|
||||
prixArticlesTTC = prixUnitaireHTArticles * (1 + tauxTVAPourcent / 100) / quantiteArticles;
|
||||
|
||||
cout << "Le prix total sera de : " << prixArticlesTTC << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
18
IUT/Info1/TD/Exercices/2.8_tva/2.8.md
Normal file
18
IUT/Info1/TD/Exercices/2.8_tva/2.8.md
Normal file
@@ -0,0 +1,18 @@
|
||||
Lexique :
|
||||
prixUnitaireHTArticle : un réel
|
||||
quantiteArticles : un entier
|
||||
tauxTVAPourcent : un réel
|
||||
prixArticlesTTC : un réel
|
||||
Algorithme :
|
||||
Début
|
||||
Ecrire("Entrez le prix unitaire d'un article HT")
|
||||
Lire(prixUnitaireHTArticle)
|
||||
Ecrire("Entrez la quantité d'articles commandés")
|
||||
Lire(quantiteArticles)
|
||||
Ecrire("Entrez le taux de TVA en pourcentage")
|
||||
Lire(tauxTVAPourcent)
|
||||
|
||||
prixArticlesTTC <- prixUnitaireHTArticle * (1 + tauxTVAPourcent / 100) * quantiteArticles
|
||||
|
||||
Ecrire("Le prix total sera de : ", prixArticlesTTC)
|
||||
Fin
|
||||
1
IUT/Info1/TD/Exercices/2.9_circuit_rlc/2.9.md
Normal file
1
IUT/Info1/TD/Exercices/2.9_circuit_rlc/2.9.md
Normal file
@@ -0,0 +1 @@
|
||||
Lexique
|
||||
23
IUT/Info1/TD/Exercices/3.2.md
Normal file
23
IUT/Info1/TD/Exercices/3.2.md
Normal file
@@ -0,0 +1,23 @@
|
||||
Lexique:
|
||||
{Role: Convertir une distance en kilomètres, en miles
|
||||
Entrée: 1 réel, des kilomètres
|
||||
Sortie: 1 réel, des miles}
|
||||
Km2miles: fonction de convertion (kilometers: un réel) -> un réel
|
||||
kms: un réel
|
||||
miles: un réel
|
||||
Algorithme:
|
||||
Debut
|
||||
Ecrire("Saisissez le distance en kilomètres")
|
||||
Lire(kms)
|
||||
miles <- Km2miles(kms)
|
||||
Ecrire("La distance en miles est de : ", miles)
|
||||
Fin
|
||||
|
||||
Km2miles: fonction de convertion (kilometers: un réel) -> un réel
|
||||
Lexique:
|
||||
miles: un réel
|
||||
Algorithme:
|
||||
Debut
|
||||
miles <- kilometers / 1.609
|
||||
Retourner miles
|
||||
Fin
|
||||
71
IUT/Info1/TD/Exercices/3.3.md
Normal file
71
IUT/Info1/TD/Exercices/3.3.md
Normal file
@@ -0,0 +1,71 @@
|
||||
Lexique: {Principal}
|
||||
Presentation: Fonction d'explication (vide) -> vide
|
||||
Saisie_rayon: Fonction de saisie (vide) -> un réel
|
||||
Perimetre: Fonction de calcul (rayon: un réel) -> un réel
|
||||
Surface: Fonction de calcul (rayon: un réel) -> un réel
|
||||
Affiche_resultats: Fonction d'affichage (perimetre: un réel, surface: un réel) -> vide
|
||||
|
||||
rayon: réel
|
||||
perimetre: réel
|
||||
surface: réel
|
||||
|
||||
Algorithme:
|
||||
Debut
|
||||
Presentation()
|
||||
rayon <- Saisie_rayon()
|
||||
perimetre <- Perimetre(rayon)
|
||||
surface <- Surface(rayon)
|
||||
Affiche_resultats(perimetre, surface)
|
||||
Fin
|
||||
|
||||
|
||||
Presentation: Fonction d'explication (vide) -> vide
|
||||
Lexique:
|
||||
vide
|
||||
Algortihme:
|
||||
Debut
|
||||
Ecrire("Cet algortihme calcule le périmètre et la surface d'un disque de rayon saisi")
|
||||
Fin
|
||||
|
||||
|
||||
Saisie_rayon: Fonction de saisie (vide) -> un réel
|
||||
Lexique:
|
||||
rayon: un réel
|
||||
Algorithme:
|
||||
Debut
|
||||
Ecrire("Saisir un rayon")
|
||||
Lire(rayon)
|
||||
Retourner rayon
|
||||
Fin
|
||||
|
||||
|
||||
Perimetre: Fonction de calcul (rayon: un réel) -> un réel
|
||||
Lexique:
|
||||
perimetre: un réel
|
||||
PI: un constante réele := 3.14159265
|
||||
Algortihme:
|
||||
Debut
|
||||
perimetre <- PI * rayon * 2
|
||||
Retourner perimetre
|
||||
Fin
|
||||
|
||||
|
||||
Surface: Fonction de calcul (rayon: un réel) -> un réel
|
||||
Lexique:
|
||||
surface: un réel
|
||||
PI: un constante réele := 3.14159265
|
||||
Algorithme:
|
||||
Debut
|
||||
surface <- PI * rayon²
|
||||
Retourner surface
|
||||
Fin
|
||||
|
||||
|
||||
Affiche_resultats: Fonction d'affichage (perimetre: un réel, surface: un réel) -> vide
|
||||
Lexique:
|
||||
vide
|
||||
Algortihme:
|
||||
Debut
|
||||
Ecrire("Perimetre: ", perimetre, "u.a.")
|
||||
Ecrire("Surface: ", surface, "u.a.²")
|
||||
Fin
|
||||
BIN
IUT/Info1/TD/Exercices/4.3_debugage/4.3
Normal file
BIN
IUT/Info1/TD/Exercices/4.3_debugage/4.3
Normal file
Binary file not shown.
29
IUT/Info1/TD/Exercices/4.3_debugage/4.3.cpp
Normal file
29
IUT/Info1/TD/Exercices/4.3_debugage/4.3.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
int a, b, c;
|
||||
int quotient, reste;
|
||||
float valeur_approchee;
|
||||
|
||||
cout << "Entrer deux entiers:\n";
|
||||
cin >> a >> b;
|
||||
cout << "Vous avez entré les valeurs " << a << " et " << b << endl;
|
||||
|
||||
c = a + b;
|
||||
cout << "Leur somme est: " << c << endl;
|
||||
|
||||
c = a * b;
|
||||
cout << "Leur produit est: " << c << endl;
|
||||
|
||||
quotient = a / b;
|
||||
cout << "Le quotient de " << a << "/" << b << " est : " << quotient << endl;
|
||||
|
||||
valeur_approchee = (float)a / b;
|
||||
cout << "La valeur approchée de " << a << "/" << b << " est : " << valeur_approchee << endl;
|
||||
|
||||
reste = a % b;
|
||||
cout << "le reste de " << a << "/" << b << " est : " << reste << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
int a, b, c;
|
||||
cout << "Entrer deux entiers:\n";
|
||||
cin >> a >> b;
|
||||
cout << "Vous avez entré les valeurs " << a << " et " << b << endl;
|
||||
c = a + b;
|
||||
cout << "Leur somme est: " << c << endl;
|
||||
c = a * b;
|
||||
cout << "Leur produit est: " << c << endl;
|
||||
c = a / b;
|
||||
cout << "Le reste de " << a << "/" << b << " est : " << c;
|
||||
return 0;
|
||||
}
|
||||
8
IUT/Info1/TD/Exercices/4.5_sans_gravite/4.5.md
Normal file
8
IUT/Info1/TD/Exercices/4.5_sans_gravite/4.5.md
Normal file
@@ -0,0 +1,8 @@
|
||||
Lexique:
|
||||
Force_a_sur_b: un réel
|
||||
Constante_Graviationelle: un constante réèle := 6.67384x10^{-11}
|
||||
Masse_A: un réel
|
||||
Masse_B: un réel
|
||||
distance_A_B: un réel
|
||||
Algorithme
|
||||
|
||||
28
IUT/Info1/TD/Exercices/5.3_surface_cyl/.vscode/tasks.json
vendored
Normal file
28
IUT/Info1/TD/Exercices/5.3_surface_cyl/.vscode/tasks.json
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"tasks": [
|
||||
{
|
||||
"type": "cppbuild",
|
||||
"label": "C/C++: g++ build active file",
|
||||
"command": "/usr/bin/g++",
|
||||
"args": [
|
||||
"-fdiagnostics-color=always",
|
||||
"-g",
|
||||
"*.cpp",
|
||||
"-o",
|
||||
"${fileDirname}/${fileBasenameNoExtension}"
|
||||
],
|
||||
"options": {
|
||||
"cwd": "${fileDirname}"
|
||||
},
|
||||
"problemMatcher": [
|
||||
"$gcc"
|
||||
],
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
},
|
||||
"detail": "Task generated by Debugger."
|
||||
}
|
||||
],
|
||||
"version": "2.0.0"
|
||||
}
|
||||
17
IUT/Info1/TD/Exercices/5.3_surface_cyl/calculation.cpp
Normal file
17
IUT/Info1/TD/Exercices/5.3_surface_cyl/calculation.cpp
Normal file
@@ -0,0 +1,17 @@
|
||||
#include "functions.h"
|
||||
|
||||
float PI = 3.141592;
|
||||
|
||||
float Perimetre(float rayon) {
|
||||
float perimetre;
|
||||
|
||||
perimetre = PI * rayon * 2;
|
||||
return perimetre;
|
||||
}
|
||||
|
||||
float Surface(float rayon) {
|
||||
float surface;
|
||||
|
||||
surface = PI * rayon * rayon;
|
||||
return surface;
|
||||
}
|
||||
10
IUT/Info1/TD/Exercices/5.3_surface_cyl/functions.h
Normal file
10
IUT/Info1/TD/Exercices/5.3_surface_cyl/functions.h
Normal file
@@ -0,0 +1,10 @@
|
||||
// Fonctions d'Affichage
|
||||
void Presentation(void);
|
||||
void afficherResultats(float, float);
|
||||
|
||||
// Fonction de Saisie
|
||||
float saisieRayon(void);
|
||||
|
||||
// Fonctions de Calcul
|
||||
float Perimetre(float);
|
||||
float Surface(float);
|
||||
20
IUT/Info1/TD/Exercices/5.3_surface_cyl/io.cpp
Normal file
20
IUT/Info1/TD/Exercices/5.3_surface_cyl/io.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
#include <iostream>
|
||||
#include "functions.h"
|
||||
using namespace std;
|
||||
|
||||
void Presentation() {
|
||||
cout << "Cet algortihme calcule le périmètre et la surface d'un disque de rayon saisi" << endl;
|
||||
}
|
||||
|
||||
void afficherResultats(float perimetre, float surface) {
|
||||
cout << "Perimètre : " << perimetre << "u.a." << endl;
|
||||
cout << "Surface : " << surface << "u.a.²" << endl;
|
||||
}
|
||||
|
||||
float saisieRayon() {
|
||||
float rayon;
|
||||
|
||||
cout << "Saisir une rayon" << endl;
|
||||
cin >> rayon;
|
||||
return rayon;
|
||||
}
|
||||
BIN
IUT/Info1/TD/Exercices/5.3_surface_cyl/main
Normal file
BIN
IUT/Info1/TD/Exercices/5.3_surface_cyl/main
Normal file
Binary file not shown.
17
IUT/Info1/TD/Exercices/5.3_surface_cyl/main.cpp
Normal file
17
IUT/Info1/TD/Exercices/5.3_surface_cyl/main.cpp
Normal file
@@ -0,0 +1,17 @@
|
||||
#include "functions.h"
|
||||
|
||||
int main() {
|
||||
float rayon;
|
||||
float perimetre;
|
||||
float surface;
|
||||
|
||||
Presentation();
|
||||
|
||||
rayon = saisieRayon();
|
||||
perimetre = Perimetre(rayon);
|
||||
surface = Surface(rayon);
|
||||
|
||||
afficherResultats(perimetre, surface);
|
||||
|
||||
return 0;
|
||||
}
|
||||
BIN
IUT/Info1/TD/Exercices/5.4_insolation/insolation
Normal file
BIN
IUT/Info1/TD/Exercices/5.4_insolation/insolation
Normal file
Binary file not shown.
17
IUT/Info1/TD/Exercices/5.4_insolation/insolation.cpp
Normal file
17
IUT/Info1/TD/Exercices/5.4_insolation/insolation.cpp
Normal file
@@ -0,0 +1,17 @@
|
||||
#include <cmath>
|
||||
|
||||
const double PI = 3.141592;
|
||||
|
||||
double declinaisonSoleil(unsigned int day) {
|
||||
return asin(0.398 * sin(0.0171915 * day - 1.3962634));
|
||||
}
|
||||
|
||||
double dureeInsolation(
|
||||
double latitude, double declinaison
|
||||
) {
|
||||
return 24/PI * acos(-tan(latitude) * tan(declinaison));
|
||||
}
|
||||
|
||||
double deg2Rad(double degree) {
|
||||
return degree * PI / 180;
|
||||
}
|
||||
3
IUT/Info1/TD/Exercices/5.4_insolation/insolation.h
Normal file
3
IUT/Info1/TD/Exercices/5.4_insolation/insolation.h
Normal file
@@ -0,0 +1,3 @@
|
||||
double declinaisonSoleil(unsigned int);
|
||||
double dureeInsolation(double, double);
|
||||
double deg2Rad(double);
|
||||
BIN
IUT/Info1/TD/Exercices/5.4_insolation/main
Normal file
BIN
IUT/Info1/TD/Exercices/5.4_insolation/main
Normal file
Binary file not shown.
23
IUT/Info1/TD/Exercices/5.4_insolation/main.cpp
Normal file
23
IUT/Info1/TD/Exercices/5.4_insolation/main.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#include <iostream>
|
||||
#include "insolation.h"
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
unsigned int day;
|
||||
double latitude;
|
||||
double declinaison;
|
||||
double insolation;
|
||||
double latitude_rad;
|
||||
|
||||
cout << "Entrez le jour de l'année : ";
|
||||
cin >> day;
|
||||
cout << "Entrez la latitude du lieu : ";
|
||||
cin >> latitude;
|
||||
|
||||
latitude_rad = deg2Rad(latitude);
|
||||
declinaison = declinaisonSoleil(day);
|
||||
insolation = dureeInsolation(latitude, declinaison);
|
||||
|
||||
cout << "La durée d'insolation à la latitude : " << latitude << "° est : " << insolation << "h" << endl;
|
||||
return 0;
|
||||
}
|
||||
2
IUT/Info1/TD/Exercices/5.6_courbure_terre/56.md
Normal file
2
IUT/Info1/TD/Exercices/5.6_courbure_terre/56.md
Normal file
@@ -0,0 +1,2 @@
|
||||
distance_homme² = distance_horizon² + rayon_terre²
|
||||
distance_horizon² = distance_homme²-rayon_terre²
|
||||
12
IUT/Info1/TD/Exercices/5.6_courbure_terre/distance.cpp
Normal file
12
IUT/Info1/TD/Exercices/5.6_courbure_terre/distance.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
#include "distance.h"
|
||||
#include <cmath>
|
||||
|
||||
double Distance(double hauteur, double rayonPlanete) {
|
||||
double distanceHorizon;
|
||||
double distanceCentreHomme;
|
||||
|
||||
distanceCentreHomme = rayonPlanete + hauteur;
|
||||
distanceHorizon = pow(distanceCentreHomme, 2) - pow(rayonPlanete, 2);
|
||||
|
||||
return distanceHorizon;
|
||||
}
|
||||
1
IUT/Info1/TD/Exercices/5.6_courbure_terre/distance.h
Normal file
1
IUT/Info1/TD/Exercices/5.6_courbure_terre/distance.h
Normal file
@@ -0,0 +1 @@
|
||||
double Distance(double, double);
|
||||
BIN
IUT/Info1/TD/Exercices/5.6_courbure_terre/main
Normal file
BIN
IUT/Info1/TD/Exercices/5.6_courbure_terre/main
Normal file
Binary file not shown.
14
IUT/Info1/TD/Exercices/5.6_courbure_terre/main.cpp
Normal file
14
IUT/Info1/TD/Exercices/5.6_courbure_terre/main.cpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#include <iostream>
|
||||
#include "distance.h"
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
double hauteur;
|
||||
double rayonPlanete;
|
||||
double horizon;
|
||||
|
||||
cin >> hauteur >> rayonPlanete;
|
||||
|
||||
horizon = Distance(hauteur, rayonPlanete);
|
||||
cout << horizon;
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
{
|
||||
R : Calculer la taille génétique de l'enfant en fonction du sexe de l'enfant et de la taille des parents
|
||||
E : La taille de la mère : un réel, la taille du père : un réel, si l'enfant est une fille : un booléen
|
||||
S : la taille génétique de l'enfant : un réel
|
||||
}
|
||||
tailleGenetique : une fonction (
|
||||
taillePere : un réel,
|
||||
tailleMere : un réel,
|
||||
estFille : un booléen
|
||||
) -> un réel
|
||||
Lexique : {Local à tailleGenetique}
|
||||
tailleEnfant : un réel
|
||||
tailleMoyenne : un réel
|
||||
VARTAILLESEXE : la constante entière := 6
|
||||
Algorithme : {Local à tailleGenetique}
|
||||
Début
|
||||
tailleMoyenne <- (taillePere + tailleMere) / 2
|
||||
Si estFille
|
||||
Alors tailleEnfant <- tailleMoyenne - VARTAILLESEXE
|
||||
Sinon tailleEnfant <- tailleMoyenne + VARTAILLESEXE
|
||||
Fin Si
|
||||
Retourner tailleEnfant
|
||||
Fin
|
||||
|
||||
|
||||
Lexique : {Principal}
|
||||
{
|
||||
R : Calculer la taille génétique de l'enfant en fonction du sexe de l'enfant et de la taille des parents
|
||||
E : La taille de la mère : un réel, la taille du père : un réel, si l'enfant est une fille : un booléen
|
||||
S : la taille génétique de l'enfant : un réel
|
||||
}
|
||||
tailleGenetique : une fonction (
|
||||
taillePere : un réel,
|
||||
tailleMere : un réel,
|
||||
estFille : un booléen
|
||||
) -> un réel
|
||||
|
||||
tailleMereSaisie : un réel
|
||||
taillePereSaisie : un réel
|
||||
estFilleSaisie : un réel
|
||||
tailleGenetiqueEnfant : un réel
|
||||
|
||||
|
||||
Algorithme : {Principal}
|
||||
Début
|
||||
Ecrire("Saisir la taille de la mere")
|
||||
Lire(tailleMereSaisie)
|
||||
...
|
||||
tailleGenetiqueEnfant <- tailleGenetique(taillePereSaisie, tailleMereSaisie, estFilleSaisie)
|
||||
Ecrire("La taille de l'enfant sera de ", tailleGenetiqueEnfant, "cm")
|
||||
Fin
|
||||
17
IUT/Info1/TD/Exercices/6.4_taille_genetique/functions.cpp
Normal file
17
IUT/Info1/TD/Exercices/6.4_taille_genetique/functions.cpp
Normal file
@@ -0,0 +1,17 @@
|
||||
#include "functions.h"
|
||||
|
||||
float tailleGenetique(float taillePere, float tailleMere, bool estFille) {
|
||||
float tailleEnfant;
|
||||
float tailleMoyenne;
|
||||
const float VARTAILLESEXE = 6;
|
||||
|
||||
tailleMoyenne = (taillePere + tailleMere) / 2;
|
||||
|
||||
if (estFille) {
|
||||
tailleEnfant = tailleMoyenne - VARTAILLESEXE;
|
||||
} else {
|
||||
tailleEnfant = tailleMoyenne + VARTAILLESEXE;
|
||||
}
|
||||
|
||||
return tailleEnfant;
|
||||
}
|
||||
9
IUT/Info1/TD/Exercices/6.4_taille_genetique/functions.h
Normal file
9
IUT/Info1/TD/Exercices/6.4_taille_genetique/functions.h
Normal file
@@ -0,0 +1,9 @@
|
||||
/*
|
||||
Calcule la taille génétique en fonction de la taille des parents
|
||||
|
||||
Args:
|
||||
float taillePere
|
||||
float tailleMere
|
||||
bool estFille
|
||||
*/
|
||||
float tailleGenetique(float, float, bool);
|
||||
BIN
IUT/Info1/TD/Exercices/6.4_taille_genetique/main
Normal file
BIN
IUT/Info1/TD/Exercices/6.4_taille_genetique/main
Normal file
Binary file not shown.
30
IUT/Info1/TD/Exercices/6.4_taille_genetique/main.cpp
Normal file
30
IUT/Info1/TD/Exercices/6.4_taille_genetique/main.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "functions.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
float tailleMereSaisie;
|
||||
float taillePereSaisie;
|
||||
float estFilleSaisie;
|
||||
float tailleGenetiqueEnfant;
|
||||
|
||||
cout << "Saisir la taille de la mère" << endl;
|
||||
cin >> tailleMereSaisie;
|
||||
|
||||
cout << "Saisir la taille de la père" << endl;
|
||||
cin >> taillePereSaisie;
|
||||
|
||||
cout << "Saisir si l'enfant et une fille" << endl;
|
||||
cin >> estFilleSaisie;
|
||||
|
||||
tailleGenetiqueEnfant = tailleGenetique(
|
||||
taillePereSaisie,
|
||||
tailleMereSaisie,
|
||||
estFilleSaisie
|
||||
);
|
||||
|
||||
cout << "La taille génétique de l'enfant est de " << tailleGenetiqueEnfant << "cm" << endl;
|
||||
|
||||
}
|
||||
28
IUT/Info1/TD/Exercices/6.5_conditions_multiples/6.5.txt
Normal file
28
IUT/Info1/TD/Exercices/6.5_conditions_multiples/6.5.txt
Normal file
@@ -0,0 +1,28 @@
|
||||
|
||||
{
|
||||
R : Verifier que le nombre saisi est entre 1 et 50 inclus
|
||||
E : nombre : un entier
|
||||
S : l'info si le nombre est correct un booléen
|
||||
}
|
||||
estEntre1Et50 : une fonction ( : un entier) -> booléen
|
||||
Lexique : {Local à estEntre1Et50}
|
||||
|
||||
Algorithme : {Local à estEntre1Et50}
|
||||
Début
|
||||
Si nb >= 1 ET nb <= 50
|
||||
Alors Retourner VRAI
|
||||
Sinon Retourner FAUX
|
||||
Fin Si
|
||||
Fin
|
||||
|
||||
|
||||
6.6
|
||||
ProduitNegatif : une fonction (a : un réel, b : un réel) -> booléen
|
||||
Si a < 0
|
||||
Alors Si b < 0
|
||||
Alors Retourner FAUX
|
||||
Sinon Retourner VRAI
|
||||
Sinon Si b < 0
|
||||
Alors Retourner VRAI
|
||||
Sinon Retourner FAUX
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
#include "functions.h"
|
||||
|
||||
bool estEntre1Et50(int nombre) {
|
||||
if (nombre >= 1 && nombre <= 50) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
// Verifie si nombre est entre 1 et 50 inclus
|
||||
bool estEntre1Et50(int);
|
||||
9
IUT/Info1/TD/Exercices/6.5_conditions_multiples/main.cpp
Normal file
9
IUT/Info1/TD/Exercices/6.5_conditions_multiples/main.cpp
Normal file
@@ -0,0 +1,9 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "functions.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
|
||||
}
|
||||
BIN
IUT/Info1/TD/Exercices/6.6.3_imbrication_si/6.6.3
Normal file
BIN
IUT/Info1/TD/Exercices/6.6.3_imbrication_si/6.6.3
Normal file
Binary file not shown.
29
IUT/Info1/TD/Exercices/6.6.3_imbrication_si/functions.cpp
Normal file
29
IUT/Info1/TD/Exercices/6.6.3_imbrication_si/functions.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "functions.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
void ordreCroissant(float a, float b, float c) {
|
||||
if (a < b) {
|
||||
if (b > c) {
|
||||
cout << c << b << a;
|
||||
} else {
|
||||
if (a > c) {
|
||||
cout << b << c << a;
|
||||
} else {
|
||||
cout << b << a << c;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (a > c) {
|
||||
cout << c << a << b;
|
||||
} else {
|
||||
if (b < c) {
|
||||
cout << a << b << c;
|
||||
} else {
|
||||
cout << a << c << b;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
10
IUT/Info1/TD/Exercices/6.6.3_imbrication_si/functions.h
Normal file
10
IUT/Info1/TD/Exercices/6.6.3_imbrication_si/functions.h
Normal file
@@ -0,0 +1,10 @@
|
||||
/*
|
||||
Affiche abc dans l'odre croissant
|
||||
|
||||
Args
|
||||
a, b, c : 3 float
|
||||
|
||||
Returns
|
||||
void
|
||||
*/
|
||||
void ordreCroissant(float a, float b, float c);
|
||||
BIN
IUT/Info1/TD/Exercices/6.6.3_imbrication_si/main
Normal file
BIN
IUT/Info1/TD/Exercices/6.6.3_imbrication_si/main
Normal file
Binary file not shown.
15
IUT/Info1/TD/Exercices/6.6.3_imbrication_si/main.cpp
Normal file
15
IUT/Info1/TD/Exercices/6.6.3_imbrication_si/main.cpp
Normal file
@@ -0,0 +1,15 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "functions.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
float a, b, c;
|
||||
|
||||
cout << "Entrez a, b, c" << endl;
|
||||
cin >> a >> b >> c;
|
||||
|
||||
ordreCroissant(a, b, c);
|
||||
return 0;
|
||||
}
|
||||
3
IUT/Info1/TD/Exercices/6.8.1_polynome/.md
Normal file
3
IUT/Info1/TD/Exercices/6.8.1_polynome/.md
Normal file
@@ -0,0 +1,3 @@
|
||||
a=0.011025
|
||||
b=0.21
|
||||
c=1
|
||||
BIN
IUT/Info1/TD/Exercices/6.8.1_polynome/fonction
Normal file
BIN
IUT/Info1/TD/Exercices/6.8.1_polynome/fonction
Normal file
Binary file not shown.
35
IUT/Info1/TD/Exercices/6.8.1_polynome/fonction.cpp
Normal file
35
IUT/Info1/TD/Exercices/6.8.1_polynome/fonction.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
#include <math.h>
|
||||
#include <iostream>
|
||||
#include "fonction.h"
|
||||
using namespace std;
|
||||
|
||||
double calcul_discriminant(double a, double b, double c) {
|
||||
return (b*b - 4 * a * c);
|
||||
}
|
||||
void calcul_racines(double a, double b, double c) {
|
||||
double discriminant;
|
||||
discriminant = calcul_discriminant(a, b, c);
|
||||
|
||||
if (discriminant >= -pow(10, -10)
|
||||
&& discriminant <= pow(10, -10)
|
||||
) {
|
||||
discriminant = 0;
|
||||
}
|
||||
if (discriminant < 0) {
|
||||
cout << "delta = " << discriminant << endl;
|
||||
return;
|
||||
} else if (discriminant == 0) {
|
||||
double x0 = (-b/ (2*a));
|
||||
|
||||
cout << "delta = " << discriminant << endl;
|
||||
cout << "La racines est " << x0 << endl;
|
||||
return;
|
||||
}
|
||||
double x1;
|
||||
double x2;
|
||||
x1 = (-b - sqrt(discriminant)) / (2 * a);
|
||||
x2 = (-b + sqrt(discriminant)) / (2 * a);
|
||||
cout << "delta = " << discriminant << endl;
|
||||
cout << "Les racines sont " << x1 << " " << x2 << endl;
|
||||
return;
|
||||
}
|
||||
3
IUT/Info1/TD/Exercices/6.8.1_polynome/fonction.h
Normal file
3
IUT/Info1/TD/Exercices/6.8.1_polynome/fonction.h
Normal file
@@ -0,0 +1,3 @@
|
||||
double calcul_discriminant(double a, double b, double c);
|
||||
|
||||
void calcul_racines(double a, double b, double discriminant);
|
||||
BIN
IUT/Info1/TD/Exercices/6.8.1_polynome/main
Normal file
BIN
IUT/Info1/TD/Exercices/6.8.1_polynome/main
Normal file
Binary file not shown.
13
IUT/Info1/TD/Exercices/6.8.1_polynome/main.cpp
Normal file
13
IUT/Info1/TD/Exercices/6.8.1_polynome/main.cpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "fonction.h"
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
double a, b, c;
|
||||
|
||||
cout << "Entrez a, b, c" << endl;
|
||||
cin >> a >> b >> c;
|
||||
|
||||
calcul_racines(a, b, c);
|
||||
}
|
||||
32
IUT/Info1/TD/Exercices/6.8.1_polynome/main.py
Normal file
32
IUT/Info1/TD/Exercices/6.8.1_polynome/main.py
Normal file
@@ -0,0 +1,32 @@
|
||||
from math import sqrt
|
||||
|
||||
def calcul_delta(a: float, b: float, c: float) -> float:
|
||||
return b**2 - 4*a*c
|
||||
|
||||
def calcul_racines(
|
||||
a: float, b: float, c: float
|
||||
) -> tuple[float|None, float|None]:
|
||||
|
||||
delta = calcul_delta(a, b, c)
|
||||
|
||||
if delta < 0:
|
||||
return (None, None)
|
||||
elif delta == 0:
|
||||
return (-b / (2 * a), None)
|
||||
else:
|
||||
return (
|
||||
(-b - sqrt(delta)) / (2 * a),
|
||||
(-b + sqrt(delta)) / (2 * a)
|
||||
)
|
||||
|
||||
def main():
|
||||
valeurs = input()
|
||||
valeurs = map(float, valeurs.split(" "))
|
||||
|
||||
racines = calcul_racines(*valeurs)
|
||||
|
||||
print(f"Les racines sont {racines}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
34
IUT/Info1/TD/Exercices/6.8.2_bisextile/6.8.2.md
Normal file
34
IUT/Info1/TD/Exercices/6.8.2_bisextile/6.8.2.md
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
R : Verifie si l'année passée en paramètre est bisextile
|
||||
E : annee un entier correspondant à l'année
|
||||
S : un booléen correspondant à si l'année est bisextile ou non
|
||||
}
|
||||
estBisextile : une fonction (annee : un entier) -> booléen
|
||||
Lexique : {Local à estBisextile}
|
||||
bisextile : un booléen
|
||||
Algorithme : {Local à estBisextile}
|
||||
Début
|
||||
Si (annee reste 4 = 0)
|
||||
Alors Si (annee reste 4000 /= 0) ET (annee reste 400 = 0)
|
||||
Alors bisextile <- Faux
|
||||
Sinon bisextile <- Vrai
|
||||
Sinon bisextile <- Faux
|
||||
|
||||
Retourner bisextile
|
||||
Fin
|
||||
|
||||
Lexique : {Principal}
|
||||
estBisextile : une fonction (annee : un entier) -> booléen
|
||||
annee : un entier
|
||||
anneeEstBisextile : un booléen
|
||||
Algortihme : {Principal}
|
||||
Début
|
||||
Ecrire("Saisir une année")
|
||||
Lire(annee)
|
||||
|
||||
anneeEstBisextile <- estBisextile(annee)
|
||||
|
||||
Si anneeEstBisextile
|
||||
Alors Ecrire("L'année saisie est bisexile")
|
||||
Sinon Ecrire("L'année saisie n'est pas bisextile")
|
||||
Fin
|
||||
53
IUT/Info1/TD/Exercices/6.8.2_bisextile/6.8.3.md
Normal file
53
IUT/Info1/TD/Exercices/6.8.2_bisextile/6.8.3.md
Normal file
@@ -0,0 +1,53 @@
|
||||
{
|
||||
R : Renvoie Vrai si l'année passée en paramètre est bisextile.
|
||||
E : année un entier
|
||||
S : un booléen en fonction de si l'année est bisextile
|
||||
}
|
||||
verifAnneBisextile : une fonction (annee : un entier) -> booléen
|
||||
|
||||
{
|
||||
R : Renvoie vrai si le mois saisi est bien entre 1 et 12
|
||||
E : mois un entier positif
|
||||
S : un booléen en fonction de la validité du mois
|
||||
}
|
||||
verifMois : une fonction (mois : un entier positif) -> booléen
|
||||
|
||||
{
|
||||
R : Verifie si le jour saisi est valide en fonction du mois et de l'année
|
||||
E : jour, mois 2 entiers positifs, anneeEstBisextile un booléen
|
||||
S : un booléen en fonction de la validité du jour
|
||||
}
|
||||
verifJour : une fonction (jour : un entier positif, mois : un entier positif, anneeEstBisextile : un booléen) -> booléen
|
||||
|
||||
{
|
||||
R : Verifie si jour, mois et annee sont valides
|
||||
E : jour, mois, annee : 3 entiers positifs
|
||||
S : booléen en fonction de si la date est valide
|
||||
}
|
||||
verifDate(jour : un entier positif, mois : un entier positif, annee : un entier positif) -> booléen
|
||||
|
||||
|
||||
Lexique : {Principal}
|
||||
{Les déclarations de fonctions}
|
||||
|
||||
jourSaisie : un entier positif
|
||||
moisSaisie : un entier positif
|
||||
anneeSaisie : un entier positif
|
||||
dateValide : un booléen
|
||||
Algorithme : {Principal}
|
||||
Début
|
||||
Ecrire("Veuillez saisir le jour")
|
||||
Lire(jourSaisie)
|
||||
|
||||
Ecrire("Veuillez saisir le mois")
|
||||
Lire(moisSaisie)
|
||||
|
||||
Ecrire("Veuillez saisir l'année")
|
||||
Lire(anneeSaisie)
|
||||
|
||||
dateValide <- verifDate(jourSaisie, moisSaisie, anneeSaisie)
|
||||
|
||||
Si dateValide
|
||||
Alors Ecrire("La date saisie est valide")
|
||||
Sinon Ecrire("La date saisie est invalide")
|
||||
Fin
|
||||
32
IUT/Info1/TD/Exercices/6.8.2_bisextile/6.8.3.py
Normal file
32
IUT/Info1/TD/Exercices/6.8.2_bisextile/6.8.3.py
Normal file
@@ -0,0 +1,32 @@
|
||||
class testOui:
|
||||
...
|
||||
|
||||
|
||||
def estBisextile(annee: int) -> bool:
|
||||
"""
|
||||
Verifie si l'année passée en paramètre est bisextile
|
||||
|
||||
Args:
|
||||
annee (int) : correspond à l'année
|
||||
|
||||
Returns:
|
||||
bool : si l'année est bisextile ou non
|
||||
"""
|
||||
bisextile: bool = False
|
||||
|
||||
if annee % 4 == 0:
|
||||
if (annee % 4000 != 0) and (annee % 400 == 0):
|
||||
bisextile = True
|
||||
else:
|
||||
bisextile = False
|
||||
else:
|
||||
bisextile = False
|
||||
|
||||
return bisextile
|
||||
|
||||
def main() -> None:
|
||||
annee = int(input())
|
||||
print(estBisextile(annee))
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
8
IUT/Info1/TD/Exercices/6.8.2_bisextile/Untitled-1.py
Normal file
8
IUT/Info1/TD/Exercices/6.8.2_bisextile/Untitled-1.py
Normal file
@@ -0,0 +1,8 @@
|
||||
def b(a):
|
||||
if a % 4 == 0:
|
||||
if
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
print(b(2016))
|
||||
13
IUT/Info1/TD/Exercices/6.8.2_bisextile/fonctions.cpp
Normal file
13
IUT/Info1/TD/Exercices/6.8.2_bisextile/fonctions.cpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#include "fonctions.h"
|
||||
|
||||
bool estBisextile(int annee) {
|
||||
bool bisextile;
|
||||
|
||||
if (annee % 4 == 0 && annee % 100 != 0 || annee % 400 == 0 && annee % 4000 != 0) {
|
||||
bisextile = true;
|
||||
} else {
|
||||
bisextile = false;
|
||||
}
|
||||
|
||||
return bisextile;
|
||||
}
|
||||
1
IUT/Info1/TD/Exercices/6.8.2_bisextile/fonctions.h
Normal file
1
IUT/Info1/TD/Exercices/6.8.2_bisextile/fonctions.h
Normal file
@@ -0,0 +1 @@
|
||||
bool estBisextile(int annee);
|
||||
BIN
IUT/Info1/TD/Exercices/6.8.2_bisextile/main
Normal file
BIN
IUT/Info1/TD/Exercices/6.8.2_bisextile/main
Normal file
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user