Advertisement
momo2345

Permutation

Jul 23rd, 2020
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.33 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define op ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
  4. int main(){
  5.       op;
  6.       int t;
  7.       cin>>t;
  8.       while(t--){
  9.        string s;
  10.        cin>>s;
  11.        bool f=next_permutation(s.begin(),s.end());
  12.        if(f) cout<<s<<endl;
  13.        else cout<<"no answer"<<endl;
  14. }
  15.      
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement