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
What are the __date__ and __time__ preprocessor commands?
Tell us the use of fflush() function in c language?
What is difference between array and structure in c?
"%u" unsigned integer print the a) address of variable b) value of variable c) name of a variable d) none of the above
When is the “void” keyword used in a function?
What are c preprocessors?
Why we use conio h in c?
Do you know the difference between exit() and _exit() function in c?
What are preprocessor directives in c?
I need a sort of an approximate strcmp routine?
Given two strings S1 and S2. Delete from S2 all those characters which occur in S1 also and finally create a clean S2 with the relevant characters deleted.
Is c is a high level language?
how to introdu5ce my self in serco
Explain what does the function toupper() do?
if p is a string contained in a string?