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
how we can make 3d venturing graphics on outer interface
How to define structures? ·
Can variables be declared anywhere in c?
What does p mean in physics?
7-Given an index k, return the kth row of the Pascal's triangle. For example, when k = 3, the row is [1,3,3,1]. For reference look at the following standard pascal’s triangle.
Can you tell me how to check whether a linked list is circular?
What does it mean when the linker says that _end is undefined?
What does double pointer mean in c?
What is bubble sort in c?
Explain how do you print only part of a string?
What is wrong with this declaration?
Why is structure important for a child?
Explain what is meant by high-order and low-order bytes?
Are there namespaces in c?
What happens if you free a pointer twice?