Permutaion Prog1 - #include <stdio.h> #include...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
#include <stdio.h> #include <stdlib.h> #include <string.h> # void ListPermutations(char str[]); void RecursivePermute(char str[], int k); void ExchangeCharacters(char str[], int i, int j); int BinarySearch(int A[], int low, int high, int target); void printNumber(int x); v int main() { FILE* ifp; int n, x=0; ifp = fopen("", "r"); fscanf(ifp, "%d", &n); char word[20]; // Let the user enter a word to permute. printf("Please enter a word you would like to permute.\n"); scanf("%s", word); // Print out the permutations. printf("\Here are the permutations:\n\n"); ListPermutations(word); system("PAUSE"); return 0; } // Pre-condition: str is a valid C String. // Post-condition: All permutations of str (assuming all distinct // characters) will be printed. void ListPermutations(char str[]) { // Call the appropriate recursive function with the correct // parameters. RecursivePermute(str, 0); } // Pre-condition: str is a valid C String, and k is non-negative and // less than or equal to the length of str. // Post-condition: All of the permutations of str with the first k
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 2

Permutaion Prog1 - #include &lt;stdio.h&gt; #include...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online