C++ :: Determining Index To Place New Value

Dec 9, 2013

I need function to determine where to place new element in sorted array. I want to use binary search to find index where element should be placed, when push all others.

Prototype should be something like

int WhereToPlaceElement(ElementType hash); // uses private atribute ElType** elements

I have tried my best to write, but all tries ended in inf loops and reading invalid locations of array.

View 3 Replies


ADVERTISEMENT

C++ :: Determining If A Float Is Odd / Even

Oct 22, 2013

determining if a value entered in loop is an odd or even number. Also, the value can't be int because it may be a decimal value(therefore i cant use the if(x%==0).

I need to replace the if(value%2 ==0) else num_even++ statement in my code with something else that will work with float to determine odd vs even.

#include <iostream>
using namespace std;
int main() {
int num_values;
float sum_values = 0;
int num_neg_values = 0;
int num_pos_values = 0;

[code]....

View 1 Replies View Related

C++ :: Determining Even / Odd Numbers From TXT File

Dec 8, 2013

I am trying to extract the numbers from Numbers.txt, and then put them in the correct file, either Odd.txt or Even.txt, depending on what they are. And I have gotten to a point where I am not sure what to do; right now it just reads Numbers.txt and then the program ends.

#include <iostream>
#include <fstream>
#include <string>

[Code].....

View 2 Replies View Related

C++ :: Determining Size Of Array?

Oct 24, 2013

char A[]={}; this is the array in c++ of unknown size, now I want to enter some alphabets via loop and want to be the no. of elements i entered the size of the array. .

View 8 Replies View Related

C++ :: Program For Determining Maximum Deflection On Beam

Oct 7, 2014

I am new at c++ and I am trying to write a code to determine the maximum deflection at the end of a cantilevered beam. I am given the formula : deflection= (4 W L^3)/(E B H^3) where W is the load weight, L is the beams length, E is the modulus of elasticity, B is the beams base, and H is the beams height.

// Included Header Files
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <fstream>
#include <cstdlib>
#include <cstdio>

[code]....

View 2 Replies View Related

C/C++ :: Determining Length Of Array Read From File

Feb 16, 2015

i have to read a file with between 5 and 10 pairs of numbers, each on a different line. i can read the file, and wrote something to save the length of the file as a variable, but when i use it i start returning crazy data. the problem is in the do while loop and i want to change the i< in the for loop to "lines" so the code stops when the last digit is read. if i use i<10 the file has extra digits is the file is only 8 or 5 pairs of numbers.

FILE *Fpointout;
FILE *Fpointin = fopen ("test.txt","r"); //read this one
Fpointout = fopen ("out.txt","w"); //write this one
if (Fpointin == NULL) //if no file in source {
printf ("File does not exist."); //tell user it is not there

[Code] .....

View 4 Replies View Related

C/C++ :: Reading Strings From A File And Determining If They Are Palindromes

Oct 17, 2014

I have to make a program to read a file with strings and determine if they are palindromes. The problem is that the program says that they're all palindromes.

int main() {
ifstream inFile;
ofstream outFile;
inFile.open("in.data");
outFile.open("out.data");
if (!inFile || !outFile) //to display error if input files are invalid

[code]....

View 3 Replies View Related

C/C++ :: Determining Extension Type Of A File Using Binary

Oct 13, 2014

I am trying to write a function that determine if a file in a directory is of a gif/bmp/png/jpg extension. Right now I think I have correctly written my code all the way up to listing the files in the directory and opening them in binary mode.

Now, I am struggling with figuring out how to determine what extension the image is. Right now i am just focusing on writing my "bool isGif();" function... To determine if a file is a .gif extension using binary, the first 6 bytes of the file will contain either GIF87a or GIF89a.So, to do this I would read the first six bytes of the file using the function below, correct?

fin.read((char *) &a_file, 6)

Then, once I read in the first six bytes how would I conditionally compare it to determine if it is a .gif? Would I just use

if(fin == "GIF87a II GIF89a) {
\do something here
}

Because that doesn't seem to be working...

View 13 Replies View Related

C++ :: Reverse A String In Place

Jan 12, 2014

I was browsing the web looking for simple yet fun programming challenges and crossed this one. I figured out how to reverse the string in place but I want it to read "blue is house the". I approached it in two ways for the heck of it. My idea was the second one, the first one I googled. I didn't know a simple rbegin() could do that, pretty neat.

I found the question here.[URL] ....

Code:
#include <iostream>
#include <string>
int main(int argc, const char * argv[])
{
std::string phrase = "The house is blue.";

[Code] ......

View 8 Replies View Related

C++ :: Statement Not Appearing At The Right Place?

Aug 25, 2014

I have an issue with my codes as according to what I created the fitness level have to appear right after I enter the time take to 3 miles. However it only appears once after repeating five times.

My codes

#include <iostream>
#include <iomanip>
#include <string>

[Code]....

View 6 Replies View Related

C# :: Cannot Place Controls On Layout

Feb 1, 2015

When I drag a control onto the Xamarin studio layout the control just slides back into the toolbox again. The only way to add controls is to edit the .axml file which is not at all ideal.

I have tried re-installing all the components again multiple times and even tried out using a different computer, still no luck. How to use the mono framework on the Visual studio IDE and build the apk using Xamarin studios?

Details -

Xamarin studio 5.7
Tested on Windows 8, 8.1 and 7

View 10 Replies View Related

C++ :: Increment In Variable Not Taking Place

Oct 27, 2013

I have created this code; it is a taxi management system. I've made a class 'List' which handle a linked list structure of the waiting taxis and waiting passengers. The class has a public int variable: waiting, which keeps track of the number of waiting taxis/passengers.

#include<iostream>
using namespace std;
class Queue{ //Class for indivdual taxis and passengers, which will be members of linked list.
public:
string id;
Queue *next;
Queue (){

[Code] .....

But when I run the code and type in a new taxi number, the code does not increment the number of taxis by one the linked list by one. I can't seem to find the problem.

BTW, in the 'int main', I've added "<< taxi_list.waiting" at the end of the line after the user inputs the new taxi registration number, so that I can see how many taxis are now on the list. This is what is being shown as zero, no matter what.

View 2 Replies View Related

C++ :: Place Two Asterisk Triangles On Top Of Each Other But Only Using 3 For Statements

Oct 19, 2014

I have to place two asterisk triangles on top of each other BUT only using 3 for statements. I have gotten the first one:

for(int a=1;a<=10;a++) {
for(int b=1;b<=a;b++)
cout << "*";
cout << endl;
}

I need the output to look like this:
*
**
***
****
*****
******
*******
********
*********
**********
*
**
***
****
*****
******
*******
********
*********
**********

The only kicker is I can have a total of 3 nested for loop statements.

View 7 Replies View Related

C/C++ :: How To Reformat Entered String With Odd Then Even Place

Oct 15, 2014

The question I am given is this:

Given a line of words (total character number is less than 100,
start from odd position 1,
and end with newline char "
").

Write a program to reformat it that new output is formed by each char from its odd position first, then its even position char.

View 14 Replies View Related

C/C++ :: Where To Place Text File For Ifstream When Using DLL

Feb 3, 2014

I have a text file that ifstream opens and fills some fields with the data. I've been able to get at the file, by using the precise path, but that path would be incorrect on other computers I'll be working on the project at. So, is there default location I should drop the folder in, and route to with the path? If not which Directory listing in Visual Studio 2013 should I use so the project can find the folder?

This is how I've formatted the string for ifstream.

".DataSampleActorData.txt"

View 6 Replies View Related

C/C++ :: Check If A Number Has Decimal Place

May 31, 2014

I'm trying to make a program to check if a number has decimal place, for instance: 1.34(yes), 1.0(no), 3.45(yes), 5.0(no).

Code:

#include <stdio.h>
#define LENGTH 4
int main( void ) {
int i;
float a[LENGTH];
for(i=0; i < LENGTH; i++) {
scanf("%f", &a[i]);

[Code] ...

I'm getting this output, why?

Quote

error: invalid operands of types "float" and "int" to binary "operator%"

View 3 Replies View Related

C++ :: In Place Merge Sort For Linked List

Oct 3, 2014

This is in-place merge sort, for merge function.

LinkedListNode::LinkedListNode(int value) {
this->next = NULL;
this->value = value;
}
LinkedListNode *mergeSortedLinkedLists(LinkedListNode *firstList, LinkedListNode *secondList)

[Code] ....

View 3 Replies View Related

C++ :: Counter That Increments Slowly And Show It In One Place?

May 9, 2013

The best I could come up with is this.

while(true){
wisdomCnt++;
_stprintf_s(szBuffer, _T("%i"), wisdomCnt/10000);
TextOut(hdc,120,10,szBuffer, _tcslen(space));
}

but the program is constantly loading and clicking anywhere causes it to stop responding. Is there a better way to do this especially in Win32 API?

View 6 Replies View Related

C++ :: Place A Counter To Count In Each Time A New Order Comes In

Jul 31, 2013

I am trying to place a counter to count in each time a new order comes in, but I am having trouble with the memory allocation part.

I allocate memory to take in names each time an order comes through, but when I print out the names, I get 0x100103ae0....

View 13 Replies View Related

C++ :: Read From A File And Place Data Into Array

May 3, 2014

Assume you want to read from a file and place the data from the file into an array. The array can hold 10 integers. The file may contain any number of integers with 1 integer per line. Fill in the missing loop test condition so that we will read from the file until either end of file occurs or the array is full. Note we are using cin to read from the file since input redirection is being used.

cin >> temp;
arrayIndex = 0;
while ( _____________________________________) {
array[arrayIndex] = temp;
arrayIndex++;
cin >> temp;
}

View 2 Replies View Related

C/C++ :: Read Strings From File And Place Into Multidimensional Array

Mar 1, 2014

I am having problems figuring out how to place a list of strings from a text file into a multidimensional array that is something like words[NUM_WORDS][MAX_LEN]. I already run through the file once and count the number of words in it. I have tried a number of loops using fscanf and fgets, but I'm not sure if I am using them right -- this is my first time using them. The text file is a list of words in a dictionary, so the wordCount is about 45340.

Here is my code:

#include <stdio.h>
#include <string.h>
#define MAX_LEN 46
int main(){
int wordCount = 0;
FILE *inputFile, *outputFile;

[Code] ....

Like I said, the wordCount portion works. I added the printf statements at the end to see if anything was being saved, but it just prints two new blank lines. New to file reading and writing.

View 3 Replies View Related

Visual C++ :: Place Binary Array Into And Then Retrieve From Registry

Feb 12, 2013

I have used the following code to attempt to place a binary array into and then retrieve from the Registry. I am a member of the local Administrator group. I have verified that the Registry for the app has a binary array 32 bytes in length under the key "settings" / "keyb" ab 12 cd ...

Code:
// in header
unsigned char m_key[32];
int m_nKeySize;
// in implementation
// int ctor
AfxGetApp()->GetProfileBinary(_T("settings"), _T("keyb"), (LPBYTE*)&m_key, (UINT*)&m_nKeySize);
// in OnDestroy
AfxGetApp()->WriteProfileBinary(_T("settings"), _T("keyb"), (LPBYTE)&m_key, m_nKeySize );

Here is a copy of the binary array in the Registry:

7D DE 2B 30 E7 06 12 AC 99 60 8C 26 21 FC 8E 5B 66 DB 72 9E A2 00 BE 15 E1 8B 67 31 E5 EC 8B 15

Here is the binary key retrieved from the Registry using the code above:

D0 EB 26 00 CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC

View 7 Replies View Related

C++ :: Restart Program Every Time Type Move Of Blank Place?

Mar 5, 2013

I have to make a 8-puzzle and I got the algorithm i just dont know how to restart the program every time i type the move of the blank place in the 3x3 puzzle so i dont have to make 10000 lines to solve the puzzle

View 2 Replies View Related

C :: ROM BIOS Programming - Accept Row Number From User And Place Cursor To The Beginning Of That Row

Nov 27, 2013

How do I write a ROM BIOS routine which accepts a row number from the user and place the cursor to the beginning of the row number which the user gave?

View 2 Replies View Related

C++ :: Creating Infinite Sheet On Which User Can Write Notes And Place Images

Dec 31, 2012

I'm new to c++ and I want to create an infinite sheet on which a user could be able to write notes and place images. Any GUI library that I could use to do that?

View 2 Replies View Related

Visual C++ :: Letting User Enter A Character On Specific Line And Place?

Aug 8, 2014

How can I create in my C++ program so a user can paste a text and then choose a character on specific line and place?. The above thing isn't that important. I just want to place a character on a specific line and place.

I mean something like this:

Enter a character:

You choosed " / "

On which line do want the character?

You choosed "Line 1 and 2"

Where do you want the the to appear on the line? (left or right)

You choose left.

Results:

Line 1. / hello

Line 2. / hello

View 8 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved