Advertisement
kamos

Untitled

Oct 23rd, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. #include <cmath>
  2. #include <iostream>
  3. #include <vector>
  4.  
  5. #define DIRTY_HACK 1234567.0
  6.  
  7. int main() {
  8.     short negative = 0, pos = 0;
  9.     double array_all[12];       //all elements
  10.     double array_second[12];    //elements after the second negative
  11.     for(int i = 0; i < 12; ++i) {
  12.         double tmp = 4.4 * std::tan(2.1 * (i + 1)) + (12.16 * std::pow(i + 1, 3.0) + std::cos(2.0 * (i + 1)))
  13.             / (3.0 * (2.0 * std::exp(1.1 * (i + 1)) - 0.6));
  14.         array_all[i] = tmp;
  15.         array_second[i] = DIRTY_HACK;
  16.         if(tmp < 0) ++negative;
  17.         if(negative >= 2) array_second[i] = tmp;
  18.     }
  19.     //additional code here
  20.     return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement