logic for generating all the combinations of the any number
of given letters.
ex:::::::::
if a,b,c,d are given the o/p should be
abcd,dcba,dbac,bcad,................
4*3*2*1 combinations............
Answer Posted / ashok kannan
#include<stdio.h>
#include<conio.h>
#include<string.h>
char a[10];
int m;
void permute(int n,int i)
{
int j;
for(j=i;j<m;j++)
{
printf("%c",a[j]);
if(n!=0)
{
permute(n-1,i+1);
}
else
{
printf("%c\n",a[j]);
}
}
void main()
{
printf("enter the string to be permuted");
scanf("%s",a);
m=strlen(a);
permute(m,0);
}
| Is This Answer Correct ? | 2 Yes | 4 No |
Post New Answer View All Answers
In a byte, what is the maximum decimal number that you can accommodate?
Explain which of the following operators is incorrect and why? ( >=, <=, <>, ==)
Explain is it better to bitshift a value than to multiply by 2?
What is unary operator?
How we can insert comments in a c program?
How many parameters should a function have?
A SIMPLE PROGRAM OF GRAPHICS AND THEIR OUTPUT I WANT SEE WAHAT OUTOUT OF GRAPHICS PROGRAM
What is page thrashing?
What is a good way to implement complex numbers in c?
i have to apply for the rbi for the post of officers. i need to know abt the entrance questions whether it may be aps or techinical....
How would you rename a function in C?
What are qualifiers in c?
Explain what are compound statements?
Explain what is the advantage of a random access file?
Write a program to know whether the input number is an armstrong number.