Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int s[100],c[100],r[200],vf=-1,inc1=0,inc2=0,sf1=-1,sf2=-1,x;
- cout<<"Dati primul sir ordonat crescator(ultima valoare 0):";
- cin>>x;
- while(x!=0)
- {
- s[++vf]=x;
- cin>>x;
- }
- cout<<"Dati al doilea sir ordonat crescator(ultima valoare 0):";
- cin>>x;
- while(x!=0)
- {
- c[++sf1]=x;
- cin>>x;
- }
- ///Interclasare
- while(vf>=0 && inc1<=sf1)
- {
- if(s[vf]<c[inc1])
- {
- r[++sf2]=s[vf];
- vf--;
- }
- else
- {
- ///liberty fraternity
- r[++sf2]=c[inc1];
- inc1++;
- }
- }
- while(vf>=0)
- {
- r[++sf2]=s[vf];
- vf--;
- }
- while(inc1<=sf1)
- {
- r[++sf2]=c[inc1];
- inc1++;
- }
- ///afisez rezultatul prin scoaterea val din coada rezultata
- while(inc2<=sf2)
- {
- cout<<r[inc2]<<" ";
- inc2++;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement