Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- int q;
- cin>>q;
- string ans[1500];
- for(int i=0;i<q;i++)
- {
- string a,b;
- cin>>a>>b;
- int c = min(a.size(),b.size());
- int j=0;
- while (j<c)
- {
- if (a[j]<b[j])
- {
- break;
- }
- else
- {
- if (a[j]==b[j])j++;
- else if (a[j]>b[j])
- {
- for (int k=j+1;k<c;k++)
- {
- if(a[k]<b[j])
- {
- char p=a[j];
- a[j]=a[k];
- a[k]=p;
- break;
- }
- else if(a[k]==b[j])
- {
- char p=a[j];
- a[j]=a[k];
- a[k]=p;
- }
- else if (k==c-1)
- {
- a="---";
- }
- }
- }
- }
- }
- cout<<a<<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement