Skip to content

Instantly share code, notes, and snippets.

@invatainfo
Created September 16, 2017 15:01
Show Gist options
  • Save invatainfo/8872c08f2e210448db88cb97e5fe18f6 to your computer and use it in GitHub Desktop.
Save invatainfo/8872c08f2e210448db88cb97e5fe18f6 to your computer and use it in GitHub Desktop.
#include <fstream.h>
void main() {
ifstream f("nr1.txt"), g("nr2.txt");
int x, y, n, m, i, j;
f >> n;
g >> m;
i = j = 1;
f >> x;
g >> y;
while (i <= n && j <= m)
if (x < y) {
f >> x;
i++;
} else if (y < x) {
g >> y;
j++;
} else {
cout << x << " ";
f >> x;
g >> y;
i++;
j++;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment