First commit
This commit is contained in:
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;
|
||||
}
|
||||
Reference in New Issue
Block a user