49,761 Topics
| |
Anyone know how to do this question? Use recursion to implement the following recurrence relation f(x): f(x)=1 where =1 f(x) = f((x+1)/2) +1 where x is odd f(x) = f(x/2) +1 where x is even This is what i did: [CODE]#include<stdio.h> int func (int x) int main() { int x; … | |
| |
//I have this running but when the user inputs a different character than the program just out puts the error //message and that its. I want it to go back and ask the user if they would like to run the program again. Any //ideas? Thank you! [CODE]int main () … | |
I'm having trouble writing an array program that deletes duplicate numbers in an array. I can't figure out the code for find the array size. I have the array max set to 25 but my array doesn't have 25 numbers in it. (let's say it only has 10 numbers in … | |
Hello I'm trying to display the memory location(s) of an array of pointers. It works, but it prints the memory locations out as: e.g. [code] (0x7fff672e19a0) [/code] I know that is the memory location, but in other examples, I've seen it being displayed as [code] 4041 [/code] Here is the … | |
Hey guys I'm here again with another problem. I want to search in a string for a string with quotes in it. Example: [CODE]String to search = {' </a></div></div></div><div class="clearfix"><table cellspacing="0" class="wsod_quoteData"><tr><td class="wsod_last wsod_lastIndex" nowrap="nowrap" '} What to search for = {' <table cellspacing="0" class="wsod_quoteData"> '} Then if found, from … | |
Using strings [CODE] #include <iostream> #include <string> using namespace std; string replaceSubstring(string, string, string); int main() { string string1 = "the dog jumped over the fence", string2 = "the", string3 = "that", newString; cout << "This program will replace a keyword in a sentence with another word.\n\n\n"; cout << "Our … | |
So I have question regarding a program I need to write. I need to read a text file which consists of a location and the coordinates of it's longitude and latitude. The program should be able to read any amount of spaces and tabs in between the tokens. So it … | |
Hello, I am working on a script that reads each individual character from a txt file and then outputs it depending on whether it's in the alphabet or not.. The problem is, it won't output spaces or anything apart from the string.. e.g. The text file reads: [code] Hello, my … | |
Hello all. I've been trying to create a paintbrush with win32, but to no avail. The best that I've been able to do is plot a few pixels here and there (with SetPixel(), but never in a straight, seamless line (the way the pencil tool works in Microsoft paint for … | |
Hi! I'm almost done with this program, but I have a problem: Whenever it displays the prime numbers, it throws in non prime numbers that are odd (like 9 and 15) Here is the code so far. [CODE] /* File: isprime.cpp Created by: Ricardo Renta Creation Date: 11/8/11 Synopsis: This … | |
Hi all, As the title says, I have to create a C++ program (for my thesis) that will solve all the motion equations and have a graphic of the moving engine system. I've done all the "heavy" lifting but I am stuck on the graphics part as I haven't work … | |
Hi, all. I am a undergraduate computer engineer major, and I am currently learning Bode plots. I am very fluent with C++ but have been out of the game, as far as creating something goes. I am looking to implement a program that can construct a Bode Plot. A bode … | |
Hi everyone! When i compile my small piece of code it gives me the error [COLOR="Red"]C2512 : No appropriate default constructor available[/COLOR] this is my definition of class person: [CODE] // Person.h // A class defining a person #pragma once #include <iostream> #include <string> #include <functional> using std::cout; using std::endl; … | |
In this code i would like to store the values that are being outputted. [CODE] fstream filestr; char check[4]; filestr.open("D:\\bio.pdf", fstream::in | fstream::binary); if(filestr.is_open()) { int i; char check[4]={0}; for(i=0;i<4;i++) { filestr.read(&magic[i],1); [COLOR="Red"]cout<<hex<<static_cast<int>(check[i])<<endl;[/COLOR] //<-- This LINE } } [/CODE] The numbers that are printed here i would like to save … | |
I have just completed my first program in c++.I am an ultra newbie,have only been doing c& c++ for 12 days,so please forgive me if my program is shit.Anyways i would like the experts on this forum to evaluate my work and give me tips and hints to make myself … | |
Write a program that uses two parallel arrays to store student names and their grades. It should use an array of strings that hold the names and a two-dimensional array of integers for grades. Use nested loop to add individual student grades and get the average grade of each. The … | |
So, I am suppose to make the bar chart looking like the picture attached below using Array and for loops. It suppose to output a bar chart (using "*") of temperatures for the hours. Range of temperatures should be from -30 to 120. Each * should have amount of 3 … | |
I made a code(test1.cpp) from an existing code of a game (ramble_shuffle.cpp) using classes...but the code gets stuck somewhere...Iam unable to find the fault...can some1 find please...the code hangs up.... Original game code : shuffle_game.cpp my code : test1.cpp | |
This is a program which i am making of a quiz in which there are lifelines for helping the user solve his question. this function is to chose from whichever lifeline the user wants to chose. but my problem is that it is not inputing the string i.e not using … | |
hi! i want to move a character A on the screen by using arrow keys. i know that there are 25 rows and 80 columns.i take a character input as follows: char input; cin>>input; int put=input; here, the ascii value of input goes in put. i am using the ascii … | |
I have the following piece of code which I'm trying to understand. I know what this code does, but I don't get what each element mean. Can somebody please explain it to me? [CODE]typedef int(__stdcall * pICFUNC)(int, int); pICFUNC add; add = pICFUNC(lpfnGetProcessID);[/CODE] Basically, this code allows me to prototype … | |
hello , i made a election program , here it is [CODE]#include <iostream> #include <cstdlib> #include <string> #include <conio.h> #include <iomanip> #include <fstream> using std::ofstream; using namespace std; string users[4]; char choice2; int votes[100] = {0}; int choice; int totalVotes=0; void votes1() { cout<<"Voting! : "<<endl; cout<<setw(21)<<left<<"(1) To vote " … | |
Hello! I was given the following problem: Define the function f(x; y) as: f(x,y) = sqrt(x^2-y^2) Write a program that produces a table of f(x, y) for integers x and y from 0 to n where y <= x. The value of f(x,y) appears in row (x+1), column (y +1) … | |
So, I need to make a program that draws a [URL="http://en.wikipedia.org/wiki/Automata_theory"]finite automata[/URL] from the input data. I had some experience with the [I]graphics.h[/I] header but as far as I know it's a Borland only header and VC++ doesn't support it. So I was wondering, is there a way to draw … | |
The below code gives an output of: [CODE] Allocated! Allocated! Deleted! Allocated! Allocated! Deleted! Size: 3 Capacity: 4 vector[0]: isAligned! 20 30 40 Deleted! Deleted! [/CODE] Can someone explain the first allocation and why there are 4 allocations instead of 2 (one for each reserve?). I figure the first is … | |
Basically I need to read from a text file that looks like this customer Kevin checking myaccount 100.00 bond mybond1 1997 100 0.07 bond mybond2 2010 200 0.01 irabond myirabond1 1997 100 0.06 end customer Mark irabond hisirabond1 1999 200 0.08 bond hisbond1 1990 2000 0.10 end I need to … | |
I have an assignment to write a program that builds an array Usize determined by user inputs m,n. the hangup is that the first element in each row or column is equal to the number of the row or column,and all the elements inside are to be the value of … | |
I'm having trouble figuring out why my extractMax function isn't working correctly. I'm reading from an input file that looks something like this: [CODE](arule, 12), (brule, 21), (zrule, 70), (drule, 25), (erule, 10) (frule, 3) (grule, 20), (srule, 100)[/CODE] It should read the priorities into an array, build the heap, … | |
Hey all I have a program that I have been working on and am having some trouble with keeping count of all the users grades. I know that now I am only counting the last grade earned for each category but I want to know how to keep count of … |
The End.