Courbe_Impliquee

2

Dec 5th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <time.h>
  4. using namespace std;
  5. const int n=10;
  6.  
  7. int main()
  8. {
  9. float a[n],sum,min,min2;
  10. for (int i=0; i<n; i++){
  11. a[i] = rand() %100 - 55;
  12. cout << a[i] << " ";
  13. }
  14. cout <<endl;
  15. for (int i=0; i<n; i++){
  16. if (a[i]<0){
  17. min=i+1;
  18. break;
  19. }
  20. }
  21. for (int i=0; i<n; i++){
  22. if (a[i]<0){
  23. min2=i;
  24. }
  25. }
  26. for (int i=min;i<min2;i++){
  27. sum+=a[i];
  28. }
  29. cout<<sum;
  30. cout <<endl;
  31.  
  32. return 0;
  33. }
Add Comment
Please, Sign In to add comment