You are on page 1of 3

//Ayuzo Hernandez Aaron AdanIgnacio

//Cabrera Duran Zajid


//Delgado Castro Uriel
//Ramirez Hernandez Diego
1
2
3 #include <iostream>
4 #include "ListaDT.h"
5 #include "Termino.h"
6
7 template <typename T>
8 void guardaDatos(ListaDT<T> & LDTo);
9 template <typename T>
10 double evaluaEn(ListaDT<T> &LD,int x);
11
12 using namespace std;
13
14 int main()
15 {
16 ListaDT<Termino> LDTo;
17 int x;
18 x = 1;
19
20 guardaDatos(LDTo);
21
22 cout << "f(x)= ";
23 LDTo.muestraTusDatosDI();
24 cout << endl << "f(" << x << ")=\t" << evaluaEn(LDTo,x) << endl;
25
26 return 0;
27 }
28
29 template <typename T>
30 void guardaDatos(ListaDT<T> & LDTo)
31 {
32 Termino Term(3,2);
33 LDTo.insertaUnNodo(Term);
34
35 Term.modificaTuCoeficiente(2);
36 Term.modificaTuExponente(5);
37 LDTo.insertaUnNodo(Term);
38
39 Term.modificaTuCoeficiente(3);
40 Term.modificaTuExponente(4);
41 LDTo.insertaUnNodo(Term);
42
43 Term.modificaTuCoeficiente(-4);
44 Term.modificaTuExponente(1);
45 LDTo.insertaUnNodo(Term);
46 }
47
48
49 template <typename T>
50 double evaluaEn(ListaDT<T> &LD,int x)
51 {
52
53 NodoDT<T>* aux;
54 Termino Term;
55 double resultado = 0.0;
56
57 aux=LD.dameTuFin();
58 while(aux!=NULL)
59 {
60
61 Term=aux->dameTuDato();
62 resultado+=Term.evaluateEn(x);
63 aux=aux->dameTuAnterior();
64
65 }
66
67 return resultado;
68 }
69
70

You might also like