Please help !!! 
Author Message
 Please help !!!

Hi, I have a problem of Turbo Pascal v.7. Can anyone help me to fix it.
Problem is how to provide the output when n is 3, 5, and 7. Please indicate
where's wrong and give me a solution. Thanks !

Program test;
var
   NumArray : Array [1..7] of Integer;
   i,j,k,r,q,c,n : Integer;

Procedure A (outarray:array of Integer;arrayno:Integer);
var
   i:Integer;
   Begin
        for i:=0 to arrayno -1 do
        write (outarray[i], ' ');
        writeln;
   End;
   Function B (x,y : Integer):Integer;
   Begin
        B:=x div y;
   End;
Begin
   Write ('Enter a number: ');
   Readln (n);
if n > 0 then
   Begin
   NumArray[1]:=n;
   k:=1;
   Repeat
         A(NumArray,k);
         if NumArray [k]<> 1 then
         Begin
            NumArray [k]:=NumArray[k] -1 ;
            NumArray [k+1]:=1;
            k:=k+1;
         End
         else
         Begin
             c:=0;
             i:=k;
             while NumArray[i]=1
             do
             Begin
               c:=c+1;
               i:=i-1;
         End;
         Begin
             NumArray[i]:=NumArray[i] -1;
             q:=B(c+1,NumArray[i]);
             r:=c+1 - q*NumArray[i];
             j:=1;
             while j=q
             do
               NumArray[i+1]:=NumArray[i];
               i:=i+1;
               j:=j+1;
          End;
          Begin
             if r=0 then
                k:=i;
                k:=i+1;
                 NumArray[k]:=r;
             end;
          End;
   until NumArray[1]=1;
   End;
A(NumArray, n);
End.



Wed, 26 Nov 2003 19:13:53 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Please Please, help me with memo-fields, real problem

2. Please, please help me with this code.

3. PLEASE PLEASE HELP ME

4. Please Please help me

5. *.exe help !!!! PLEASE HELP ME

6. programming help **please help me** its not hard

7. Please Help Help ....D4 and Oracle 8.04

8. Need help with Hailstone Sequence program please Help

9. need help on prcedures (please help)

10. I need help fixing this CASE Select code, please help

11. HELP, Please help. Delphi and TAPI

12. HELP!! Please help beginner w/ easy lab project

 

 
Powered by phpBB® Forum Software