Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 29-12-2010
Member
 
Join Date: Mar 2010
Posts: 732
Code for Permutations

Hey Guys, I wanted to know the code for Permutations. I don?t mind it whether it may be in any language. If anyone knowing about the code for permutation then please let me know as I wanted it very urgently. As, I said that code can be in any programming language such as C. C++, Java, C# etc? So, please let me know as I am eagerly waiting for the reply.
Reply With Quote
  #2  
Old 29-12-2010
Member
 
Join Date: May 2009
Posts: 503
Re: Code for Permutations

Code:
#include <string>
#include <iostream>

using namespace std;

void string_permutation( std::string& original, std::string& permutation )
{
    if( original.empty() )
    {
        std::cout<<permutation<<std::endl;
        return;
    }

    for(int i=0;i<original.size();++i)
    {
        std::string orig2 = orig;

        orig2.erase(i,1);

        std::string perm2 = permutation;

        perm2 += original.at(i);

        string_permutation(orig2,perm2);
    } 
}

int main()
{
    std::string orig="QWERT";
    std::string perm;  

    string_permutation(original,permutation);

    cout<<"Done!"<<endl;

    system("Stop");

    return 0;
}
This is an code for Permutations in C++. This will enable you to get the appropriate result. You need to run this code in Turbo C which will give you the appropriate result.
Reply With Quote
  #3  
Old 29-12-2010
Member
 
Join Date: Mar 2010
Posts: 732
Re: Code for Permutations

Hey thank you I got the result but know I wanted the code for factorial which I have got as assignment in my college. So, please if you have code for permutation and some simple program in C++ then please help me out. If you are having then please post it so that I could submit this assignment. So, please help me out.
Reply With Quote
  #4  
Old 29-12-2010
Member
 
Join Date: May 2009
Posts: 620
Re: Code for Permutations

This is the Program to find factorial of number which is C++ code. I think that this is the most simplest code in C++.

Code:
#include<iostream.h>
#include<conio.h>
main()
{
    int i,m,fact=1;
    clrscr();
    cout<<?Enter a positive number?;
    cin>>m
     for(i=1;i<=m;++i)
           fact=fact*I;
     cout<<?factorial of given number is   ? << fact;
 }
Reply With Quote
  #5  
Old 29-12-2010
Member
 
Join Date: Apr 2009
Posts: 484
Re: Code for Permutations

This the Program for generation of Fibonacci series 1 1 2 3 5 8 13??. Which is mostly are unable to solve. Thought it seems simple but when you think and code it, its very difficult. I think that you need to have a good technique for coding any program so that you could make it more simple and short.

Code:
#include<iostream.h>
#include<conio.h>
main()
{
   int f0 ,f1,f2,i,n;
   cout<<?Enter a  number ?;
    cin>>n;
    f0=f1=1;
    cout<< f0 <<?   ?<<f1<<?  ?;
    for(i=2;i<=n;++i)
         {
          f2=f0+f1;
          cout<<f2<<?   ?;
          f0=f1;
          f1=f2;
         }
}
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Code for Permutations"
Thread Thread Starter Forum Replies Last Post
Need help on removing Activation Required message BlackBerry 9930 Bold with MSL code SPC code Groupism Portable Devices 15 02-05-2014 03:00 PM
startup error code:0x80090006 ,,unable to locate activation code Mr.Walter Windows XP Support 3 04-01-2012 06:08 PM
Error code 801613C9 while entering gold membership code in Xbox 360 Boreanaz Portable Devices 5 08-07-2011 07:53 PM
How to perform permutations in c++ Linoo Software Development 4 09-02-2010 07:37 PM
Permutations help in php HardWeaR Software Development 3 02-12-2009 02:35 PM


All times are GMT +5.5. The time now is 08:59 PM.