Advertisement
Guest User

prostesti

a guest
Feb 18th, 2020
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int s[100],c[100],r[200],vf=-1,inc1=0,inc2=0,sf1=-1,sf2=-1,x;
  8. cout<<"Dati primul sir ordonat crescator(ultima valoare 0):";
  9. cin>>x;
  10. while(x!=0)
  11. {
  12. s[++vf]=x;
  13. cin>>x;
  14. }
  15. cout<<"Dati al doilea sir ordonat crescator(ultima valoare 0):";
  16. cin>>x;
  17. while(x!=0)
  18. {
  19. c[++sf1]=x;
  20. cin>>x;
  21. }
  22. ///Interclasare
  23. while(vf>=0 && inc1<=sf1)
  24. {
  25. if(s[vf]<c[inc1])
  26. {
  27. r[++sf2]=s[vf];
  28. vf--;
  29.  
  30. }
  31. else
  32. {
  33. ///liberty fraternity
  34. r[++sf2]=c[inc1];
  35. inc1++;
  36. }
  37. }
  38. while(vf>=0)
  39. {
  40. r[++sf2]=s[vf];
  41. vf--;
  42. }
  43. while(inc1<=sf1)
  44. {
  45. r[++sf2]=c[inc1];
  46. inc1++;
  47. }
  48. ///afisez rezultatul prin scoaterea val din coada rezultata
  49. while(inc2<=sf2)
  50. {
  51. cout<<r[inc2]<<" ";
  52. inc2++;
  53. }
  54. return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement