Posts
 
Reputation
Joined
Last Seen
0 Reputation Points
Unknown Quality Score

No one has voted on any posts yet. Votes from other community members are used to determine a member's reputation amongst their peers.

0 Endorsements
~6K People Reached
Favorite Forums
Favorite Tags
c++ x 12
Member Avatar for pearle

I'm supposed to rewrite a binary search function so that it uses a generic type for array elements instead of just int. The only changes I made to the function are inserting the line "template<typename T>" and changing the line "int binarySearch(const int list[], int key, int arraySize)" to "int …

Member Avatar for pearle
0
567
Member Avatar for pearle

Suppose I have something like [CODE]char *threeDays[3] = {"Monday","Tuesday","Wednesday"};[/CODE] and I wanted to extract the first letter of each string and create another string using those letters. How would I go about doing it? I tried [CODE]char str[4]; strcpy(str,*(threeDays+1)); strcat(str,*(threeDays+2));[/CODE] but that gives me "TuesdayWednesday". I just want a string …

Member Avatar for pearle
0
1K
Member Avatar for pearle

Hi, all. I'm trying to write a function that checks the status of a Tic Tac Toe game. If there's a winner, it'll return the character for the winner ('X' or 'O'). If there's a draw, it returns 'D'. I'm having trouble getting it to check whether the game is …

Member Avatar for usainbolt
0
4K
Member Avatar for pearle

Another recursive problem. I'm trying to write a function that reverses an int value recursively. I think I've got the algorithm right, but I can't get the base case right. So my program ends up printing 5 infinitely... Here's the code: [CODE]#include <iostream> #include <cmath> using namespace std; void reverseDisplay(int …

Member Avatar for WaltP
0
154
Member Avatar for pearle

Hi, everybody. I've started learning about recursion, but I'm having a hard time completely understanding it. I've tried to write a simple recursive function that returns the sum of the series m(i) = (1/3) + (2/5) + (3/7) + (4/9) + ... (i / (2i + 1)), but I keep …

Member Avatar for pearle
0
105
Member Avatar for pearle

Hi, all. I'm pretty new to C++, and I think I'm getting the hang of it, but there's a problem with a program I'm writing and I just can't seem to fix it. The program's supposed to print a pyramid like this: [ICODE] 1 1 2 1 1 2 4 …

Member Avatar for tetron
0
120