Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- ifstream fin1("bac1.txt");
- ifstream fin2("bac2.txt");
- int a, b, n, m, i = 1, j = 1;
- int main() {
- fin1 >> n >> a;
- fin2 >> m >> b;
- while (i <= n && j <= m) {
- if (a == b) {
- fin1 >> a;
- fin2 >> b;
- i++, j++;
- } else if (a < b) {
- if (a % 5 == 0) {
- cout << a << ' ';
- }
- fin1 >> a;
- i++;
- } else {
- if (b % 5 == 0) {
- cout << b << ' ';
- }
- fin2 >> b;
- j++;
- }
- }
- while (i <= n) {
- if (a % 5 == 0) {
- cout << a << ' ';
- }
- fin1 >> a;
- i++;
- }
- while (j <= m) {
- if (b % 5 == 0) {
- cout << b << ' ';
- }
- fin2 >> b;
- j++;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement