Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

permutations/combinations
Hello!

I'm trying to write a program that outputs the possible combinations of a se
t of numbers, but I can't seem to get it right.. 

In a list of 1-2-3, the program only outputs 1-2-3.
It should be
1-2-3
1-3-2
2-1-3
2-3-1 etc... 

Any suggestions? The code:

MODULE div

INTEGER, PARAMETER :: usedmax = 3
LOGICAL, DIMENSION(usedmax) :: used
INTEGER, DIMENSION(usedmax) :: choice

CONTAINS

RECURSIVE SUBROUTINE Useit()
INTEGER :: i, j

   DO i = 1, usedmax, 1
      IF (.NOT. used(i)) then
         used(i) = .TRUE.
         WRITE (*,*) 'made choice', choice(i)
         CALL UseIt()
         RETURN
      ENDIF
   ENDDO
RETURN
   
END SUBROUTINE UseIt

SUBROUTINE Init
IMPLICIT NONE
   INTEGER :: i
   DO i = 1, usedmax, 1
      used(i) = .false.
      choice(i) = i
   ENDDO
   RETURN
   
END SUBROUTINE init
END MODULE

PROGRAM main
USE div
IMPLICIT NONE
   CALL Init
   CALL UseIt()
   STOP
END PROGRAM main

Report this thread to moderator Post Follow-up to this message
Old Post
kanskje
04-23-05 09:20 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Fortran archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 07:22 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.