First commit
This commit is contained in:
17
IUT/Info1/TD/Exercices/8.3_racines_carree/.md
Normal file
17
IUT/Info1/TD/Exercices/8.3_racines_carree/.md
Normal file
@@ -0,0 +1,17 @@
|
||||
racine_carree : une fonction (a : un réel, n : un entier) -> un réel
|
||||
lexique : {Local à racine_carre}
|
||||
racine: un réel
|
||||
i : un entier
|
||||
Algorithme : {Local à racine_carre}
|
||||
Début
|
||||
i <- 0
|
||||
racine <- 1
|
||||
Tant que i < n
|
||||
racine <- (racine + a / racine)/2
|
||||
i <- i + 1
|
||||
FinTantQue
|
||||
Retourner(racine)
|
||||
Fin
|
||||
|
||||
|
||||
|
||||
28
IUT/Info1/TD/Exercices/8.3_racines_carree/.vscode/tasks.json
vendored
Normal file
28
IUT/Info1/TD/Exercices/8.3_racines_carree/.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",
|
||||
"${file}",
|
||||
"-o",
|
||||
"${fileDirname}/${fileBasenameNoExtension}"
|
||||
],
|
||||
"options": {
|
||||
"cwd": "${fileDirname}"
|
||||
},
|
||||
"problemMatcher": [
|
||||
"$gcc"
|
||||
],
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
},
|
||||
"detail": "Task generated by Debugger."
|
||||
}
|
||||
],
|
||||
"version": "2.0.0"
|
||||
}
|
||||
BIN
IUT/Info1/TD/Exercices/8.3_racines_carree/8.3
Normal file
BIN
IUT/Info1/TD/Exercices/8.3_racines_carree/8.3
Normal file
Binary file not shown.
8
IUT/Info1/TD/Exercices/8.3_racines_carree/fonctions.cpp
Normal file
8
IUT/Info1/TD/Exercices/8.3_racines_carree/fonctions.cpp
Normal file
@@ -0,0 +1,8 @@
|
||||
float racine_carree(float a, unsigned int n) {
|
||||
float root = 1;
|
||||
|
||||
for (int i=0; i < n; i++) {
|
||||
root = (root + a / root) / 2;
|
||||
}
|
||||
return root;
|
||||
}
|
||||
1
IUT/Info1/TD/Exercices/8.3_racines_carree/fonctions.h
Normal file
1
IUT/Info1/TD/Exercices/8.3_racines_carree/fonctions.h
Normal file
@@ -0,0 +1 @@
|
||||
float racine_carree(float a, unsigned int n);
|
||||
25
IUT/Info1/TD/Exercices/8.3_racines_carree/main.cpp
Normal file
25
IUT/Info1/TD/Exercices/8.3_racines_carree/main.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "fonctions.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
float root;
|
||||
float a;
|
||||
unsigned int n;
|
||||
|
||||
do {
|
||||
cout << "Saisir a" << endl;
|
||||
cin >> a;
|
||||
} while (a < 0);
|
||||
|
||||
cout << "Saisir la nombre d'itérations" << endl;
|
||||
cin >> n;
|
||||
|
||||
root = racine_carree(a, n);
|
||||
|
||||
cout << "Racine de " << a << " = " << root << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user