Facebook
From Beige Treeshrew, 5 Years ago, written in C++.
Embed
Download Paste or View Raw
Hits: 218
  1. void __fastcall TForm1::Button2Click(TObject *Sender)
  2. {
  3.         int i, suma;
  4.         Form2->Show();
  5.         suma = 0;
  6.         for (i = 0; i < N; i++) {
  7.                 if (gosp[i] < StrToInt(Edit2->Text)) {
  8.                         suma = suma + gosp[i] + gosc[i];
  9.                 }
  10.                 else if(gosc[i] < StrToInt(Edit2->Text)) {
  11.                         suma = suma + gosp[i] + gosc[i];
  12.                 }
  13.         }
  14.         Form2->Label2->Caption=IntToStr(suma);
  15. }
  16. //---------------------------------------------------------------------------
  17. void __fastcall TForm1::Button3Click(TObject *Sender)
  18. {
  19.         int i, ile;
  20.         float srednia, suma;
  21.         Form3->ShowModal();
  22.         suma = 0;
  23.         ile = 0;
  24.         for (i = 0; i < N; i++) {
  25.                 if (gosp[i]>gosc[i]) {
  26.                         ile += 1;
  27.                         suma += gosp[i];
  28.                 }
  29.         }
  30.         srednia = suma/ile;
  31.         Form3->Label2->Caption=FloatToStr(srednia);
  32. }