পার্মুটেশন কাকে বলে বা পার্মুটেশন কি সেটি বিস্তারিত জানার জন্য উইকির এই লিংকে  ঢুঁ দিয়ে এসো-
পার্মুটেশন সম্পর্কিত কিছু প্রোগ্রামিং প্রব্লেম প্রতিযোগিতায় আসে। আমি এখানে শুধু STL ব্যবহার করে কিভাবে পার্মুটেশন করা যায় তা নিয়ে জানাবো।
STL ব্যবহার করে পার্মুটেশনের সিউডো কোড এই রকম-
    do
{
//Here write code as your requirements
{
//Here write code as your requirements
    }while(next_permutation(a, a+n)); 
Code:
/*  Next Permutation */
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
    char a[3]={'a','b','c'};
    do
    {
        for(int i=0; i<3; i++)
        {
            printf("%c ", a[i]);
        }
        printf("\n");
    }while(next_permutation(a,a+3));
    return 0;
}
No comments:
Post a Comment