First commit
This commit is contained in:
BIN
IUT/Info1/TD/Exercices/9.1_PGCD/a.exe
Normal file
BIN
IUT/Info1/TD/Exercices/9.1_PGCD/a.exe
Normal file
Binary file not shown.
13
IUT/Info1/TD/Exercices/9.1_PGCD/fonction.cpp
Normal file
13
IUT/Info1/TD/Exercices/9.1_PGCD/fonction.cpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#include "fonction.h"
|
||||
|
||||
unsigned int pgcd(unsigned int a, unsigned int b) {
|
||||
unsigned int echange;
|
||||
|
||||
while (b != 0) {
|
||||
echange = b;
|
||||
b = a % b;
|
||||
a = echange;
|
||||
}
|
||||
|
||||
return a;
|
||||
}
|
||||
10
IUT/Info1/TD/Exercices/9.1_PGCD/fonction.h
Normal file
10
IUT/Info1/TD/Exercices/9.1_PGCD/fonction.h
Normal file
@@ -0,0 +1,10 @@
|
||||
/*
|
||||
Calcul du PGCD de a et b avec l'algorithme d'euclide
|
||||
|
||||
Arguments:
|
||||
a et b 2 entiers positifs
|
||||
|
||||
Returns:
|
||||
le pgcd de a et b un entier positif
|
||||
*/
|
||||
unsigned int pgcd(unsigned int a, unsigned int b);
|
||||
18
IUT/Info1/TD/Exercices/9.1_PGCD/main.cpp
Normal file
18
IUT/Info1/TD/Exercices/9.1_PGCD/main.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "fonction.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
unsigned int a, b, plusGrandDiviseur;
|
||||
|
||||
cout << "Saisir a et b" << endl;
|
||||
cin >> a >> b;
|
||||
|
||||
plusGrandDiviseur = pgcd(a, b);
|
||||
|
||||
cout << plusGrandDiviseur << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user