Advertisement
Guest User

Untitled

a guest
Feb 17th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <vector>
  4.  
  5. using namespace std;
  6. struct studentas{
  7. string firstName[100];
  8. string secondName[100];
  9.  
  10.  
  11. vector<double> nd;
  12. vector <double>egz;
  13. };
  14. int main()
  15. {
  16. //Storing information
  17. cout << "Kiek noresite ivesti studentu ?"<< endl;
  18. int stud;
  19. cin >> stud;
  20. /*
  21. while (stud =< 0 || stud == " ")
  22. {
  23. cout << "Ivedet neteisingus duomenis, prasome vesti per nauja: "<< endl;
  24. cin >> stud
  25. }
  26. */
  27. cout << "Kiek noresite ivesti namu darbu ?"<< endl;
  28. int n;
  29. cin >> n;
  30.  
  31. vector<double> ndVid(n);
  32. //double ndMed[n];
  33. vector<double> galutinis(stud);
  34.  
  35. studentas s;
  36. s.nd.resize(100);
  37. s.egz.resize(100);
  38.  
  39. cout << "Iveskit studentu informacija: " << endl;
  40.  
  41. for (int i = 0; i < stud; i++)
  42. {
  43. ndVid[i] = 0;
  44. cout << "Iveskit varda: ";
  45. cin >> s.firstName[i];
  46.  
  47. cout << "Iveskit pavarde: ";
  48. cin >> s.secondName[i];
  49.  
  50. cout << "Iveskit egzamino rezultata: ";
  51. cin >> s.egz[i];
  52.  
  53. //Vidurkio skaiciavimas
  54. for (int j = 0; j< n; j++){
  55. cout << "Iveskit namu darbo rezultata: ";
  56. cin >> s.nd[j];
  57. cout << s.nd[j];
  58. ndVid[i] += s.nd[j];
  59.  
  60. }
  61.  
  62.  
  63. ndVid[i] /= n;
  64.  
  65. galutinis[i] = 0.4 * ndVid[i] + 0.6 * s.egz[i];
  66.  
  67. }
  68. //Displaying information
  69.  
  70. cout << "Jusu pateikta informacija: " << endl;
  71.  
  72. cout << "Pavarde" << " " << "Vardas" <<" "<< "Galutinis(Vid.)" << endl;
  73.  
  74. for (int i = 0; i < 20; i++ ){
  75. cout <<"-";
  76. }
  77. cout<<endl;
  78.  
  79. for (int i = 0; i <stud; ++i)
  80. {
  81. cout << s.firstName[i] << " " << s.secondName[i] << fixed<< setprecision(2) <<" "<< galutinis[i] << endl;
  82. }
  83.  
  84.  
  85.  
  86.  
  87. return 0;
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement