コード例 #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;
}
コード例 #2
0
ファイル: Equipment.cpp プロジェクト: PolinaGurinovich/Lab
void Equipment::show()
{
	Product *p = head;
	while (p)
	{
		p->print();
		p = p->next;
	}

}
コード例 #3
0
ファイル: bestval2.cpp プロジェクト: maxoyn/lab
/* ИЗПОЛЗВАНЕ НА КЛАСА */
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;
}
コード例 #4
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;
}