Pseudocode again

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <string>   
#include <iostream>
#include <fstream>
   
using namespace std;
   
void string_permutation( string &, string&, ofstream & );
   
int main(){   
     
    string orig="abc";   
    string perm;//empty string

	ofstream outFile( "permutation.txt" );//Write in file
 
    string_permutation( orig , perm , outFile );   
   
    cout << "Complete!" << endl;   
   
    system( "pause" );//Pause window
   
    return 0;   
} 

//Permutation recursive function
void string_permutation( string& orig, string& perm ,ofstream &outFile){   

	//If empty string will display the permutation
    if( orig.empty() ){
        cout << perm << endl;
		outFile << perm << endl;
        return;   
    }   
   
    for( int i = 0 ; i < orig.size() ; ++i ){   
        string orig2 = orig;   
   
		//erase the alphabet
        orig2.erase(i,1);   
   
		//Use another variable to call the recursive function
        string perm2 = perm;   

		//Get back position for original
        perm2 += orig.at(i);   
   
        string_permutation( orig2 , perm2 , outFile );//Recursive function   
   
    }    
}  



and here is my pseudocode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Algorithm( Words , Permutation ){
	if ( words is empty ){
		write permutation
	}
	
	for i <- 0 to words size
		TemporaryWords = Words
		
		TemporaryWords.erase( i , 1 )
		
		TemporaryPermutation = Permutation
		
		TemporaryPermutation += Words.at( i )
		
		Algorithm( TemporaryWords , TemporaryPermutation )
	end for


i not really familiar with this but i will try my best to do it myself as many as possible before i post and ask any senior tyr to correct me?
I have no idea what you are asking.
i wan to ask my pseudocode write correctly or out of the box.

i not so good in write my code into my pseudocode here. so im asking some expert to guide me out
you want help in writing the pseudo code or there is some problem in your code for which you need help ?
help writing in pseudo code.

my program are done already
i complete with my own.
the problem is i not really expert to write in pseudo code although i know how to do in coding. that's the problem. haha
pseudo code is like writing the english translation of what the program does. Take this as an example:
1
2
3
4
5
6
7
8
9
10
11
12
#include <iostream>
using std::endl;

int main()
{
    std::cout << "Hello, pseudo!" << endl;
    int x = 5;
    for(int i = 0; i < 10; ++i)
    {
        x += x*i;
    }
}
using iostream
let endl be std::endl

function main nothing -> integer:
do
    write "Hello, pseudo" and endl to the standard output stream
    let x be an integer initialized to 5
    for i in [0, 10):
    do
        add the product of x and i to x
    end
end
I don't know of any strict rules on pseudo code, just make it pretty obvious that it is more english than code.
Last edited on
And I also recommend some books which give pseudo code for the actual code.. for example "introduction to algorithms by Thomas H. Cormen). You may not need to buy this book.. you can get some pseudo code snippets from the book online like at google books etc..
Topic archived. No new replies allowed.