C :: Display The Names In A Queue

Mar 12, 2014

I have an assignment that needs to display the names of customers to be served according to a sequence. coding to display the names accordingly?

Code:

#include <stdio.h>
#include <stdlib.h>
#define MAXIMUM 20
void create();

[Code].....

This is my output. I have trouble displaying the names of the customers as it outputs null when I try to display my position in queue.

View 4 Replies


ADVERTISEMENT

C/C++ :: Display Names In A Queue?

Mar 13, 2014

I have encountered errors when trying to display the customers' names in a priority queue.

#include <stdio.h>
#include <stdlib.h>
#define MAXIMUM 20
void create();
void priority_insert(int data);
void check(int data);

[code]....

I have gotten the following output:

Peter
Peter
<Null>

How do I correct my coding to display like below:

John
Peter

View 1 Replies View Related

C++ :: Implementation Of Circular Queue Of Array Containing Names

Jun 28, 2013

/* Implementation of a circular queue of Array containg names.. */
# include <stdio.h>
# include <conio.h>
# include <stdlib.h>
# include <string.h>
# define QSIZE 5
typedef struct{

[Code] ....

I changed my code. but whenever i typed in the ILoveBacolod it takes it as a whole, and if i deleted it deletes the string not the letter. for example:

Enter String: ILoveBacolod
Enter a command: Delete (D)
Output: LoveBacolod
Enter a command: Delete (D)
Output: oveBacolod
Enter a command: Add (A)
Enter a character: z
Output: oveBacolodz

View 2 Replies View Related

C/C++ :: Call To String Function To Display Names In Class Not Display

Apr 19, 2014

I created class called students which suppose to store students names of in array but when I call the display function it display only the first name. but I want it to display names depending on the array size.

#include <iostream>
#include <sstream>
using namespace std;
const int SIZE=5;

[Code]....

View 3 Replies View Related

C++ :: A Call To A String Names In A Class Not Display

Apr 19, 2014

I created class called students which suppose to store students names of any sizes in an arrey but when I call the display function it does not show the names.

#include <iostream>
#include <sstream>
using namespace std;
const int SIZE=5;
class students{
public:
string names[SIZE];

[Code] ......

View 1 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++ :: Delete Specified Names From A List Of Store Names?

Feb 10, 2013

i have a vector of stores. i would like to delete the specified choice(store) from the list. Here is what i have but my erase statement is wrong and wont compile.

void Store::deleteSpecifiedStoreFromList(string choice) {
for (int i = 0; i < this->stores.size(); i++) {
if(this->stores[i].getStoreNames() == choice) {
this->stores.erase( std::remove_if( this->stores.begin(), this->stores.end(), choice ), this->stores.end() );
}
}
}

View 4 Replies View Related

C :: Binary To Decimal Conversion Through A Port To Display On LCD Display

Dec 6, 2013

I know this is more simple than I am making it out to be. I have a solar panel hooked up to an 8-Bit ADC and linked into my Microprocessor. I am trying to take the Binary readout from the ADC and convert it to a decimal number to be displayed on the boards LCD display. I am wiring the ADC to PORTA on my Motorola Freescale Board. This is for a final project for my electronic systems class due on Monday...

View 3 Replies View Related

C/C++ :: Priority Queue Without STL

Nov 28, 2014

How to build a FiFO queue without using the STL (done that no problem), get it to dequeue (again, done that no problem). However, to get those extra marks, I need to be able to order it using a priority system.

I've tried ordering the NodeDequeue class that I'll show at the bottom of this post, but I just cannot get it to order appropriately. The closest I have got is everything in order but I lose a Node from the memory completely. So, that's no good.

The most logical idea I have thought of right now is to send the largest number to the back of the queue each time it's iterated, eventually, the largest number will end up at the front.

class PriorityQueue : public Queue {
public:
Node* NodeDequeue(void) {
Node* tmp = front;
Node* seek = tmp->getPrev();

[Code] .....

View 3 Replies View Related

C :: Removing Item From A Queue

Aug 17, 2014

I'm having a problem with removing an item from a queue. At first in the debugger I got SIGTRAP but I don't get it anymore but the problem still exists. When you try to remove an item from the queue the first nothing happens. Here's the code below compile it and you see what I'm talking about.

Code:

#include <stdio.h>
#include <stdlib.h>
struct Node {
char let;
struct Node *nextNode;
};

[code]....

View 12 Replies View Related

C++ :: Not Marking That The Queue Is Full

Apr 11, 2013

Why is this code not marking that the queue is full.. I'm just including my Add function that verifies if they want to add another number to the queue. The isFull function works fine, have used it on other programs.

template <class T> //Template currSize function
int Queue<T> :: currSize ()
{
return (rear - front + arraylength) % arraylength; //

[Code].....

The output goes all the way down to 1 spot left, lets the user enter the last element. Then it asks if they want to add another.. At this point, when they hit Y, it lets them add it and it says there are 5 spots left!

View 8 Replies View Related

C++ :: Decrease Key In STL Priority Queue

Jan 19, 2013

I'm trying to implement Prim's Algorithm and for that I need to have a decreaseKey method for a priority queue (to update the key value in a priority queue). Can I implement this in the STL Priority Queue?

This is the algorithm I'm following:

for each vertex u in graph G
set key of u to INFINITY
set parent of u to NIL
set key of source vertex to 0
en-queue to priority queue Q all vertices in graph

[Code] .....

View 1 Replies View Related

C++ :: How To Resort Priority Queue

Nov 4, 2013

I've got a priority queue of items who, from time to time, returns a different comparison result. Any way to re-sort a priority queue who is storing them?

Example:

#include <cstdlib>
struct Random {
bool operator<(const Random&) const { return !(rand()&1); } };

View 10 Replies View Related

C++ :: Passing Object By To Queue

Dec 4, 2013

I've been working on a little project and hit a snag. I'm using nodes for a queue and stack class that were created using an existing list node class. I create an object for a student class and I want to enqueue that object.

int main() {
Queue sLine;
Customer stu;
Queue<Student &>
cLine.enqueue(cust);
}

That's basically the coding of it in main. However when I follow the error which says uninitialized reference member ListNode<Student& info>::data;

#ifndef LISTND_H
#define LISTND_H
template< class T > class List;
template< class NODETYPE >
class ListNode {
friend class List< NODETYPE >;

[Code] .....

What I may have been doing wrong? Trying to work within certain contexts.

View 2 Replies View Related

C++ :: Creating STL Queue Of Arrays?

Dec 3, 2013

Is there any possible way to create an STL queue of arrays? I tried

queue<int[]>q;

It didn't work?

View 2 Replies View Related

C++ :: Empty State Of Queue?

Feb 18, 2013

what is the empty state of queue?

View 5 Replies View Related

C++ :: How To Start A Printer Queue

Nov 30, 2014

Write a program to simulate a printer queue (priority queue or heap – Bentley article has code) where 3 printers are “fed” by this queue. Each print job has an unchanging priority and higher priority jobs go first (although once started, a job isn't stopped to let a higher one go). For each unit of time, there is a 26% probability that a job will be added to the queue and all jobs take 8 time units to complete. Print job priorities are between 5 and 100. The queue opens 20 time units prior to the start of printing for adding print “jobs”. A print “day” is 1000 time units. The output from your program is:

1) A list of jobs completed with their priorities for each printer

2) A list of jobs not completed (if any).

#include <iostream>
#include <cstdio>
#include <cstring>

[Code].....

View 1 Replies View Related

C++ :: 2 Queue With Linked List?

Dec 6, 2014

while the prog. running compiler say " access violation .. "

this my code ...

solved :just forget to make r=NULL ; rf =NUll ; frontm=NUll; frontf=NULL ;

#include <iostream>
#include<conio>
struct stu{
int id;
float gba ;
char gender ;
stu *next ;
}*r ,*rf ;
stu read()

[code]....

View 2 Replies View Related

C/C++ :: How To Include Whitespace In Queue

Feb 21, 2014

my code is already finished. im using parallel queues and im having problem in the queue customer name if i dont input space the code is fine but if i input space in the name it skips the bagcode and immediately jump to the number of bags what can i do to include the white spaces in the customer name and push it to the queue?

here's my code

#include <iostream>
#include <string>
#include <queue>
#include<conio.h>
using namespace std;
int main() {
queue<string> customer;

[code].....

View 3 Replies View Related

C/C++ :: Email Simulation Using Queue?

Feb 1, 2015

Here is the assignment I get:

Write an email simulator that processes mail at an average of 40 messages per minute. As messages are received, they are placed in a queue.assume that the messages arrive at an average rate of 30 messages per minute.messages must arrive randomly.

Each minute, you can dequeue up to 40 messages and send them. Assume that 25% of the messages in the queue cannot be sent in any processing cycle.use a random number to determine whether a given message can be sent. If it can't be sent, enqueue it.

Run the simulation for 24 hours, At the end of the simulation, print the statistics that show:

-The total messages processed.
-The average arrival rate.
-The average number of messages sent per minute.
-The average number of messages in queue in a minute.
-The number of messages sent on the first attempt, the number sent on the second attempt, and so forth.
-The average number of times messages had to be requeued (do not include the messages sent the first time in this average)

Well, actually I've done a part of the coding. But how to continue it. And here is my code :

#include <iostream>
using namespace std;
#define SIZE 40
class Queue {
int queue[SIZE];
int head, tail;
public:
Queue();
void Enq(int num);

[code]....

View 1 Replies View Related

C/C++ :: Queue Making Using Arrays

Nov 11, 2014

I'm trying to write a code that proves a queue like fifo (first in first out). I have four characters :

p(rint),e(nqueue),d(equeue) and q(uit).

The problem is when I press d a first character must get rid of, but not. When I press d the numbers get double.

Example input:
e 2 3 9 8 7
p
2 3 9 8 7
d
p
3 9 8 7
d
p
9 8 7

#include <stdio.h>
void enqueue(int queue[], int newnum, int *tail_p, int maxsize);
void deque(int queue[], int *tail_p, int *elem);
void printqueue(int queue[],int count);

[Code] ....

View 1 Replies View Related

C/C++ :: Read And Add Multiple Queue Together

Feb 21, 2014

Program requirements: Read two Queues (Male and Female) and pair them up.

Example:

inFile
M Bob
F Mary

outFile
Bob + Mary

Here is what I have so far. Code:

////////////////////////////main.cxx//////////////////////////

#include <iostream>
#include <fstream>
#include <cstdlib>
#include <iomanip>
#include "queue.cxx"
using namespace std;
int main() {
ifstream inFile;
ofstream outFile;

[Code]....

View 4 Replies View Related

C :: Double Ended Priority Queue

Jun 19, 2013

how double ended priority queue be used to implement external quick sort?

View 8 Replies View Related

C :: Queue Program Not Running After Pressing 1

Apr 20, 2013

Code:

#include<stdio.h>
#include<process.h>
struct que

[Code].....

View 1 Replies View Related

C :: Queue Implementation - Linked List

Mar 23, 2013

I am trying to create a code to represent a queue using a linked list but i get the disturbing "Segmentation fault coredumped" after compilation.

Code:

#ifndef QUEUE_H
#define QUEUE_H
#include <stdbool.h>

typedef int Item;
typedef struct queue_type *Queue;
typedef struct node *return_node;

[Code] .....

View 2 Replies View Related

C :: Circular Queue Based On Struct

Oct 6, 2013

I am stuck with how to make a circular queue that are based on a struct. Have been reading about the implementation but cant really understand it fully. Here is what i got so far.

Code:
#define SIZE 10
typedef struct {
char reg;
char brand;
int modelyear;
int mileage;

[Code] .....

View 8 Replies View Related







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