# Pascal Pseudo Code

Page 1 of 1

## 1 Replies - 550 Views - Last Post: 30 March 2010 - 02:54 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=165205&amp;s=d32c9636c135af38b8e6d2feeb5fd39a&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 Whiskers12345

Reputation: 0
• Posts: 14
• Joined: 01-March 10

# Pascal Pseudo Code

Posted 30 March 2010 - 01:51 PM

Trying to convert Pascal to C++ to sort an array of double numbers

Pascal (pseudo code):
```procedure insertsort(var r: list ; n : integer)
var j, i, save : integer;
begin
for i := n-1 downto 1 do
begin
j := i+1;
save := r[i];
r[n+1] := save;
while save > r[j] do
begin
r[j-1] := r[j];
j := j+1;
end
r[j-1] := save;
end;
end;

```

My C++ Version that does not work

```void Insert(double A[], int &N)
{
int i, j;
double save;
for(i=0; i<N; i++)
{
j=i+1;
save=A[i];
A[N+1]=save;
while(save>A[j])
{
A[j-1] = A[j];
j++;
}
A[j-1]=save;
}
}

```

Current Output:

Insert Sort:
-6155.667 44.830 -7.117 70.028 -70.879
-41.304 -19.709 -25.004 17.377 26.585

any help would be appreciated...thank you

Is This A Good Question/Topic? 0

## Replies To: Pascal Pseudo Code

• Saucy!

Reputation: 6193
• Posts: 23,920
• Joined: 23-August 08

## Re: Pascal Pseudo Code

Posted 30 March 2010 - 02:54 PM

Duplicate of post in C/C++. Please do NOT create duplicate topics.

Closed.