Advertisement
Guest User

kr_v6

a guest
Nov 27th, 2014
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. #include <stdlib.h>
  4. #include <conio.h>
  5.  
  6. float f (float x){
  7.     return sin(x);
  8. }
  9.  
  10. float ff(float x){
  11.       return exp(x);
  12. }
  13.  
  14. void p(float *x, int n, float (*f)(float x), float c){
  15.     for (int i = 0; i < n; i++){
  16.         if (f(x[i]) > x[i]) x[i] = c;
  17.     }
  18. }
  19.  
  20. void main(){
  21.     float a[20],b[10];
  22.     for (int i = 0; i < 20; i++){
  23.         cin >> a[i]
  24.     }
  25.     for (int i = 0; i < 10; i++){
  26.         cin >> b[i]
  27.     }
  28.     p(a, 20, f, 0);
  29.     p(b, 10, ff, 10.5);  
  30.     for (int i = 0; i < 20; i++){
  31.         cout << " " << a[i];
  32.     }
  33.     for (int i = 0; i < 10; i++){
  34.         cout << " " << b[i];
  35.     }
  36.     getch();  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement