Tengo un programa en C++ que me gustaría pasar a C. ¿Cómo sería?
El código es:
Código:
Un saludo. #include<iostream.h> class DivDiff{ float *x,*f; int n,intial,final; public: void iovalues(); float dd(int,int); }; void DivDiff::iovalues() { cout<<"Enter number of points :"<<endl; cin>>n; x=new float[n]; f=new float[n]; for(int i=0;i<n;i++) {cout<<"Enter x["<<i<<"]"<<endl; cin>>x[i]; cout<<"Enter f["<<i<<"]"<<endl; cin>>f[i];} while(1){ cout<<"Enter intial r(-1 to exit)"<<endl; cin>>intial; if(intial==-1)break; cout<<"Enter final r"<<endl; cin>>final; cout<<dd(intial,final)<<endl; } } float DivDiff::dd(int intial,int final) { float temp=0; if((final-intial)==1) temp=(f[final]-f[intial])/(x[final]-x[intial]); else temp=(dd(intial+1,final)-dd(intial,final-1))/(x[final]-x[intial]); return temp; }