Guest User

Untitled

a guest
Feb 10th, 2025
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. #include <numeric>
  2. #include <vector>
  3. #include <algorithm>
  4. #include <cmath>
  5. #include <cstdio>
  6.  
  7. int main()
  8. {
  9.  
  10.     std::vector<float> fs(64*1024*1024,0);
  11.     int i = 0;
  12.     for(float& f : fs){
  13.         f = float(i) / float(fs.size());
  14.         i ++;
  15.     }
  16.    
  17.     std::for_each(fs.begin(), fs.end(), [](float& f){f=std::sinf((f));});
  18.     //std::for_each(fs.begin(), fs.end(), [](float& f){f=std::sin(double(f));});
  19.     float x = std::accumulate(fs.begin(), fs.end(), 0.0);
  20.     printf("%.4f\n", x);
  21.  
  22. }
  23.  
  24.  
  25.  
Advertisement
Add Comment
Please, Sign In to add comment