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............
Answers were Sorted based on User's Feedback
Answer / abdur rab
#include <stdio.h>
void permute ( char* strptr, int start, int length )
{
int count1;
int count2;
int temp;
for ( count1 = start; count1 < length - 1;
++count1 ) {
for ( count2 = count1 + 1; count2 < length;
++count2 ) {
temp = strptr [ count1 ]; strptr [
count1 ] = strptr [ count2 ]; strptr [ count2 ] = temp;
permute ( strptr, count1 + 1,
length );
temp = strptr [ count1 ]; strptr [
count1 ] = strptr [ count2 ]; strptr [ count2 ] = temp;
}
}
printf ( "\n%s", strptr );
}
int main ( int argc, char* argv [] )
{
char str[] = "abcd";
permute ( str, 0, ( strlen ( str ) ) );
return 0;
}
Is This Answer Correct ? | 7 Yes | 4 No |
Answer / 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 |
which operator is known as dummy operator in c?
Draw a flowchart to produce a printed list of all the students over the age of 20 in a class .The input records contains the name and age of students. Assume a sentinel value of 99 for the age field of the trailer record
Is struct oop?
1. Can we use the for loop this way? for(;i>5;) 2. What is the use of pointers? 3. what is array of pointer? 4. What is the difference between file and database? 5. Define data structure?
Write a program that an operator and two operands read from input operand operator on the implementation and results display.
what is use of malloc and calloc?
What is an example of structure?
why should i select you?
what is a void pointer?
What is the 'named constructor idiom'?
What is a global variable in c?
what is the difference between structural,object based,object orientd programming languages?