Guest User

Untitled

a guest
Dec 3rd, 2015
104
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <fstream>
  4. using namespace std;
  5. //-------------------------------------
  6. const int Cmax = 100;
  7. const char CDfv[]="Duomenys.txt";
  8. const char CRfv[]="Rezultatai.txt";
  9. //-------------------------------------
  10. void Skaityti (int A[], int B[], int C[], int & n, double & msum, double & bsum);
  11. void Vidurkis(int A[], int B[], int C[], int & n, double & mvid, double & bvid, double & msum, double & bsum, double & vsum);
  12. void Tikrinti (int A[], int B[], int C[], int & n, double & mvid, double & bvid, double & bsum);
  13. void Spausdinti (double & mvid, double & bvid, double & vsum);
  14. int main(){
  15.     int A[Cmax], B[Cmax], C[Cmax], n;
  16.     double mvid, bvid, msum, bsum, vsum;
  17.     Skaityti (A, B, C, n, msum, bsum);
  18.     Vidurkis(A, B, C, n, mvid, bvid, msum, bsum, vsum);
  19.     Tikrinti(A, B, C, n, mvid, bvid, bsum);
  20.     Spausdinti(mvid, bvid, vsum);
  21. }
  22. void Skaityti(int A[], int B[], int C[], int & n, double & msum, double & bsum){
  23. ifstream fd;
  24. fd >> n;
  25. for(int i=0; i<n; i++){
  26.     fd >> C[i];
  27.     if(C[i]<0){
  28.         fd >> B[i];
  29.         bsum=bsum+B[i];
  30.         }
  31.         else
  32.         fd >> A[i];
  33.         msum=msum+A[i];
  34.     }
  35.     fd.close();
  36. }
  37. void Vidurkis(int A[], int B[], int C[], int & n, double & mvid, double & bvid, double & msum, double & bsum, double & vsum){
  38. int i;
  39. bvid=bsum/n;
  40. mvid=msum/n;
  41. vsum=C[i]/n;
  42. }
  43. void Tikrinti (int A[], int B[], int C[], int & n, double & msum, double & bvid, double & bsum){
  44. ofstream fr;
  45. for(int i=0; i<n; i++){
  46. if(B[i]>=175)
  47.     bsum=bsum+1;
  48. }
  49. if(bsum>=7)
  50.     fr << "Komanda sudaryti galima" << endl;
  51.     else
  52.     fr << "Komandos sudaryti negalime" << endl;
  53. for(int i=0; i<n; i++){
  54. if(A[i]>=175)
  55.     msum=msum+1;
  56. }
  57. if (msum==7)
  58.     fr << "Komanda sudaryti galima" << endl;
  59.     else
  60.     fr << "Komandos sudaryti negalime" << endl;
  61. }
  62.  
  63. void Spausdinti (double & mvid, double & bvid, double & vsum){
  64. ofstream fr;
  65. fr << fixed << setprecision(1) << vsum << endl;
  66. fr << fixed << setprecision(2) << bvid << endl;
  67. fr << fixed << setprecision(3) << mvid << endl;
  68. }
RAW Paste Data