C :: Simulate Process Of Placing CDs In CD Container Using QUEUE

Sep 16, 2014

I'm in need of the C program which will simulate the process of placing and removing CD's in CD container using QUEUE.

View 4 Replies


ADVERTISEMENT

C :: Program To Simulate Taxi Rank Implemented As Queue Via Array - Linked List

Mar 26, 2013

I have an assignment where i am required to code up in C, a program to simulate a taxi rank that is implemented as a queue via an array that can hold up to a maximum of six taxis.When a taxi arrives, it joins the rear of the queue. When a taxi departs, the first taxi in the rank is used and its departure is logged.A "rolling menu" comprising integer codes as specified below is used until 0 is entered to exit the simulation. I've done this stage but now the next stage is asking me to implement the queue as a linked list. what the difference is between an array and a linked list and what is a linked list?

View 2 Replies View Related

C++ :: Increase Sizes Of Queue In A Vector Of Queues And Find Shortest Queue

Feb 20, 2013

I have a paradigm in a loop of queues of a vector,if a condition is true,increase sizes of the queue of that particular queue in the loop of queues, if condition is false, the queuesize is left as such in loop of queues. After this operation i need to search the queue sizes of all queues and enqueue in the shortest queue.

I want to do something like the code given below

#include <vector>
#include <queue>
int min_index = 0;
std::vector<std::queue<int> > q
std::size_t size = q.size();

[Code] ....

How to implement this logic?

will q[i].size=q[i].size+5 increase the queuesize by 5 for the ith queue?

View 12 Replies View Related

C/C++ :: Placing Numbers In Random Positions In Matrix?

Oct 30, 2014

i have a problem with a bit of code (part of an as-yet incomplete program that creates a sort of maze with 10 roadblocks, and then finds the shortest route to the exit.

I don't know what it means, to put tags around my code, but I shall try to point out the problem bit clearly. It is not a long segment. This part is all working fine and printing the messages the user needs to see initially:

#include <stdio.h>
#include <stdlib.h>
int main() {
printf("The number -1 shall represent the position of the robot in the matrix.
"
"The number 99 shall represent the position of the exit.
"
"The number 100 shall represent all blocks.
"
"All other numbers represent the number of moves required to reach the occupied space from the robot's position.
");

Below is where is goes bad, and I really am not sure why. The program says it has stopped responding and gets grayed out, and then I get the error message, "An access violation (Segmentation fault) raised in your program.

I have tried using the debugger, and it only tells me it found 0 errors and 0 warnings.

srand(time(NULL));
int initialmatrix [8] [8];
initialmatrix [0] [7] = 99;
int numberofblocks=0;
int randomrow;

[code]....

View 5 Replies View Related

C/C++ :: Placing Struct Of Object In Header And Source File?

Jul 19, 2014

Let's say I am using a library containing classes called class1 and class2 but both classes take three arguments to construct them. eg. class1(int a, int b, int c). and the same for class2

The below is an example of how to lay out the structure in the header and source file if class1 and class2 don't have any arguments in their constructor. But.... I'm not sure how to go about the below to take into account the constructor arguments of class1 and class2.

program.h
struct thestructure
{
thestructure(class1, class2); //constructor.

[Code].....

View 5 Replies View Related

C Sharp :: Placing Search Button And Finding For A Particular Row In Datagridview

Nov 8, 2012

private void btnok_Click(object sender, EventArgs e)
        {
            DataView dv = new DataView(ds.Tables["Employee"]);
            dv.RowFilter = "empno=" + txtempno.Text;
            dataGridView2.DataSource = dv;

View 1 Replies View Related

Visual C++ :: Placing Image In Kinect Color Frame?

Dec 10, 2012

I m trying to place an image on the colour frame of the Kinect live video. I m able to overlay the image using alpha blending mechanism.

The image used is a bitmap image of dimension 128*128.

The Kinect has a resolution of 640*480.

IDE used is Visual studio 2010 and I m developing using c++.

The Kinect has a render target whose size is taken as 640*480 so that it stretches for the complete window. So when I try to overlay the image it appears 5 times because of this stretching.
If I increase the image size to 640*128 i get a single image that is stretched horizontally across the window with dimension 640*480.

I have created a function that will create a render target with bitmap properties and size equal to 640*480. This is used to store the data from the Kinect, frame by frame, and draw it on to the screen

So I think when I overlay the image, it gets replicated 5 times to meet the render target size.By default the image is placed at the left top position.

My doubts are

- How can I use different functions to specify the size of render target for Kinect as 640*480 and the size of render target for bitmap image as 128*128.

- How to I give overlay or place the image on the live video at a specific location.

View 2 Replies View Related

C++ ::  assignment Is Recursive Call And Placing Strings In Linked List Notes

Oct 24, 2013

You need to write a permute class that will take first and second strings to rearrange letters in first, followed by second. For example, if the first is “CAT” string and second is “MAN” string, then the program would print the strings TACMAN, ATCMAN, CTAMAN, TCAMAN, ACTMAN, and CATMAN. The first and second strings can be any length of string or a null.

The permute class uses a Note class as link list note to link all letters arrangement. The permute class has Note pointers, firstNote and lastNote, to point to the beginning and ending Notes of the link list as private data members. There are three other private data members (total, firstString and secondString) to store the total possible number of arrangements and strings pass into the class.

Write a driver to test the permute class to pass in any two strings of any sizes.

Other than mention in the following, you can add more classes, functions, and private data members to this program.

Note class

The Note class needs to have two private data members and a constructor. The two private data members are data and p pointer. The data’s data type is string and p pointer is Note. The Note class constructor has two parameters, one is string and the other is Note pointer.

Permute class

The Permute class has five private data members (*firstNote, *lastNote, total, firstString and secondString). The firstNote and lastNote pointers are point to Note. The total has integer data type. The firstString and secondString have string data type.

There should have at least three public member functions, Permute, permutation and print. The Permute function is the constructor which takes strings to initialize the private data members. The permutation function does the recursive call to arrange the strings and setup the link list. The print function will print out the private data member information.

Driver file

The driver file should declare a Permute eight elements pointer array. Instantiate eight Permute object with the following eight set of data and assign the object to the pointer array. Use a repetition to call the object’s print function to print out the private data member information. If the total of the permute private data member is less than 100 then print out the permutated letters four in a row, otherwise print out 9 in a row.

first = "", second="",
first = "", second ="CATMAN",
first = "C", second ="ATMAN",
first = "CA", second ="TMAN",
first = "CAT", second ="MAN",
first = "CATM", second ="AN",
first = "CATMA", second ="N",
first 1 = "CATMAN", second ="";

View 19 Replies View Related

Visual C++ :: Assignment Is Recursive Call And Placing Strings In Link List Notes?

Oct 30, 2013

You need to write a permute class that will take first and second strings to rearrange letters in first, followed by second. For example, if the first is “CAT” string and second is “MAN” string, then the program would print the strings TACMAN, ATCMAN, CTAMAN, TCAMAN, ACTMAN, and CATMAN. The first and second strings can be any length of string or a null.

The permute class uses a Note class as link list note to link all letters arrangement. The permute class has Note pointers, firstNote and lastNote, to point to the beginning and ending Notes of the link list as private data members. There are three other private data members (total, firstString and secondString) to store the total possible number of arrangements and strings pass into the class.

Write a driver to test the permute class to pass in any two strings of any sizes.

Other than mention in the following, you can add more classes, functions, and private data members to this program.

Note class:The Note class needs to have two private data members and a constructor. The two private data members are data and p pointer. The data’s data type is string and p pointer is Note. The Note class constructor has two parameters, one is string and the other is Note pointer.

Permute class:The Permute class has five private data members (*firstNote, *lastNote, total, firstString and secondString). The firstNote and lastNote pointers are point to Note. The total has integer data type. The firstString and secondString have string data type.

There should have at least three public member functions, Permute, permutation and print. The Permute function is the constructor which takes strings to initialize the private data members. The permutation function does the recursive call to arrange the strings and setup the link list. The print function will print out the private data member information.

Driver file:The driver file should declare a Permute eight elements pointer array. Instantiate eight Permute object with the following eight set of data and assign the object to the pointer array. Use a repetition to call the object’s print function to print out the private data member information. If the total of the permute private data member is less than 100 then print out the permutated letters four in a row, otherwise print out 9 in a row.

first = "", second="",

first = "", second ="CATMAN",

first = "C", second ="ATMAN",

first = "CA", second ="TMAN",

first = "CAT", second ="MAN",

first = "CATM", second ="AN",

first = "CATMA", second ="N",

first 1 = "CATMAN", second ="";

View 3 Replies View Related

C :: UDP Application Simulate Packet Loss

Aug 12, 2014

have udp server-client application written in C. On the client side packet loss is detected using recvfrom function and sequence numbers of packets. How can I now simulate dropped packet's on the client side, for example if server is sending 1000 packet I want to drop 20% of them? I want to do this in the code, not for example using ip tables or WANEM or something like that. And one more thing, I have few clients and I want that they can dropped different packets, not the same one.

Code:
while(1){
nbytes = recvfrom(socket, buffer, MAX_SIZE, 0, (struct sockaddr *) &srv_addr, &addrlen);
if (nbytes != -1) {
// packet is received

}else{
//packet is not received
}
}

View 2 Replies View Related

C++ :: Simulate Random Walk In 2 Dimensions

Jan 6, 2015

I am writing a piece of code that simulates a random walk in 2 dimensions (an object chooses whether to move up, down, left or right randomly). I would like the program to run the simulation for many objects at the same time. The way i have written it means that for every object i add the code becomes about 40 lines longer. Any method that would simplify the code so that i could have many objects but not pages and pages of code.

#include <ctime>
#include <cstdlib>
#include<iostream>
#include<cmath>
#include<iomanip>
#include<fstream>

using namespace std;
double dist(int a, int b);

[Code] .....

View 5 Replies View Related

C++ :: Program To Simulate Coin Toss

Nov 14, 2013

Write a program that simulates coin tossing. For each toss of the coin, the program should print Heads or Tails. Let the program toss the coin 100 times and count the number of times each side of the coin appears. Print the results. The program should call a separate function flip that takes no arguments and returns 0 for tails and 1 for heads. [Note: If the program realistically simulates the coin tossing, then each side of the coin should appear approximately half the time.]

View 7 Replies View Related

C++ :: How To Simulate File Space Allocation

Mar 29, 2014

I want to write a c++ code that due the structure of file space allocation,Simulates file system with 2*n array. Each column represents a sector. The first row is for storing files And second row holds the address of the next sector (Number of columns). And With each click on keyboard Create a file with random size and automatically find Appropriate sectors by using disk allocation method (or index allocation)... Also File names should be asked from user... And we should have file table Where the starting address of each sector,file extension and file size is given..

View 1 Replies View Related

C++ :: Implementing Class To Simulate A Disk

Oct 1, 2013

So this code compiles without any problem but it is not producing the correct output. I know there's a problem in either my getBlock or putBlock functions but I can't see it.

Currently the output is "Should be 32 1s: "
"Should be 32 2s: "

There should be 32 1s and 32 2s and nothing is coming out.

#include <iostream>
#include <fstream>
using namespace std;
class Sdisk {
public :
Sdisk(string diskname);

[Code] .....

View 3 Replies View Related

C++ :: Get Live Data To Simulate Algorithm?

Apr 9, 2014

How to get live streaming of stock data from yahoo finance? Using C++. I need the code and fetch the data so I can do calculations on the price and volume or what not.

View 1 Replies View Related

C/C++ :: Can Use Packed Structure To Simulate Memory?

Oct 11, 2013

I am trying to simulate memory in C. I want to create a structure in C that will hold a 8bit opcode and a 32bit memory address. This would simulate a 40 bit instruction for my simulator.

I read in an old book that packed structs could be used for this to not waste space. What are the draw backs for using this? I am not worried about wasting space, but just looking for a simple way to access the memory instructions. Below is a sample of the structure that I want to use.

struct memory_area {
unsigned int opcode:8;
unsigned int address:32;
};

View 2 Replies View Related

C :: Simulate Roll Of A Dice - How To Use Rand Function

Sep 23, 2014

I saw a program in which it uses rand like this:-

d1=rand() % 6+ 1;

where, d1 is any integer. The program is to simulate the roll of a dice. The whole program is this:-

Code:

#include<stdio.h>
#include<stdlib.h>
main() {
int i;
int d1, d2;
int a[13];

[Code] .....

View 10 Replies View Related

C++ ::  random Number Generator To Simulate A Critical Hit

Oct 25, 2013

I am trying to make a random number generator to simulate a critical hit if the number generated is from 0-critical amount. However, every time i run the code, despite being within the parameters set by the if statements, it always runs through as a critical hit and never a regular hit.

#include <iostream>
#include <iomanip>
#include <ctime>
#include <cstdlib>
using namespace std;
int main(){
srand((unsigned)time(0));

[Code]...

There are four attempts to save time in getting a good result.

View 6 Replies View Related

C++ :: Simulate Adding Machine - Total / Subtotal

Mar 28, 2013

Write a program that simulates an adding machine. When a zero is entered it should print the subtotal of all the numbers entered from the last zero that was entered and reset the subtotal. When two consecutive zeroes are entered it should print the total (not the subtotal) of all the numbers entered and terminate the program. Example:

1
2
3
0
subtotal 6
4
5
-2
0
subtotal 7
8
0
subtotal 8
0
total 21

Be careful this program needs a bit more thought than you might think at first. To get full credit you must make sure it also works for the 0 - 0 case. Example:

0
subtotal 0
0
total 0

The problem is, after I enter the integers and type 0, it shows the subtotal which is what I want; however, when I type more integers and type another 0 to see the subtotal again, it shows the total instead. The subtotal should reset whenever a single 0 is typed and the total should only show when two 0's are inputted simultaneously. Also, after the user enters two 0's simultaneously and views their total, I want the program to exit by saying "press any key to exit." Is there a special name for that to happen? Here is my code:

#include "stdafx.h"
#include <iostream>
using namespace std;
int main() {
int subtotal = 0, total = 0, number = 0;
bool input_zero = false;

[Code] ....

View 2 Replies View Related

C++ :: Simulate Random Walk That Starts With Position 0

Mar 19, 2014

I am supposed to create a program that simulates a random walk that starts with position 0. If its odd it moves to the right (add one) if the random number is even it moves to the left (subtract 1).

#include<iostream>
#include<iomanip>
using namespace std;
void main() {
int num1, num2, num3, num4, i, rs = 12345 ;
cout << " Please enter the number iterations to be executed: ";

[Code] ....

I'm getting an error when I try to run the program: error C2106: '=' : left operand must be l-value. So I don't even know if what I have is right.

View 19 Replies View Related

C/C++ :: Linked List To Simulate Text Editor

Mar 10, 2015

I am trying to make a text editor in C++ that uses Linked Lists as the main driving force. I need to make a program that can add a line of text at a certain point, delete a certain line of text, print the entire text, and quit and save the text to the original text file inputted from the shell script. My problems are with the cpp file, and the linked list files. My remove function is not what I need it to be I know that. I also know that there are some problems with my cpp file myEditor. My code is below.

#include <sstream>
#include "linkylist.h"
#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>
using namespace std;
int main(int argc, char *argv[]) {
//node* head = new node;

[Code] ....

View 6 Replies View Related

C Sharp :: Simulate (automatic) Mouse Right Click

Aug 22, 2013

How to simulate(automatic) mouse right click operation using c#?

View 2 Replies View Related

C++ :: Program To Simulate Customers Lining Up To Buy Tickets For Some Event

Oct 17, 2013

Create a line class using a linked list that acts as a queue (first in, first out) both enqueue and dequeue. Complete the line class so that customers can be added or removed from the line. Implement the line as a linked list of customer objects that you have developed yourself or use the vector class.

View 2 Replies View Related

C++ :: Pointer Arrays - Program To Simulate Squares Most Landed On

Jun 8, 2014

I have not been using pointers that long i most of my stuff has not needed them but now they do i need to learn how to use them more. I'm writing a program that simulates the squares most landed on(for fun) and i cant get a method to work because of an array pointer.

The error is no matching function for call to 'GameLoop::Loop(int, int (*)[4])'

Here is the latest version of the code. I've been editing a lot of things so there might be some stupid errors but I've tring everything.

rolling.h and rolling.cpp are just some dice function they are working perfect.

main.cpp

#include <iostream>
#include "Rolling.h"
#include "GameLoop.h"
Rolling Roll;
GameLoop Game;

[Code] ....

View 2 Replies View Related

C++ :: Write A Program To Simulate Deck Of 52 Playing Cards

Oct 22, 2014

Write a program to simulate a deck of 52 playing cards.

Represent your deck as a 2D Array where the value in the cell is the position of the card in the deck. Represent the names for the suits and faces as an array of Strings.

Write an algorithm to shuffle the deck.

Display the deck. For Example:

1 Jack of Spades
2 Deuce of Diamonds
3 Three of Diamonds
4 King of Spades
5 Eight of Clubs
6 King of Diamonds
7 Six of Clubs
8 Six of Spades
9 Eight of Hearts

Deal two hands of five cards each. For Example:

****** HAND 1 ******
Jack of Spades
Three of Diamonds
Eight of Clubs
Six of Clubs
Eight of Hearts
...

Below is what I have so far. Dealing two hands and displaying it. How would I be able to do that?

#include <iostream>
#include <ctime>
#include <string>
using namespace std;
void shuffle(int[][2]);
int main()
{
int j,deck[52][2];

[Code]...

View 2 Replies View Related

C++ :: Program And Simulate 2 Floor Lift Control System?

Apr 28, 2014

I need to program and simulate a 2 floor lift control system. How to do that ? I need to design its program only.

View 1 Replies View Related







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