First commit
This commit is contained in:
6
IUT/Info1/TD/Exercices/8.5_PGCD/.vscode/settings.json
vendored
Normal file
6
IUT/Info1/TD/Exercices/8.5_PGCD/.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"files.associations": {
|
||||
"*.py": "python",
|
||||
"iostream": "cpp"
|
||||
}
|
||||
}
|
||||
28
IUT/Info1/TD/Exercices/8.5_PGCD/.vscode/tasks.json
vendored
Normal file
28
IUT/Info1/TD/Exercices/8.5_PGCD/.vscode/tasks.json
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"tasks": [
|
||||
{
|
||||
"type": "cppbuild",
|
||||
"label": "C/C++: g++.exe build active file",
|
||||
"command": "C:\\Program Files Perso\\mingw64\\bin\\g++.exe",
|
||||
"args": [
|
||||
"-fdiagnostics-color=always",
|
||||
"-g",
|
||||
"*.cpp",
|
||||
"-o",
|
||||
"${fileDirname}\\${fileBasenameNoExtension}.exe"
|
||||
],
|
||||
"options": {
|
||||
"cwd": "${fileDirname}"
|
||||
},
|
||||
"problemMatcher": [
|
||||
"$gcc"
|
||||
],
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
},
|
||||
"detail": "Task generated by Debugger."
|
||||
}
|
||||
],
|
||||
"version": "2.0.0"
|
||||
}
|
||||
37
IUT/Info1/TD/Exercices/8.5_PGCD/8.5.md
Normal file
37
IUT/Info1/TD/Exercices/8.5_PGCD/8.5.md
Normal file
@@ -0,0 +1,37 @@
|
||||
{
|
||||
R : Calcule le plus grand diviseur commun entre 2 entier a et b
|
||||
E : a et b, 2 entiers positifs
|
||||
S : un entier correspondant au plus grand diviseur commun de a et b
|
||||
}
|
||||
pgcd: une fonction (a: un entier, b un entier) -> un entier
|
||||
Lexique : {Local à pgcd}
|
||||
r : un entier
|
||||
Algorithme : {Local à pgcd}
|
||||
Début
|
||||
Tant Que b != 0
|
||||
r <- a reste b
|
||||
a <- b
|
||||
b <- r
|
||||
Fin Tant Que
|
||||
Retourner(a)
|
||||
Fin
|
||||
|
||||
Lexique : {Principal}
|
||||
{R : ...; E : ...; S : ...}
|
||||
pgcd: une fonction (a: un entier, b un entier) -> un entier
|
||||
|
||||
a : un entier
|
||||
b : un entier
|
||||
plusGrandDiviseur : un entier
|
||||
Algorithme : {Principal}
|
||||
Début
|
||||
Ecrire("Entrez a un entier positif")
|
||||
Lire(a)
|
||||
|
||||
Ecrire("Entrez b un entier positif")
|
||||
Lire(b)
|
||||
|
||||
plusGrandDiviseur <- pgcd(a, b)
|
||||
|
||||
Ecrire("Le plus grand diviseur commun de ", a, " et ", b, " est ", plusGrandDiviseur)
|
||||
Fin
|
||||
12
IUT/Info1/TD/Exercices/8.5_PGCD/fonction.cpp
Normal file
12
IUT/Info1/TD/Exercices/8.5_PGCD/fonction.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
#include "fonction.h"
|
||||
|
||||
unsigned int pgcd(unsigned int a, unsigned int b) {
|
||||
unsigned int r;
|
||||
|
||||
while (b != 0) {
|
||||
r = a % b;
|
||||
a = b;
|
||||
b = r;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
1
IUT/Info1/TD/Exercices/8.5_PGCD/fonction.h
Normal file
1
IUT/Info1/TD/Exercices/8.5_PGCD/fonction.h
Normal file
@@ -0,0 +1 @@
|
||||
unsigned int pgcd(unsigned int a, unsigned int b);
|
||||
BIN
IUT/Info1/TD/Exercices/8.5_PGCD/main
Normal file
BIN
IUT/Info1/TD/Exercices/8.5_PGCD/main
Normal file
Binary file not shown.
23
IUT/Info1/TD/Exercices/8.5_PGCD/main.cpp
Normal file
23
IUT/Info1/TD/Exercices/8.5_PGCD/main.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "fonction.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
unsigned int a;
|
||||
unsigned int b;
|
||||
unsigned int plusGrandDiviseur;
|
||||
|
||||
cout << "Entrez a un entier positif" << endl;
|
||||
cin >> a;
|
||||
|
||||
cout << "Entrez b un entier positif" << endl;
|
||||
cin >> b;
|
||||
|
||||
plusGrandDiviseur = pgcd(a, b);
|
||||
|
||||
cout << "Le plus grand diviseur commun de " << a << " et " << b << " est " << plusGrandDiviseur << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
BIN
IUT/Info1/TD/Exercices/8.5_PGCD/main.exe
Normal file
BIN
IUT/Info1/TD/Exercices/8.5_PGCD/main.exe
Normal file
Binary file not shown.
Reference in New Issue
Block a user