Advertisement
Eddie_1337

bac 2009 var 12 sub 3 ex 3

Nov 1st, 2017
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5.  
  6. int m, i, x;
  7.  
  8. bool verif(int v[101]) {
  9.     while (v[i] <= x)
  10.         if (x == v[i])
  11.             return 0;
  12.         else
  13.             if (i != m)
  14.                 i++;
  15.     return 1;
  16. }
  17.  
  18. int main() {
  19.     int v[101], j = 0, n, c = 0;
  20.     ifstream f("BAC.TXT");
  21.     f >> m >> n;
  22.     for (i = 1; i <= m; i++)
  23.         f >> v[i];
  24.     i = 1;
  25.     while (j < n) {
  26.         f >> x; j++;
  27.         if (verif(v)) {
  28.             cout << x << ' ';
  29.             c++;
  30.         }
  31.     }
  32.     cout << endl << c << endl;
  33.     f.close();
  34.     system("pause");
  35. }
  36.  
  37. /*  9 12
  38.     3 5 10 23 25 28 30 40 61
  39.     1 2 13 15 23 25 26 30 31 32 35 36  */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement