Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- #include <stdlib.h>
- #include <conio.h>
- float f (float x){
- return sin(x);
- }
- float ff(float x){
- return exp(x);
- }
- void p(float *x, int n, float (*f)(float x), float c){
- for (int i = 0; i < n; i++){
- if (f(x[i]) > x[i]) x[i] = c;
- }
- }
- void main(){
- float a[20],b[10];
- for (int i = 0; i < 20; i++){
- cin >> a[i]
- }
- for (int i = 0; i < 10; i++){
- cin >> b[i]
- }
- p(a, 20, f, 0);
- p(b, 10, ff, 10.5);
- for (int i = 0; i < 20; i++){
- cout << " " << a[i];
- }
- for (int i = 0; i < 10; i++){
- cout << " " << b[i];
- }
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement