Advertisement
robkepetr

Untitled

Apr 29th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 8.07 KB | None | 0 0
  1. #pragma endregion
  2.  
  3. inline double round( double val )
  4. {
  5.     if( val < 0 ) return ceil(val - 0.5);
  6.     return floor(val + 0.5);
  7. }
  8.  
  9.         void Atnaujinimas()
  10.         {
  11.             std::ifstream fr(glob::pav + ".txt");
  12.          glob::n = 0;
  13.              while(!fr.eof())
  14.              {
  15.                  getline(fr,glob::Reg.ats[glob::n].klientas,'!');
  16.                  getline(fr,glob::Reg.ats[glob::n].procedura,'@');
  17.                  getline(fr,glob::Reg.ats[glob::n].data,'#');
  18.                  fr >> glob::Reg.ats[glob::n].ugis;
  19.                  fr >> glob::Reg.ats[glob::n].svoris;
  20.                  fr >> glob::Reg.ats[glob::n].proc;
  21.                  fr >> glob::Reg.ats[glob::n].ritmas;
  22.                  fr >> glob::Reg.ats[glob::n].ivertinimas;
  23.                  fr >> glob::Reg.ats[glob::n].kmi;
  24.                  fr.ignore(80, '\n');
  25.                  glob::n++;
  26.              }
  27.              fr.close();
  28.              glob::n--;
  29.              glob::n--;
  30.         }
  31.  
  32.     private: System::Void Rezultatai_Load(System::Object^  sender, System::EventArgs^  e) {
  33.                
  34.             label3->Text = gcnew String(glob::pav.c_str());
  35.  
  36.              }
  37. private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
  38.  
  39.              Atnaujinimas();
  40.  
  41.              textBox1->Text = glob::Reg.ats[0].ugis.ToString();
  42.              textBox2->Text = glob::Reg.ats[0].svoris.ToString();
  43.              textBox3->Text = glob::Reg.ats[0].proc.ToString();
  44.              textBox4->Text = glob::Reg.ats[0].ritmas.ToString();
  45.              textBox5->Text = glob::Reg.ats[0].ivertinimas.ToString();
  46.              textBox6->Text = glob::Reg.ats[0].kmi.ToString();
  47.          }
  48. private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) {
  49.  
  50.          Atnaujinimas();
  51.  
  52.                  textBox1->Text = glob::Reg.ats[glob::n].ugis.ToString();
  53.                  textBox2->Text = glob::Reg.ats[glob::n].svoris.ToString();
  54.                  textBox3->Text = glob::Reg.ats[glob::n].proc.ToString();
  55.                  textBox4->Text = glob::Reg.ats[glob::n].ritmas.ToString();
  56.                  textBox5->Text = glob::Reg.ats[glob::n].ivertinimas.ToString();
  57.                  textBox6->Text = glob::Reg.ats[glob::n].kmi.ToString();
  58.          }
  59. private: System::Void button3_Click(System::Object^  sender, System::EventArgs^  e) {
  60.  
  61.              Atnaujinimas();
  62.                      textBox1->Text = glob::Reg.ats[1].ugis.ToString();
  63.                      textBox2->Text = glob::Reg.ats[1].svoris.ToString();
  64.                      textBox3->Text = glob::Reg.ats[1].proc.ToString();
  65.                      textBox4->Text = glob::Reg.ats[1].ritmas.ToString();
  66.                      textBox5->Text = "---";
  67.                      textBox6->Text = glob::Reg.ats[1].kmi.ToString();
  68.                
  69.  
  70.          }
  71. private: System::Void button4_Click(System::Object^  sender, System::EventArgs^  e) {
  72.  
  73.              Atnaujinimas();
  74.              double ugis = glob::Reg.ats[glob::n].ugis - glob::Reg.ats[1].ugis;
  75.              double svoris = glob::Reg.ats[glob::n].svoris - glob::Reg.ats[1].svoris;
  76.              double proc = glob::Reg.ats[glob::n].proc - glob::Reg.ats[1].proc;
  77.              int ritmas = glob::Reg.ats[glob::n].ritmas - glob::Reg.ats[1].ritmas;
  78.              double kmi = glob::Reg.ats[glob::n].kmi - glob::Reg.ats[1].kmi;
  79.              kmi = round( kmi * 100.0 ) / 100.0;
  80.              textBox1->Text = "";
  81.              textBox2->Text = "";
  82.              textBox3->Text = "";
  83.              textBox4->Text = "";
  84.              textBox5->Text = "";
  85.              textBox6->Text = "";
  86.  
  87.              if(glob::Reg.ats[1].ugis > glob::Reg.ats[0].ugis)
  88.              {
  89.                  if(ugis < 0)
  90.                  {
  91.                      textBox1->Text = ugis.ToString();
  92.                  }
  93.                  else
  94.                     textBox1->Text = "Pasiekta";
  95.              }
  96.              else if(glob::Reg.ats[1].ugis < glob::Reg.ats[0].ugis)
  97.              {
  98.                  if(ugis <= 0)
  99.                  {
  100.                      textBox1->Text = "Pasiekta";
  101.                  }
  102.                  else
  103.                      textBox1->Text = ugis.ToString();
  104.              }
  105.              else
  106.                 textBox1->Text = "Pasiekta";
  107. //-----------------------------------------------------------------------------------------------------
  108.              if(glob::Reg.ats[1].svoris > glob::Reg.ats[0].svoris)
  109.              {
  110.                  if(svoris < 0)
  111.                      textBox2->Text = svoris.ToString();
  112.  
  113.                  else
  114.                      textBox2->Text = "Pasiekta";
  115.              }
  116.              else if(glob::Reg.ats[1].svoris < glob::Reg.ats[0].svoris)
  117.              {
  118.                  if(svoris <= 0)
  119.                  {
  120.                      textBox2->Text = "Pasiekta";
  121.                  }
  122.                  else
  123.                      textBox2->Text = svoris.ToString();
  124.              }
  125.              else
  126.                 textBox2->Text = "Pasiekta";
  127. //-----------------------------------------------------------------------------------------------------
  128.              if(glob::Reg.ats[1].proc > glob::Reg.ats[0].proc)
  129.              {
  130.                  if(proc < 0)
  131.                  {
  132.                      textBox3->Text = proc.ToString();
  133.                  }
  134.                  else
  135.                      textBox3->Text = "Pasiekta";
  136.              }
  137.              else if(glob::Reg.ats[1].proc < glob::Reg.ats[0].proc)
  138.              {
  139.                  if(proc <= 0)
  140.                  {
  141.                      textBox3->Text = "Pasiekta";
  142.                  }
  143.                  else
  144.                      textBox3->Text = proc.ToString();
  145.              }
  146.              else
  147.                 textBox3->Text = "Pasiekta";
  148. //-----------------------------------------------------------------------------------------------------
  149.              if(glob::Reg.ats[1].ritmas > glob::Reg.ats[0].ritmas)
  150.              {
  151.                  if(ritmas < 0)
  152.                  {
  153.                      textBox4->Text = ritmas.ToString();
  154.                  }
  155.                  else
  156.                      textBox4->Text = "Pasiekta";
  157.              }
  158.              else if(glob::Reg.ats[1].ritmas < glob::Reg.ats[0].ritmas)
  159.              {
  160.                  if(ritmas <= 0)
  161.                      textBox4->Text = "Pasiekta";
  162.  
  163.                  else
  164.                      textBox4->Text = ritmas.ToString();
  165.              }
  166.              else
  167.                 textBox4->Text = "Pasiekta";
  168. //-----------------------------------------------------------------------------------------------------
  169.              if(glob::Reg.ats[1].kmi > glob::Reg.ats[0].kmi)
  170.              {
  171.                  if(kmi < 0)
  172.                  {
  173.                      textBox6->Text = kmi.ToString();
  174.                  }
  175.                  else
  176.                      textBox6->Text = "Pasiekta";
  177.              }
  178.              else if(glob::Reg.ats[1].kmi < glob::Reg.ats[0].kmi)
  179.              {
  180.                  if(kmi <= 0)
  181.                  {
  182.                      textBox6->Text = "Pasiekta";
  183.                  }
  184.                  else
  185.                      textBox6->Text = kmi.ToString();
  186.              }
  187.              else
  188.                 textBox6->Text = "Pasiekta";
  189. //-----------------------------------------------------------------------------------------------------
  190.          }
  191. private: System::Void button5_Click(System::Object^  sender, System::EventArgs^  e) {
  192.  
  193.              textBox1->Text = "";
  194.              textBox2->Text = "";
  195.              textBox3->Text = "";
  196.              textBox4->Text = "";
  197.              textBox5->Text = "";
  198.              textBox6->Text = "";
  199.  
  200.              Atnaujinimas();
  201.              double ugis = glob::Reg.ats[glob::n].ugis - glob::Reg.ats[0].ugis;
  202.              double svoris = glob::Reg.ats[glob::n].svoris - glob::Reg.ats[0].svoris;
  203.              double proc = glob::Reg.ats[glob::n].proc - glob::Reg.ats[0].proc;
  204.              int ritmas = glob::Reg.ats[glob::n].ritmas - glob::Reg.ats[0].ritmas;
  205.              double kmi = glob::Reg.ats[glob::n].kmi - glob::Reg.ats[0].kmi;
  206.  
  207.              kmi = round( kmi * 100.0 ) / 100.0;
  208.  
  209.              textBox1->Text = ugis.ToString();
  210.              textBox2->Text = svoris.ToString();
  211.              textBox3->Text = proc.ToString();
  212.              textBox4->Text = ritmas.ToString();
  213.              textBox5->Text = "-----";
  214.              textBox6->Text = kmi.ToString();
  215.  
  216.          }
  217. private: System::Void button6_Click(System::Object^  sender, System::EventArgs^  e) {
  218.  
  219.              textBox1->Text = "";
  220.              textBox2->Text = "";
  221.              textBox3->Text = "";
  222.              textBox4->Text = "";
  223.              textBox5->Text = "";
  224.              textBox6->Text = "";
  225.  
  226.              Atnaujinimas();
  227.              double ugis = 0;
  228.              double svoris = 0;
  229.              double proc = 0;
  230.              double kmi = 0;
  231.              double ritmas = 0;
  232.              double ivertinimas = 0;
  233.  
  234.              for(int i = 0; i < glob::n; i++)
  235.              {
  236.                  ugis += glob::Reg.ats[i].ugis;
  237.                  svoris += glob::Reg.ats[i].svoris;
  238.                  proc += glob::Reg.ats[i].proc;
  239.                  ritmas += glob::Reg.ats[i].ritmas;
  240.                  kmi += glob::Reg.ats[i].kmi;
  241.                  ivertinimas += glob::Reg.ats[i].ivertinimas;
  242.              }
  243.              ugis = (ugis - glob::Reg.ats[1].ugis) / (glob::n - 1);
  244.              svoris = (svoris - glob::Reg.ats[1].svoris) / (glob::n - 1);
  245.              proc = (proc - glob::Reg.ats[1].proc) / (glob::n - 1);
  246.              ritmas = (ritmas - glob::Reg.ats[1].ritmas) / (glob::n - 1);
  247.              kmi = (kmi - glob::Reg.ats[1].kmi) / (glob::n - 1);
  248.              ivertinimas = (ivertinimas - glob::Reg.ats[1].ivertinimas) / (glob::n - 1);
  249.  
  250.              kmi = round( kmi * 100.0 ) / 100.0;
  251.              ugis = round( ugis * 100.0 ) / 100.0;
  252.              svoris = round( svoris * 100.0 ) / 100.0;
  253.              ritmas = round( ritmas * 100.0 ) / 100.0;
  254.              proc = round( proc * 100.0 ) / 100.0;
  255.              ivertinimas = round( ivertinimas * 100.0 ) / 100.0;
  256.  
  257.  
  258.              textBox1->Text = ugis.ToString();
  259.              textBox2->Text = svoris.ToString();
  260.              textBox3->Text = proc.ToString();
  261.              textBox4->Text = ritmas.ToString();
  262.              textBox5->Text = "-----";
  263.              textBox6->Text = kmi.ToString();
  264.  
  265.          }
  266. };
  267. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement