Esempio n. 1
0
int main()
{  
   Product best;
   Product secondBest;

   bool more = true;
   while (more)
   {  
      Product next;
      next.read();
      if (next.is_better_than(best)) {
	secondBest = best;
	best = next;
      }
      else {
	if(next.is_better_than(secondBest)) {
	  secondBest = next;
	}
      }


      cout << "More data? (y/n) ";
      string answer;
      getline(cin, answer);
      if (answer != "y") more = false;
   }

   cout << "The best value is ";
   best.print();
   cout << "The second best value is ";
   secondBest.print();

   return 0;
}
Esempio n. 2
0
void Equipment::show()
{
	Product *p = head;
	while (p)
	{
		p->print();
		p = p->next;
	}

}
Esempio n. 3
0
/* ИЗПОЛЗВАНЕ НА КЛАСА */
int main()
{  Product best;       /* дефиниране на обект от класа */
   bool more = true;
   while (more)
   {  Product next;
      next.read();    /* извикване на член-функция на класа */
      if (next.is_better_than(best)) best = next;
      cout << "More data? (y/n) ";
      string answer;
      getline(cin, answer);
      if (answer != "y") more = false;
   }
   cout << "The best bang for the buck is ";
   best.print();        /* извикване на член-функция на класа */
   return 0;
}
int main(int argc, char **argv) {
    Product best;
    
    bool more = true;
    while (more)
    {
        Product next;
        next.read();
        if (next.is_better_than(best)) best = next;
        
        cout << "More data? (y/n)";
        string answer;
        getline(cin, answer);
        if (answer != "y") more = false;
    }
    
    cout << "The best bang for the buck is ";
    best.print();
    
    return 0;
}