Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

C / C++ Forum


You are currently viewing our C / C++ Forum as a guest. Please register to participate.
Login



Reply
Simple Permutation using C with characters?
Old 12-30-2010, 10:18 AM Simple Permutation using C with characters?
phazorRise's Avatar
Skilled Talker

Posts: 57
Name: Sachin Gutte
Trades: 0
I want to kno about permutation with string to find out possible combinations ! Suggest any link or part of code you know about this !
phazorRise is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-30-2010, 11:54 AM Re: Simple Permutation using C with characters?
chrishirst's Avatar
Defies a Status

Posts: 44,046
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
permutation or combination??

They are two different things.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 12-31-2010, 01:54 AM Re: Simple Permutation using C with characters?
phazorRise's Avatar
Skilled Talker

Posts: 57
Name: Sachin Gutte
Trades: 0
Quote:
Originally Posted by chrishirst View Post
permutation or combination??

They are two different things.
Umm.. Permutation ! Want to use it in anagram program ! Thank you
phazorRise is offline
Reply With Quote
View Public Profile
 
Old 12-31-2010, 04:32 PM Re: Simple Permutation using C with characters?
King Spam Talker

Posts: 1,110
Name: Paul W
Trades: 0
See unicell's reply in http://www.daniweb.com/code/snippet216770.html
__________________
Great music:
Please login or register to view this content. Registration is FREE



Please login or register to view this content. Registration is FREE
PaulW is offline
Reply With Quote
View Public Profile
 
Old 01-31-2011, 06:47 AM Re: Simple Permutation using C with characters?
Novice Talker

Posts: 4
Name: Jaionezensis
Trades: 0
  1. main()
  2. {
  3. int a[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
  4. int count = 0;
  5. do
  6. {
  7. if ( ( a[0] + a[1] + a[2] ) == 17 &&
  8. ( a[0] + a[3] + a[6] ) == 17 &&
  9. ( a[2] + a[5] + a[8] ) == 17 &&
  10. ( a[2] + a[4] + a[6] ) == 17 &&
  11. ( a[6] + a[7] + a[8] ) == 17 )
  12. {
  13. cout <<count << " : ";
  14. for ( int i = 0 ; i <9 ; i++ )
  15. cout <<a[ i ] <<" ";
  16. cout <<"\n";
  17. }
  18. count++;
  19. } while ( next_permutation( a, a + 9 ) );
  20. cout <<count <<" permutations were tested\n";
  21. return 0;
  22. }
__________________

Please login or register to view this content. Registration is FREE
Jaionezensis is offline
Reply With Quote
View Public Profile
 
Old 02-23-2011, 11:26 AM Re: Simple Permutation using C with characters?
Extreme Talker

Posts: 206
Name: vikas
Trades: 0
it would be better if you do google about the same .... its a vast topic may be you would like start with small example and then go forward ... start reading it will surely help better start with examples
__________________

Please login or register to view this content. Registration is FREE
Collection of free online books and free ebooks
Please login or register to view this content. Registration is FREE
- Free online pdf books and free pdf eBooks
vikas1234 is offline
Reply With Quote
View Public Profile
 
Old 05-24-2011, 01:13 AM Re: Simple Permutation using C with characters?
Average Talker

Posts: 18
Trades: 0
sample code to write permutation in C,

#include<stdio.h>
#include<stdlib.h>
int lev=-1,n,val[50],a[50];
void main()
{
int i,j;
clrscr();
printf("Enter howmany numbers
");
scanf("%d",&n);
for(i=0;i<n;i++)
{
val[i]=0;
j=i+1;
scanf("%d",&a[j]);
}
visit(0);
getch();
}
visit(int k)
{
int i;
val[k]=++lev;
if(lev==n)
{
for(i=0;i<n;i++)
printf("%2d",a[val[i]]);
printf(" ");
}
for(i=0;i<n;i++)
if(val[i]==0)
visit(i);
lev--;
val[k]=0;
}
techforums123 is offline
Reply With Quote
View Public Profile Visit techforums123's homepage!
 
Reply     « Reply to Simple Permutation using C with characters?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.20320 seconds with 11 queries