Question
convert this code from C to C++
include <stdio.h> include <locale.h> void filtre (double x. double yll, double yol, int , int N) int Nn-10000 int main) setlo
0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <iostream>
#include <locale>

using namespace std;

void filtre(double x[], double y[], double yo[], int m, int N);
int Nm=10000;

int main()
{
setlocale(LC_ALL,"");
double x[Nm],y[Nm],yo[Nm]={0.0};
int m;
FILE *dosya1=fopen("D:\veri\678.txt","r");
FILE *dosya2=fopen("D:\veri\data2.txt","w+");
int i=0;
while(!feof(dosya1))
{
fscanf(dosya1,"%lf %lf",&x[i],&y[i]);
i++;
}
fclose(dosya1);
int N=i;
cout << "Pencere Genisligi m=";
cin >>m;
filtre(x,y,yo,m,N);
for(int k=0;k<N;k++)
fprintf(dosya2,"%0.40f %0.41f %0.41f\n",x[k],y[k],yo[k]);
fclose(dosya2);
}
void filtre(double x[], double y[], double yo[], int m, int N)
{
int m2=(m-1)/2;
for(int i=0;i<N;i++)
{
int mL=i-m2;
if(mL<1)mL=1;
int mU=i+m2;
if(mU>N)mU=N;
double T=0.0;
for(int j=mL;j<=mU;j++)
T=T+y[j];
yo[i]=T/m;
}

}

i do not have 673.txt so can not execute the program let me know if any doubt is there , thanks

Add a comment
Know the answer?
Add Answer to:
convert this code from C to C++ include <stdio.h> include <locale.h> void filtre (double x. double...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT