/*
 * Practica 2.
 *
 * Practicas Metodologia de la Programacion.
 * Curso 2008 - 2009
 *
 * Vicente Lujan Mansilla
 * Lorena Margareto Bisquert
 */

#include<iostream>
#include<assert.h>
#include<math.h>
#include<fstream>

using namespace std;

float Tfact(unsigned n);
float Tsuma(unsigned n);
float Tf1(unsigned n);

void evaluar(unsigned ini, unsigned fin, int inc, float (*t)(unsigned), ostream & file, float factor);

int main()
{
	
	unsigned ini, fin;
	int inc;
	ofstream f1, f2, f3;

	f1.open("at.dat");
	f2.open("bt.dat");
	f3.open("ct.dat");

	/*cout<<"Introduce el valor inicial\n";
	cin>>ini;
	cout<<"Introduce el valor final\n";
	cin>>fin;
	cout<<"Introduce el incremento\n";
	cin>>inc;
	cout<<"Introduce el factor de escala\n";
	cin>>factor;*/

	evaluar(1, 2000, 5, Tfact, f1, 20);
	evaluar(1, 1000, 10, Tsuma, f2, 20);
	evaluar(1, 25, 1, Tf1, f3, 1);

	f1.close();
	f2.close();
	f3.close();

	return 0;
	
}

float Tfact(unsigned n)
{
	return(n+1);
}



float Tsuma(unsigned n)
{
	return((n*n)+(3*n)+2);
}



float Tf1(unsigned n)
{
	return(5*pow(2,n)-3);
}


void evaluar(unsigned ini, unsigned fin, int inc, float (*t)(unsigned), ostream & file, float factor)
{	
	int i;
	
	for(unsigned i=ini; i<= fin; i+=inc)
	{
		t(i);
		file<< i;
		file<<"\t";
		file<< factor * t(i);
		file<<"\n";
	}

}