Advertisement
MeehoweCK

Untitled

Dec 20th, 2018
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.77 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <fstream>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     int n,m,w;
  10.     ifstream plik;
  11.     plik.open("plik.txt");
  12.  
  13.     vector<int> a(n);
  14.     vector<int> b(m);
  15.     if(plik.good())
  16.     {
  17.         plik >> n >> m >> w;
  18.  
  19.         for(int i=0; i<n; i++)
  20.         {
  21.             plik >> a[i];
  22.         }
  23.         for(int i=0; i<m; i++)
  24.         {
  25.             plik >> b[i];
  26.         }
  27.     }
  28.     else
  29.     {
  30.         cout << "Nie udalo sie otworzyc pliku" << endl;
  31.         return 0;
  32.     }
  33.  
  34.     plik.close();
  35.  
  36.     int wy=0;
  37.     for(int i=0; i<n; i++)
  38.     {
  39.         for(int j=0; j<m; j++)
  40.         {
  41.             if(a[i]+b[j]==w)
  42.             {
  43.                 wy++;
  44.             }
  45.         }
  46.     }
  47.     cout << wy;
  48.     return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement