With "abc" input
My output is: "acb", "bac", "bca", "cab" and "cba"
But it should be like this: "acb", "bca", "bac", "cab", and "cba"
User Profile
Collapse
-
This is my output:
Code:Enter a string: abc Original string: abc Permutations: acb bac bca cab cba Press q (or any other key) followed by 'Enter' to quit:
Leave a comment:
-
Help with Permutation
Create a program to display all of the permutations of a string of any length. A permutation is a re-arrangement of the order of letters. For example, the string "abc" has permutations "acb", "bca", "bac", "cab", and "cba"
Here is my code but I don't know how to re-arrangement. Please help me
...Code:#include <iostream> //Required if
-
-
it works. Can you explain me how it works? Pleaseee!
Thanks much!Leave a comment:
-
-
How do I change this?
How do I change something in function f1 to displays the values stored in the array a in ascending order
...Code:13 void f1(int a[]) { 14 const int m = 100; 15 int b[m]; 16 for (int j = 0; j < m; ++j) b[j] = 0; 17 for (int i = 0; i < 10; ++i) ++b[a[i]]; 18 for (int i = 0, j = 0; j < m; ++j) 19 for (int k = b[j]; k > 0; --k) a[i++] = j; -
The compiler of BloodShed did not warning for errors but program terminate when accessing the function with that replacing. Any ideas? Many thanks for the help so far.Leave a comment:
-
When I tried put that code in the function, it gave me some errors such as:
==> declaration of 'int**arr' shadows a parameter
==> `col' cannot appear in a constant-expression
How can I fix this errors?
...Code:/* to initialize matrix */ int** init(int** arr,int row,int col) { int i=0, j=0; //arr=(int**)malloc(sizeof(int)*row*col);Leave a comment:
-
Yeap, I'm taking CS 161, really basic stuff, this is my extra credit project. That's y my instructor wanted us to write functions, should not use vector at this time. Anyways, thanks much for the help!Leave a comment:
-
Help me with pointer to pointers
I'm working on dynamic arrays. I found source code in C. Please help me convert this line of code from C to C++. Thanks so much for the help.
row and col are variables
Code:arr=(int**)malloc(sizeof(int)*row*col);
-
I got it! Computer does the * and / first (left to right) then do the + and - (left to right). Thanks for the help!Leave a comment:
-
This is my output of the program:
...Code:Original Input is 12 + 34 - 34 + 11 * 4 * 11 / 1 Input after trimmed is 12+34-34+11*4*11/11 Number elements of Array is 13 Original Values of Elements of the Array A[0] = 12 A[1] = + A[2] = 34 A[3] = - A[4] = 34 A[5] = + A[6] = 11 A[7] = * A[8] = 4 A[9] = * A[10] = 11 A[11] = / A[12]
Leave a comment:
-
Ok, First, This is my input as a string 12+34-34+11*4*11/11
Then, convert them to integer and calc them.
My program gave me result is -32
But Correct must be 56
My algorithm is get the string input then create an Array and put them into the Array. For ex input above: 12 is the first element and + is second elements of the array ...etc
Then I check the the Array if there is * then get the...Leave a comment:
-
If you want to know what stdio.h does, read the Reference here
http://www.cplusplus.c om/reference/clibrary/cstdio/Leave a comment:
-
I'm newbie with C++ too, correct my if I'm wrong
#include<stdio. h> <== Include file stdio.h in the library of C Header File
#include" filename.c" <== Include file filename.c with a specific path of that fileLeave a comment:
-
Help with Simple Integer Expression
My task is Create a program to read a simple integer expression and display the result. "Simple" means no parentheses are allowed and only the +, -, *, and / operators are allowed.
I think expression would be Multiplications , then Division, then Addition and Subtraction.
My program gave me a wrong result after addition, take a look to my code you will understand. Please help me to develop this.
... -
Help me with awk command in Unix please
This is my file named students
...Code:Tom Jones 100 90 80 Nancy Jones 70 80 90 Terry Sims 55 65 75 John Terry 75 76 77 Ruth Maier 100 100 100 Mike Wolfe 90 95 98 Dennis Cole 70 80 89 Ron Maier 90 85 89 Susan Miller 65 80 90 Mad Bill 75 65
-
determine which letter appears most frequently in the text
I'm looking for info talk about this but can't find it on google. Anyone help me with this please! Do I need to use array for this? -
Finally, I got it. This problem took me more than 5 hours. Hahha. Such a dummy! Thanks for all the helps!Leave a comment:
No activity results to display
Show More
Leave a comment: