Код:
#include <iostream>
#include <cmath>
#define a1 6.
#define b1 8.
#define h1 1.
#define a2 1.
#define b2 2.2
#define h2 .2
double f1(double x) {
return sqrt(x);
}
double f2(double x) {
return cos(x) * exp(-x);
}
int main() {
double i;
// while
i = a1;
while(i <= b1) {
std::cout << "f1(" << i << ") = " << f1(i) << "\n";
i += h1;
}
std::cout << "\n";
// for
for (i = a2; i <= b2; i += h2) {
std::cout << "f2(" << i << ") = " << f2(i) << "\n";
}
return 0;
}