Advertisement
a53

InterclasNoMemory

a53
Oct 1st, 2021
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. void interclasare()
  2. {
  3. ifstream fin1("file1.txt"),fin2("file2.txt");
  4. ofstream fout("file.out");
  5. int n, m, nr1, nr2;
  6. fin1>>n;
  7. fin2>>m;
  8. int i=0,j=0;
  9. fin1>>nr1;
  10. fin2>>nr2;
  11. while(i<n&&j<m)
  12. if(nr1<nr2)
  13. fout<<nr1<<' ',++i,fin1>>nr1;
  14. else
  15. fout<<nr2<<' ',++j,fin2>>nr2;
  16. while(i<n)
  17. fout<<nr1<<' ',++i,fin1>>nr1;
  18. while(j<m)
  19. fout<<nr2<<' ',++j,fin2>>nr2;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement