Exercise:
The c++ programming:
#include <iostream>
#include <fstream>
int main()
{
char c;
std::fstream File("AUC data.csv");
double arr_x[351];
double arr_y[351];
double AUC = 0.0;
for (int i = 0; i < 351; i++)
{
File >> arr_x[i] >> c >> arr_y[i];
}
for (int i = 0; i < 350; i++)
{
AUC += (arr_y[i] + arr_y[i + 1])*(arr_x[i+1] - arr_x[i])/2;
}
std::cout << "The area under curve using trapezoidal rule is: " <<AUC << std::endl;
std::cin.get();
return 0;
}
Output:
The area under curve using trapezoidal rule is: 0

No comments:
Post a Comment