Advertisement
momo2345

string permutation 2

Jul 24th, 2020
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 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. {
  6.     op;
  7.     int t;
  8.     cin>>t;
  9.     for(int j=1;j<=t;j++){
  10.         int n,k,d=0;
  11.         cin>>n>>k;
  12.         char c='A';
  13.         string s;
  14.         for(int i=1;i<=n;i++){
  15.             s+=c;
  16.             c++;
  17.         }
  18.         cout<<"Case "<<j<<":"<<"\n";
  19.         do{
  20.             cout<<s<<endl;
  21.             d++;
  22.             if(d==k) break;
  23.         }while(next_permutation(s.begin(),s.end()));
  24.         d=0;
  25.     }
  26.  
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement