Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <cmath>
- #include <iomanip>
- #include <string>
- #include <stdlib.h>
- using namespace std;
- float *evaluate ();
- void display ();
- void Min_Max(float *);
- int main()
- {
- float *p;
- evaluate();
- display();
- cin.get();
- p = evaluate();
- Min_Max(p);
- return 0;
- }
- float *evaluate()
- {
- ofstream Out_File("result.txt");
- int n=30;
- float x [n];
- float fx[n];
- float interval = ((4-(-2))/0.2);
- x[0]= -2.0;
- for(n=0;n <= interval;n++)
- {
- fx[n] = 4*exp((-x[n])/2)*sin((2*x[n]- 0.3)*3.14159/180);
- x[n+1] = x[n] + 0.2;
- if (Out_File.is_open())
- {
- Out_File <<setprecision(5)<<setw(8)<<showpoint<<fixed<< x[n];
- Out_File << "\t\t"<<setprecision(5)<<setw(8)<<showpoint<<fixed<<fx[n]<<endl;
- }
- else cout << "Unable to open file";
- }
- Out_File.close();
- return fx;
- }
- void display()
- {
- ifstream inFile;
- inFile.open("result.txt");
- string line;
- cout << " x\t\t\t f(x)"<<endl;
- cout << "_______________________________________"<<endl;
- while( getline (inFile,line))
- {
- cout<<line<<endl;
- }
- inFile.close();
- }
- void Min_Max(float *value)
- {
- int a=0;
- for(a=0;a<=30;a++){
- cout << *(value+a) <<endl;
- *value =0;}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement