Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- int main()
- {
- ifstream f("bac1.txt");
- ifstream g("bac2.txt");
- int n, m, a, b, i=1, j=1, k=0;
- f>>n>>a;
- g>>m>>b;
- while(i<=n && j<=m){
- ///cat timp putem compara un element din a cu unul din b
- ///cout<<a<<" "<<b<<endl;
- if(a<b){
- if(a%5==0){
- cout<<a<<" ";
- }
- i++;
- f>>a;
- }
- else if(b<a){
- if(b%5==0){
- cout<<b<<" ";
- }
- j++;
- g>>b;
- }
- else if(a==b){
- i++;
- j++;
- f>>a;
- g>>b;
- }
- }
- if(i<=n){
- for(k=i; k<=n; k++){
- if(a%5==0){
- cout<<a<<" ";
- }
- f>>a;
- }
- }
- else if(j<=m){
- for(k=j; k<=m; k++){
- if(b%5==0){
- cout<<b<<" ";
- }
- g>>b;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement