49,761 Topics
| |
[code] int log2(int n) { int count = 1; while(!n >= 1) { if (n%2 == 0) { count++; n=n/2; } else { count++; n=n/2; floor(n); } } return count; } [/code] not sure why it isnt working? | |
Everything work except for the fact that it cannot solve the whole puzzle, only a few rows. If somebody could just look over the recursive backtracking part of the algorithm, that would be greatly appreciated. Here's the snippet of code that I think is causing me grief: [code] /* @member … | |
I am trying to write in a file using VC++. my program is to read the entries from the listview and write them in a text file. however i am unable to give newline after each column in listview is written , thus entire listview contents get written in a … | |
once I have assigned a file name to a stream object, and no longer have direct access to that file name but I do have access to the stream object is there a way to extract the file name from it? It has to know it because subsequent operations read/write … | |
Hi all. I'm a novice with C++ and I'd like to make a program that will present the user with a series of exam questions, most of which are numbers but some of which are descriptions. I want each question to repeat until the user enters the correct response (but … | |
Im doing a c++ course at uni and one of my questions is to read in an external file, input a number (like 64) then the program will search the file for the number and output how many times the number the user input comes up in the file. here … | |
Hello, I'm new to gui programming althou i've done things before in c++ i've always encountered this error and never really tried to fix it. Lets for say I have a counter label and a button that says "Start" when one clicks start the label changes values from 0 to … | |
I AM FACING PROBLEMS WITH SEPARATING SENTENCES FROM A TEXT . FOR eg. if i separate sentence after each '.' then it won't help for Dr.xyz. it would consider them as two different sentences.. but it is not. please help if possible with a suitable code.. | |
given a queue: queue<int> myqueue; write a function to remove the last entry in the queue. remark: you can't use stack, pointers, or linked list to do that. You can only use functions such as myqueue.pop(), myqueue.front() etc... Anyone has any ideas? | |
Right now im making a converting program for myself. I got it to convert correctly but it only converts one character so here is my code [CODE]map<string,string>datamap; datamap["A#"]="b"; datamap["C"]="DD"; string change; getline(cin,change); for(int i=0; i<change.size(); i++) { //output based on what character gets passed to the map cout << datamap[string(change.begin() … | |
Hello i have a problem with lineing up each column up correctly, the directories seems to be all messed up. Bellow is my code, a screen shot of the problem is attached to this post. [CODE=C++]if(lSwitch == true) { cout << "\nd: " << setw(15) << right << "" << … | |
Hello, A few days ago I visited a lecture of a teacher in an university that was about parallel processing. He explained why it's good etc, and how you can make programs that use multiple cpus in C. He used MPI and the code looked nice, wasn't too hard and … | |
Hi, i am trying to make a general compression algorithm in c++ but i haven't really gotten the i/o part of this right yet. What i want to do somewhere along the line is to have my program parse say 10 or so characters at a time from a binary … | |
This program is "C:\test\program.exe": [code]#include <iostream> #include <fstream> using namespace std; int main() { int choice; cout<<" Which name to embrace?\n\n"; cout<<" - 1. Fight Club\n"; cout<<" - 2. Shawshank Redemption\n"; cout<<" - 3. Italian Job\n"; cin>> choice; }[/code] There's also a .txt file there named file.txt, "C:\test\file.txt\". Inside this … | |
Hello, I'm learning to start to program in C++, and I have a problem with the prompt closing before the program ends. I know there's a lot of info about it, and I've googled it and searched here, but all the solutions to system("pause") don't work for me. I'm using … | |
Hello, I have seen many problems that inputs an unknown size of tests and i have to output the result of each test. An example is here: [QUOTE] The Input The input will consist of a series of pairs of integers i and j, one pair of integers per line. … | |
Ok i have a parent class called MobileAccount, it has a public method called void PrintAccountInfo(), and within this PrintAccountInfo() method I call a private method called void PrintAccountType(). Now as I mentioned the parent class called MobileAccount has a subclass called AdvancedAccount, it too has a method called PrintAccountInfo() … | |
Hello. I am having hard time understanding recussion in binary search tree. Assuming we have 6,4,7 in our tree the following inorder function should print 4,6,7 and I don't understand how it's done. Can somebody help explaining in more detail. Thank You. [code=cplusplus] void BinarySearchTree::print_inorder() { inorder(root); } void BinarySearchTree::inorder(tree_node* … | |
Hi Guys, this is searching coding. I needs to ;- - read data from file - DONE - bubble sort - DONE - to find the data (searching) - [B]undone.[/B] can anyone help me to find the error in my coding.. coz when i run my program, my algorithm [B]void … | |
Can anyone tell me what I am doing wrong in this code? The output window allows me to input the string, but does not output whether or not it is a palindrom. There are no build errors Thanks in advance! Lauren [code] #include <iostream> #include <deque> #include <string> #include <cctype> … | |
Ok I need some fast help with this, I'm trying to get a regular expression to work with my file system. this is what i currently have, but it seem to crash on, boost::regex expr(regex); [code=c++]void show_files (const path & directory, bool recurse_into_subdirs, bool lSwitch, bool rSwitch, bool aSwitch, string … | |
Hi, Just a quick simple question, I have done some googleing and have been unable to find a conclusive answer, But is it possible to use the XAudio2 API (DirectX) to capture sound as well as play sound? I am planning a project where I need to play and capture … | |
Nucleon was nice enough to provide me with the following code to help learn lists a while back. I've had a little more time to revisit lists again and would like to see what this code looks like using a linked list instead of an array.. This is NOT homework, … | |
Well i just want to find out , that is there any way where we can find out the various functions and operators / keywords present in a particular header file ....? | |
Does anyone have a c++ program for a high-low card game?? | |
hullo am sory but i have some thing trigaring my mind can you please help me out find the solution for this 1write a function 2write aprogram "to readstudent's name ,examinationscore for 4 subjects ,compute their average score" please help me out with that using c++ thanks AMIRSHAMI | |
I've created a program that will parse the log file generated by an MFP (Multi-Functional Printer). The program works fine when I parse a log file with less than 2000 lines, but when it reached more than 2000 lines (I've tried the log files with 8000 and 22000 lines), the … | |
Hey guys, this function is for rounding 2 decimal places, e.g. 1.2785 rounds to 1.2800. First, how would I alter the function so it would round 3 decimal places 1.2780, and second how would I truncate it so it would read 1.278. Thanks! [CODE]double roundIt(double x, double n) //Write definition … | |
[B]iSel = ListView_GetSelectionMark(g_hwndLV);[/B] //used to get cursor selection from list view &then we write it to file //i hav problems moving the slection to next item .currently am using follg code: index=ListView_GetNextItem(g_hwndLV,-1,LVNI_BELOW); iSel=ListView_SetSelectionMark(g_hwndLV,index); //and then i write code to write next selected entry into file .code compiles.but doesnt work as … | |
Everybody hi! Last few days i was interested in one question: Does wxWidgets working well in KDE? Windows? [I]I know[/I], that i can read official wxWidgets site for posted issues, but actually i want to know your opinion about it! I looking for good UI for my apps, and i … |
The End.