Advertisement
rihardmarius

final 14.12.13

Dec 19th, 2013
434
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.86 KB | None | 0 0
  1. struct polinomio {
  2.     double argumento;
  3.     int grado;
  4.     array<double, 4> coeficiente;
  5. }
  6.  
  7. bool leerEspecial (ifstream& input, polinomio& p);
  8. void push (pila& p, double valor);
  9. bool EstaVacia (const queue& q);
  10. void dequeue (queue& q, int& v);
  11. void enqueue (queue& q, int v);
  12.  
  13. bool leerPolinomio(ifstream& f, pila& p, double& a)
  14. {
  15.     polinomio poli;
  16.     if (leerEspecial(f, poli))
  17.     {
  18.         a = poli.argumento;
  19.         for (int i=0; i<4; i++)
  20.             push(p, poli.coeficiente.at(i));
  21.         return true;
  22.     }
  23.     return false;
  24. }
  25.  
  26. void vaciarColaEnPantalla (queue& q)
  27. {
  28.     double valor;
  29.     while (not EstaVacia(q));
  30.     {
  31.         dequeue (q, valor);
  32.         cout << valor << endl;
  33.     }
  34. }
  35.  
  36. int main()
  37. {
  38.     cola q; pila p; double a;
  39.     ifstream input ("polinomios.bin", ios::binary);
  40.     while (leerPolinomio(input, p, a))
  41.         enqueue (q, EvaluarPolinomio (p, a));
  42.     vaciarColaEnPantalla (q);
  43.     return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement