So this is my second project in C++, but I'm having some trouble understanding Recursive functions. We are supposed to write a program that has a recursive function. And the program should ask the user for a number. And then display the number of even digits that the number had. ie. input: 22378 output: the number had 3 even digits on it So far this is my code, but I'm having lots of trouble with the recursive [CODE] #include <iostream> using namespace std; int howManyEven (int); int main (){ int number, again = 1; while (again == 1){ cout << …

Member Avatar
Member Avatar
+0 forum 2

please help me in my code the error appears and i can`t figure it out. i used to write a program that will accepts the user input, but only a word then the program will scramble the word that had been inputted by the user and display it on JFrame(WINDOW) [code]package gui; import javax.swing.*; import java.awt.*; import java.awt.event.*; import javax.swing.JOptionPane; public class FieldInputs extends JFrame { private JLabel wordL, scrambleWordL; private JTextField wordTF, scrambleWordTF; private JButton scrambleB, exitB; private ScrambleTheWordButtonHandler sbHandler; private ExitButtonHandler ebHandler; private static final int WIDTH = 400; private static final int HEIGHT = 400; public FieldInputs(){ …

Member Avatar
Member Avatar
+0 forum 9

Hi, I created a Python script using pyPDF that automatically merges all the PDFs in a folder and puts them into an output folder and rename them automatically as per the folder's name. What I want to do now is for the script to search for sub-directories, process all the PDF files in them and create an output in the sub-directory and give it the same name as the sub=dir. I have been trying to use the os.path.walk() function but I can't get the hang of it or understand it. This is my current code: [CODE]#---------------------------------------------------------------------------------------------- # Name: pdfMerger # …

Member Avatar
Member Avatar
+0 forum 10

Hello, I'm very new at C++ and I have to write a code that uses a recursive function to reverse some characters within a boundary, so lets say I have A[1] == ‘A’ A[2] == ‘B’ A[3] == ‘C’ A[4] == ‘D’ A[5] == ‘E’ and I put in a boundary like reverse between 2 to 5 I will get A[1] == ‘A’ A[2] == ‘E’ A[3] == ‘D’ A[4] == ‘C’ A[5] == ‘B’ So far this is what I have but I keep getting this link error and undefined symbol reallyReverse(char*, int, int) [CODE]include <iostream> #include <string> using …

Member Avatar
Member Avatar
+0 forum 18

I recently had an assignment for an advanced coding class where I was to create a Binary tree from inorder and preorder traversals. I first started out by creating my ADT for binary trees and working with that to create a new tree. The way I worked it was that I started by storing inorder traversal in an array and preorder in a queue and then I went through dividing the array into smaller arrays and passing it to the function again, recursively. The base case was when there was only one element in the array, i.e. a leaf. and …

Member Avatar
Member Avatar
+0 forum 5

Hi, I have been experiment with Recursion / Trasversal through directories recently but seem to have run into a few unexplainable errors. Attached is my source code which is a function (which has the path (input user directory) passed into it). What im hoping this function will do is detect if inside this directory (path) are subdirectories and if so store these in an array (creating a list of subdirectories) allowing a following function to open these inorder and run a process on all files inside. Any ideas what im doing wrong? I've look across various forums etc at FindNextFile(), …

Member Avatar
Member Avatar
+0 forum 14

Hello, I'm working on a recursive loop subcategory system. The code below is ALMOST where I need it. The last thing I'd like to do is indent each subcategory based on levels deep, rather than just separate by commas. I can't seem to wrap my head around it. Any suggestions? [CODE] function showlist($parent, &$catlistids="") { $result = mysql_query("SELECT component_part_id, component_part_quantity_used FROM builds WHERE build_part_id='$parent'"); while ($line = mysql_fetch_array($result)) { if($catlistids!=""){ $catlistids .= ", "; } $catlistids .= get_part($line["component_part_id"]) . ' ' . $line["component_part_quantity_used"]; showlist($line["component_part_id"], &$catlistids); } return $catlistids; }[/CODE]

Member Avatar
Member Avatar
+0 forum 2

The End.