How to sort the array from smallest to largest in this code?
Code:
#include <iostream>
#include <cmath>
using namespace std;
double integrate(double lower, double upper);
int main()
{
int ranges[][2] = {{0,1},{1,2},{2,3},{3,4},{4,5},{5,6},{6,7},{7,8},{ 8,9},{9,10}};
for(int i=0; i<10; ++i)
cout << integrate(ranges[i][0],ranges[i][1]) << endl;
return 0;
}
double integrate(double lower, double upper)
{
double n = 0.0;
double dx = (upper-lower)/2000;
for (double i = lower; i < upper-dx; i += dx)
{
n += sin(i)*dx;
}
return n;
}
I finished this code, and this is only my problem. How do you make them in ascending order in this code? Thank you.