C :: Simple Search - Any Single Numbers In Array

Jul 13, 2013

I wrote a code which checks if there are any single numbers in an array.e.g.In the next array there is a single number - "3" 4 1 4 3 4 1..Here is an array which doesn't have single numbers in it: 4 1 4 3 3 1

Code:
#include <iostream>
using namespace std;
int single (int arr[], int size)
{
int couple=0;

[Code]....

First I thought to double the number of couples I'll get from my search and find some connection to the length of the array, but it hasn't worked out (signed red).

View 9 Replies


ADVERTISEMENT

C++ :: Search User Input Number In Array Filled With Random Numbers

Nov 6, 2014

I need to create A program That makes a 12x10 Array Grid Filled With Random Numbers From 0-99.

Then I need To Allow The User To Input A Number Between 0-99 And Then The program will then search through the array and count how many of the users number there is inside the array.

Code:

#include <iostream>
using namespace std;
int main() {
int input;
int number;
int row=0;
int col=0;
int Array [12][10];

[Code] ....

View 1 Replies View Related

C/C++ :: Search Simple Window Library For OpenGL

Sep 7, 2014

I search for a really simple window library with a OpenGL context. I really only want to create window, I don't want a GUI library like wxWidgets. The best would be, if the library is cross platform compatible. In Google I only find very big libraries with widgets and other stuff.

View 4 Replies View Related

C++ :: Simple Dictionary Search - No Contents Found

Feb 8, 2013

There is no content when i search word in the dictionary.txt....this is my example of dictionary.txt...in the add case it is working,,only in search case...

--------------
dictionary.txt content.
--------------
mwet-asd.
test-test.
apple-prutas.
beryy-berry.
house-house.
--------------

#include <iostream>
#include <fstream>
#include <string>
#include <conio.h>
using namespace std;
int counter=0;
char op;

[Code] .....

View 1 Replies View Related

C :: Simplifying A Simple Linked List With Search Function

Jun 5, 2013

Code:
#include <stdlib.h>
#include <string.h>
#include <stdio.h>

struct node
{
int data;
struct node *next;

[Code] ....

It fills the singly-linked list with 0 through 9 and calls a function to prompt the user to search for a number. I don't see any glaring errors, I was just wondering what could be done to simplify it or if there's anything I missed.

View 8 Replies View Related

C++ :: Print Numbers At Random From A Set Using Single Statement

Jan 21, 2012

I have an exercise that asks me to print numbers at random from the following set (using only a single statement):

2, 4, 6, 8, 10

Here's my statement:

Code:
cout << (2 + rand() % 9) << " ";

which prints numbers at random between 2 and 10, now I can use the modulus operator in an if...else statement to print only even numbers but the exercise specifically requires using only one statement, can that be done using the conditional operator? and if not then how?

View 10 Replies View Related

C++ :: Binary Search Or Linear Search For 3D Array

Oct 7, 2014

inputting a search array. I tried putting a binary search but I can't get it to work. everything else works up until I put the value I am searching for in the array, then it just crashes.

How it suppose to work: input 2 coordinates with a value each then it calculates the distance between them then it suppose to let user search the coordinates for a value and state if found which coordinate it is at.

#include "stdafx.h"
#include <iostream>
#include <iomanip> //for setprecision
#include <math.h>

[Code].....

View 3 Replies View Related

C++ :: Simple Way To Hold Numbers With Lot Of Decimals

Apr 8, 2013

I have a task to hold a number like 4.0000000000000000199e+30 and, in a variable like long double (the largest of the data type) doesn't hold the whole number, holds only 4.099e+30, like that.

Any way to hold the whole number?

View 1 Replies View Related

C++ :: Simple Input / Output - Float Point Numbers

Apr 26, 2012

I have a simple input output problem using float point numbers and after the first input the program skips the other cin functions is there something that I did wrong? It compiles fine also.

Code:
#include <iostream>
#include <float.h>
using namespace std;
int main() {
int x;
int y;
int z;

[Code] .....

View 5 Replies View Related

C++ :: Multidimensional Array - Moving Whole Int Array Row As A Single Unit?

Feb 27, 2013

I have a multidimensional array that runs parallel with a string array

Lincoln 120 300 400
Parks 100 500 250
Shakespeare 0 30 50
Ghandi 250 100 40
Ashe 300 50 175
Rodriguez 87 118 320
Curie 284 0 112

I need to sort this and I know how to do it. But I need to sort it again with the highest value in the first row and keep all information in that row paired with the name . So

Lincoln 120 300 400
Parks 100 500 250

Parks 100 500 250
Lincoln 120 300 400

I need so swap this whole rows. I'm using dynamic array. So my question is Do I have to do a bunch of temps to move them? Or is there a way to move the whole int array row as a single unit?

View 3 Replies View Related

C++ :: How To Manipulate A Whole Array As A Single Integer

Mar 22, 2014

here i have an assignment, creating a longInt class and using it to calculate large numbers, i dont have a clue how to manipulate a whole array as a single ineteger.

View 7 Replies View Related

C++ :: Display Numbers In Binary Search Tree - Getting 0s

Jan 31, 2015

I want to display the numbers in a bst but all I get are 0s, what is wrong with my code that is causing this?

#include <iostream>
using namespace std;
class binarySearchTree {
private:
class TreeNode {
friend class binarySearchTree;
int value;

[Code] ....

View 1 Replies View Related

C++ :: Reading Two Words Into Single Char Array From Text File

Sep 15, 2014

I am trying to read in player names (ex: first last) from a text file into the people[].name data struct. I can successfully read in my card file, but I cannot get this to work. I get a seg fault. I believe this is because nothing is actually being read in for my while loops. I can't use std::strings so these must be c-style strings aka char arrays.

// deck of cards
// below are initializations
#include <iostream>
#include <fstream>
#include <ctime>
#include <stdlib.h>
#include <string>

using namespace std;
//globals
const int maxCards = 52;

[Code] .....

View 1 Replies View Related

C++ :: Compare Element Of Char Array And String With Single Character

Dec 3, 2014

how can i compare an element of the char array and string with single chsracter also how to compare char array to cpp string

View 3 Replies View Related

C++ :: How To Convert Large Valuge Form Single Integer To Array

Jun 3, 2013

i have mathematic operation and the result is near 70 digits....single variable cannot hold it....

View 4 Replies View Related

C# :: Histogram - Identify Integer In Array And Insert Symbol For Every Single One

Apr 18, 2015

I am supposed to make a histogram. I succeeded in generating the integers for the histogram. But what I want to do is instead of displaying numbers in the console, I want something like "*" displayed for every integer there is in an array. It should look something like this.

*
****
*****
********
**********
******
****
***
*

As far as I understand, in some way I need to identify the integer in the array and for every single one of them I need to insert the symbol. I don't know how to identify it.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1{
class Program {
static void Main(string[] args) {
diceHistogram();

[Code] .....

View 2 Replies View Related

C++ :: Convert Binary Search With Int Array To Use String Array

May 8, 2014

I'm having trouble converting this binary search with an int array to use a string array..

Code:

#include <iostream>
#include <string>
using namespace std;
// Function prototype
int binarySearch(string [], int);

[Code] .....

View 3 Replies View Related

C++ :: Simple Array With Access Violation Errors

Oct 17, 2014

I have a rather large project which uses a float array for OpenGL but I believe I am reproducing the problem with a simple example below.Essentially I am getting access violation and HEAP CORRUPTION errors when I execute the code below.

#include <iostream>
#include <string>
#include <sstream>
int main(int argc, char** argv) {
std::cout << "Please enter in the size of the array you would like to create:

[code].....

View 2 Replies View Related

C/C++ :: Binomial Expansion - Simple Math String Into Array

May 5, 2014

My project is binomial expansion. I want to allow for basic string input. Then, I must process the string for input into the other portions of my program. To make the binomial expansion calculation simpler I am using two separate arrays for the first and second term of the binomial expansion. The integer array structure for each term is [{numerical Coefficient of term}, {exponent of variable a}, {exponent of variable b}, {exponent of variable c}, ......{exponent of variable x}, {exponent of variable y}, exponent of variable z}].

So, if the user doesn't use a variable it's exponent's value will = 0. The reason why I set my array up like this is so it would be very simple to raise each term to the power of n, or (n-k) (Multiple variable exponents by number, raise #coefficient to the power). It would also be easy to combine the terms to get one term. terms[0] are multiplied, all other terms are added.

My issue is translating a basic mathematical string consisting of only Integers, letter, parenthesis, and '^', into the array. I find difficulty mainly due to the '^' symbol. I know how to find the array index for a given letter. termArrayIndex = (int)((char from string) - 'a' + 1)

the main things causing me issues

-The issue is knowing which numbers to multiply by the array.

E.g. (_(_____)^#(__^#__)^#____)^#

I started by finding the first ')', then finding the preceding '(' and processing that string. I would then remove said string and use recusrion to go through the whole string. This method doesn't work because there is data loss upon removal of processed string. EG (__(__)^#) =remove innermost string and parenthesis=> (__^#) != (__()^2,

-maybe enter all terms, leave parenthesis, then process exponents separately...

-I may be able to find the # of separate terms by seeing # of times a '(' comes after a ')'

This is by far the most difficult part of the problem for me. But that also makes it the most fun. I want it to be able to handle all variation of these basic mathematical expressions.

View 3 Replies View Related

C :: How To Edit Printed Array Board For Simple Candy Crush Game

Oct 24, 2013

I am required to create a simple candy crush game.

I am this stage where I am required to print the 'box' for navigation purpose at the center of the board once the program initializes.

Here is the code:

Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
//FUNCTION: Draw the Board

[Code].....

I understand that the sequence could be to clear the screen and print the whole board with the indicated marker.

*Yes I am required to move the box in later part of the program but for now, I just need to get the box to show up at coordinate

Code: board[5][5]

I am stuck ...

View 11 Replies View Related

C++ :: How To Search For An Item In The Array

Jun 29, 2014

If the item is in the array. Count how many times it is stored in the array and what are their respective array locations.

How can I add this output in my program.

Here's my code...

int array[15]={28,3,16,4,3,16,5,8,4,12,5,4,8,21,40};
int x=0;
int done=0;
int item;

cout<<"Input an item to be searched:";
cin>>item;

[Code] ....

This should be the output:

Item to be searched: 4
number of occurence : 3
array locations : 3 8 11

View 3 Replies View Related

C++ :: Concatenate Two Char Arrays Into Single Char Array?

Sep 29, 2014

I am trying to concatenate two words from a file together. ex: "joe" "bob" into "joe bob". I have provided my function(s) below. I am somehow obtaining the terminal readout below. I have initialized my memory (I have to use dynamic, dont suggest fixing that). I have set up my char arrays (I HAVE TO USE CHAR ARRAYS (c-style string) DONT SUGGEST STRINGS) I know this is a weird way to do this, but it is academic. I am currently stuck. My file will read in to my tempfName and templName and will concatenate correctly into my tempName, but I am unable to correctly get into my (*playerPtr).name.

/* this is my terminal readout
joe bob
<- nothing is put into (*playerPtr).name, why not?
joe bob joe bob
seg fault*/
/****************************************************************/
//This is here to show my struct/playerInit

[Code]....

View 2 Replies View Related

C++ :: Find Prime Numbers Between Given Pair Of Numbers And Store Them Into Array?

Apr 18, 2014

Find all the prime numbers between a given pair of numbers. Numbers should be read in from an input file called "numbers.txt" and find all the prime numbers between them. Store the prime numbers in an array, then sort the array from greatest to least. Display the array before and after the sort.

I'm stuck on how to put the prime numbers into an array.

The input file has the numbers 1 & 100.

Here's what I have so far.

#include <iostream>
#include <fstream>
using namespace std;
int main() {
ifstream fin;
fin.open("numbers.txt");

[Code] .....

View 1 Replies View Related

C/C++ :: Making Binary Search In Array?

Jul 15, 2014

i was trying to make a program that will asks the user for 10 numbers.then asks the user to enter integer search key.next,the program should find the value in element.i used linear search.my code is like this:

#include <iostream.h>
#include <conio.h>
int linearsearch(const int [], int, int);

[Code]...

how should i make a program that will uses binary search instead of linear search?

View 4 Replies View Related

C++ :: Search And Find The Shortest Queue And Search After Some Condition?

Mar 7, 2013

I am trying to implement a Task scheduler where i have n number of tasks. The Idea behind my task scheduler is that in a loop of queues of a vector, task should get enqueued to the shortest queue among the loop of queues, which is done by the following code.

#include <vector>
#include <queue>
std::vector<std::queue<int> > q
int min_index = 0;
task t // implemented in the other part of the program

[Code] ....

Next i am trying to extend this paradigm to reduce the overhead time of the scheduler, Instead of searching the shortest queue every time, search after some condition ie. search the shortest queue after 5 tasks gets enqueued to the shortest queue.

i need to do something like this

#include <vector>
#include <queue>
std::vector<std::queue<int> > q
task t // implemented in the other part of the program
while(q[min_index].size()!=q[min_index].size()+5) // check whether current min_index queue's size is increased 5 more times if not goto enqueue

[code].....

View 1 Replies View Related

C :: Find Duplicate Numbers And Numbers Found Once In Array

Dec 7, 2013

Question: How to find a duplicate numbers and numbers found once in array.

View 7 Replies View Related







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