Advertisement
rotti321

T4 2021 SII ex 3

May 19th, 2021
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. ifstream f("bac1.txt");
  9. ifstream g("bac2.txt");
  10. int n, m, a, b, i=1, j=1, k=0;
  11. f>>n>>a;
  12. g>>m>>b;
  13. while(i<=n && j<=m){
  14. ///cat timp putem compara un element din a cu unul din b
  15. ///cout<<a<<" "<<b<<endl;
  16. if(a<b){
  17. if(a%5==0){
  18. cout<<a<<" ";
  19. }
  20. i++;
  21. f>>a;
  22. }
  23. else if(b<a){
  24. if(b%5==0){
  25. cout<<b<<" ";
  26. }
  27. j++;
  28. g>>b;
  29. }
  30. else if(a==b){
  31. i++;
  32. j++;
  33. f>>a;
  34. g>>b;
  35. }
  36. }
  37. if(i<=n){
  38. for(k=i; k<=n; k++){
  39. if(a%5==0){
  40. cout<<a<<" ";
  41. }
  42. f>>a;
  43. }
  44. }
  45. else if(j<=m){
  46. for(k=j; k<=m; k++){
  47. if(b%5==0){
  48. cout<<b<<" ";
  49. }
  50. g>>b;
  51. }
  52. }
  53. return 0;
  54. }
  55.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement