daily pastebin goal
34%
SHARE
TWEET

Untitled

a guest Feb 17th, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <vector>
  4. #include <algorithm>
  5.  
  6. using namespace std;
  7. struct studentas{
  8. string firstName;
  9. string secondName;
  10.  
  11.  
  12. vector<double> nd;
  13. double egz;
  14. };
  15. void display ();
  16. double median (vector<double> set);
  17. int main()
  18. {
  19. //Storing information
  20.         cout << "Kiek noresite ivesti studentu ?"<< endl;
  21.             int stud;
  22.             cin >> stud;
  23.             /*
  24.             while (stud =< 0 || stud == " ")
  25.             {
  26.                 cout << "Ivedet neteisingus duomenis, prasome vesti per nauja: "<< endl;
  27.             cin >> stud
  28.             }
  29.             */
  30.             cout << "Kiek noresite ivesti namu darbu ?"<< endl;
  31.              int n;
  32.             cin >> n;
  33.  
  34.              vector<double> ndVid(n);
  35.  
  36.             vector<double> galutinis(stud);
  37.             vector<double> galutinis2(stud);
  38.  
  39. vector<studentas> s(stud);
  40.  
  41.         cout << "Iveskit studentu informacija: " << endl;
  42.  
  43.         for (int i = 0; i < stud; i++)
  44.         {
  45.             ndVid[i] = 0;
  46.             s[i].nd.resize(n);
  47.             cout << "Iveskit varda: ";
  48.             cin >> s[i].firstName;
  49.  
  50.             cout << "Iveskit pavarde: ";
  51.             cin >> s[i].secondName;
  52.  
  53.             cout << "Iveskit egzamino rezultata: ";
  54.             cin>> s[i].egz;
  55.  
  56.             for (int j = 0; j< n; j++){
  57.                 cout << "Iveskit namu darbo rezultata: ";
  58.                 cin >> s[i].nd[j];
  59.                 //Vidurkio skaiciavimas
  60.                 ndVid[i]+=s[i].nd[j];
  61.                 //cout << ndVid[i] << endl;
  62.  
  63.         }
  64.         ndVid[i] /= n;
  65.  
  66. //Galutinio formule
  67.         galutinis[i] = 0.4 * ndVid[i] + 0.6 * s[i].egz;
  68.         galutinis2[i] = 0.4 * median(s[i].nd[i]) + 0.6 * s[i].egz;
  69.         }
  70.  
  71.  
  72.  
  73.  
  74. //Displaying information
  75.  
  76. cout << "Jeigu norite skaiciuote galutini su vidurkiu spauskitine 0, jeigu su mediana, spauskite 1"<< endl;
  77. int tmp=0;
  78. cin >> tmp;
  79. if (tmp == 0){
  80.         //Su vidurkiu
  81.         cout << "Jusu pateikta informacija: " << endl;
  82.  
  83.         cout << "Pavarde" << "    " << "Vardas" <<"   "<< "Galutinis(Vid.)" << endl;
  84.  
  85.     for (int i = 0; i < 20; i++ ){
  86.         cout <<"-";
  87. }
  88. cout<<endl;
  89.  
  90.     for (int i = 0; i <stud; ++i)
  91. {
  92.         cout << s[i].firstName << "    " << s[i].secondName << fixed<< setprecision(2) <<"    "<< galutinis[i] << endl;
  93. }
  94. }
  95. //Su mediana
  96. else {
  97.     cout << "Jusu pateikta informacija: " << endl;
  98.  
  99.         cout << "Pavarde" << "    " << "Vardas" <<"   "<< "Galutinis(Med.)" << endl;
  100.  
  101.     for (int i = 0; i < 20; i++ ){
  102.         cout <<"-";
  103. }
  104. cout<<endl;
  105.  
  106.     for (int i = 0; i <stud; ++i)
  107. {
  108.         cout << s[i].firstName << "    " << s[i].secondName << fixed<< setprecision(2) <<"    "<< galutinis2[i] << endl;
  109. }
  110. }
  111.  return 0;
  112. }
  113.  
  114.  
  115.  
  116.  
  117. //Medianos skaiciavimas
  118. double median (vector<double> set)
  119. {
  120.     sort(set.begin(), set.end());
  121.  
  122. return (set.size()% 2 == 0 ? (set[set.size()/2] + set[(set() / 2 ) - 1]) / 2 : set[set.size() / 2]);
  123. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top