C :: Create ASCII Bar Graph Of Die Rolls
May 24, 2013
for an assignment we need to create basically a program that asks the user for the result of standard six-sided die rolls (numbers from 1 to 6). The program will prompt the user with "Enter a die roll or 0 to exit " for the first entry and Next die roll? for all subsequent entries. The program will continue reading die rolls from the user until the user enters 0. At this point, the program prints two newline characters (one blank line) and finally, the bar chart showing the number of times each die roll has been entered, and then terminates.If the user enters an invalid number, the program will just ignore it, and ask for another number. Only numbers 1-6 inclusive and 0 are valid.
Example output Enter a die roll or 0 to exit 6 Next die roll? 6 Next die roll? 7 Next die roll? 4 Next die roll? 0
[code].....
View 3 Replies
ADVERTISEMENT
Jun 25, 2013
This program needs to display a vertical graph of asterisks showing production for each plant in the company ...
Here is what I have so far:
***********************************
This program will read data and
display a vertical graph showing
productivity for each plant.
Reference Display 7.8 pg. 401-3
***********************************
*/
#include <iostream>
[Code].....
View 1 Replies
View Related
Aug 30, 2014
I have a text file which contains ASCII of A,B and C like below,
65
66
67
Now I need to create a file which containing letters related with above ASCII like below, ABC
This is my code.
#include<iostream>
#include<fstream>
#include<string>
[Code]....
View 2 Replies
View Related
Apr 7, 2015
#include <stdio.h>
#include <cstdlib>
#include <ctime>
[Code].....
Why is it this does not print out the number?
The goal is to print 10 groups of 5 rolls per group, can't figure this out...
View 10 Replies
View Related
Feb 19, 2013
I'm having a problem adding up the values of the dice rolls in a while loop. The program will only store the last value so how would I get it to store multiples values? Here is my program thus far. I would try an array but we haven't gotten to that yet.
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main() {
int die_1=0, die_2=0, total_score1, total_score2, player1score;
char enter;
[Code] ....
What operators or equation I should use to accomplish this?
View 7 Replies
View Related
Feb 7, 2013
My issue is that my program dies whenever it attempts to readout the average and sum of the rolls. I think I need to include the size function in here somewhere but am not sure how to go about it. Possibly scrap the "do while" loop and go with something else, or just am completely missing something.
Here's the code:
#include<iostream>
#include<random>
#include<ctime>
#include<vector>
#include<cstdlib>
#include<iomanip>
using namespace std;
int sum5(int d1, int d2, int d3, int d4, int d5);
int DiceRoll();
[Code] ....
View 3 Replies
View Related
Feb 20, 2015
I have a program that rolls two dice however many times the user specifies and counts the occurrences of each total (2-12). I have to compare the results of the random rolls to the expected outcome and give the percentage of error between the two.
I have an example that tells me the sum to expected outcome are as follows if I roll 36 times: 2/1, 3/2, 4/3, 5/4, 6/5, 7/6, 8/5, 9/4, 10/3, 11/2, 12/1 but I don't know how to put that into code to get the expected outcome for X amount of rolls.
View 11 Replies
View Related
Feb 12, 2014
i have to make a programs that prompts the user to enter quiz grades and add them up. For examples the user enters 6 test grades they are out of 5 so he enters 0-5 and i store them in the array. This part works great but now i have to print out a bar of vertical asterisks for every part too. So if at the end we have one test grades that are 2 grades of 1 points, 1 grade of two point, 2 grades of three point and 1 grade of 5 point it will have to display them as this
There are 2 grades of 1
There are 1 grades of 2
There are 2 grades of 3
There are 1 grades of 5
i need to do for loops but i am stuck on what to count too and what to print i know i will need cout << "*" and a couple of spaces.
#include <iostream>
using namespace std;
int main (){
int size;
int tests;
int a[6]={0};
cout << "How many quiz scores will you enter: ";
cin >> size;
[code]....
View 1 Replies
View Related
May 18, 2013
You have to implement a data structure to represent graphs,directed or undirected,that tries to avoid the wasted space in the representation of a graph with adjacency matrix and the difficulty of searching the edges with adjacency list representation.We consider that the vertices are numbered from 1 to nverts and the exit degree of each vertex is at most MAXDEG. If deg[i] is the exit degree of the vertex i then the neighbors of the vertex i can be saved at the matrix edge[i][j], 1<=j<=deg[i].
Write a program that reads the datas from a file: if the graph is directed or undirected(1 or 0), the number of vertices (nverts),the number of edges (nedges) and the first and the last vertex of each edge.Write the function dfs that, with argument the data structure that you implemented before for the representation of a graph, prints the edges by the depth-first search of a graph. What I've done so far is: I wrote a program that reads these information from a file, calculates the exit degree of each vertex and creates the matrix edge[i][j]. What data structure do I have to implement???
View 1 Replies
View Related
Oct 29, 2013
this is my first year programming, and in my class, each week we have to write a program. last week we wrote a program in c that made random value point and made a graph of the random points that continued on forever. this week, we have to use statistical functions to find the sum, mean, max, and min of the graph. below is the code i have so far.
Code:
#include <stdlib.h>
#include <strings.h>
#include <stdio.h>
#include <stdbool.h>
#include "SwinGame.h"
[code]....
so, as you can see from the code, the parts i need are finding/ coming up with a function to find the max min sum and mean of the functions.
View 7 Replies
View Related
Feb 26, 2014
How do I print this without generating errors?
Code:
printf(" ||====================================================================||
");
printf(" ||//$///////////////////////////////$||
");
printf(" ||(100)==================| RESERVE BANK OF INDIA|================(100)||
");
printf(" ||$// ~ '------========--------' $//||
[code].....
View 8 Replies
View Related
Apr 16, 2014
I am using koolplot plot graph and able to plot two lines in a graph. My question is how to fill between the lines? Is it possible to do so with koolplot? or i should use another library?
View 2 Replies
View Related
Jan 5, 2014
I am trying to compare two vectors and make a bar graph. I have tried sorting it and pushing it into another vector but this issue is when I go to output it. My logic is wrong.
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <iomanip>
int main(int argc, const char * argv[]) {
[Code] ....
Output
22 *
44 *
22 *
45 *
33 *
44 *
18 *
34 *
33 *
12 *
3 *
5 *
34 *
33 *
5 *
7 *
22 *
44 *
49 *
9 *
18 *
View 3 Replies
View Related
Mar 30, 2014
I used a BFS to simulate graph-join structure in a C++ code, and had a binary tree that asks the user e.g. to insert a node in the tree among other options, anyhow, I reached a point where I should pass a set of vertices from the graph to the tree, but how to do so. So I wanted to ask is such a thing possible? i.e. passing vertices from a graph to a tree automatically (no user involvement is needed)?
View 4 Replies
View Related
May 3, 2014
"My Programm is crashing and i dont know why?"
#include<iostream>
using namespace std;
int arr[3];
struct edges {
int edge_data;
edges *next;
[code]....
View 1 Replies
View Related
Apr 13, 2013
I need building a complete graph from a file. The format in the file is as follows.
[ vertex 1] [ x_coordinate 1] [ y_coordinate 1] [cityname 1]
[ vertex 2] [ x_coordinate 2] [ y_coordinate 2] [cityname 2]
. . .
[ vertex n] [ x_coordinate n] [ y_coordinate n] [cityname n]
What kind of data structure shall I use in order to store date in a complete graph so there is an edge between every pair?
View 7 Replies
View Related
Dec 29, 2013
I was asked to find the longest path in a graph. I was thinking about using Dijsktra's algorithm after multiplying all the weights with -1 and run the program in normal way and find the shortest path. And then I'll multiply with -1 again and get the longest path. I think this should give me the longest path, do you think it would work? And also, I'm dealing with considerably big data, such as 1.000.000 nodes and many more edges. etc. and I have a time limit of 2 seconds and memory limit of 128mb. Any other data structure instead of Adjacency Matrix? Because I'm pretty sure it will exceed the limits.
View 2 Replies
View Related
Apr 18, 2012
I wrote class DFS - Depth-first search. This algorithm check that this graph is consistent. Below is code of class
Code:
#ifndef DFS_H
#defineDFS_H
class DFS{
private:
std::stack<int, std::vector<int> > stos;//stos do przechowywania wezlow w dfs'ie
int *odwiedzony;
int liczbaWezlow;
[Code] ....
When i initialize dfs i use 2 parameters. On the next step i would like show all content array odwiedzony. Regardless of the given parameters of the array always has a value of zero. Where i made mistake and how to repair?
View 10 Replies
View Related
May 7, 2013
I want to convert Hex:390041 to ascii "90A",
39: 9
00: 0 -->Null
41: A
i am getting only "9" in the bytearray,i know 0 is terminating the array
unsigned int bytes[3];
int j=0,counter=0;
char c[2];
[Code]....
View 1 Replies
View Related
Mar 31, 2015
I have some ascii characters in a char variable.ex - char buf[100]="ab*(z&";
So each of the char in that char array will have some hex value.ex- *'s hex value is '2a'.
And I have a long long int variable in which there is a 64 bit hex value.
ex- long long int k=0x0000888888888888;
Now i want to subtract the char buff's hex value in k. How to accomplish it.
That is 0x0000888888888888
- 0x000061622a287a26
= 0x000027265e600e62 (final result in a buffer or a long variable is okay)
Later i want to reverse the result as 26e006e56272.It should be stored in a variable such that i should be able to access each byte from it(ex- '72'(last 2 hex digits))
View 1 Replies
View Related
May 29, 2013
I have a 'Graph' class, which has derived classes for Adjacency Matrix and Adjacency List representations.
How do I provide iterators for traversing vertices and edges, when the iterator classes would have different implementations for the different derived classes ?
The following way is the only one I can think of, but seems quite cumbersome.
Code:
class Base {
public:
class BaseIterator {
};
virtual const BaseIterator& begin();
virtual const BaseIterator& end();
[Code] .....
Or is there a pattern for doing this that I'm not aware of ? Would composition be a better idea here compared to polymorphism ? I mean, I can think like..a Graph can 'have' several representation 'objects' within it.
All the involved classes are templates,not sure if that makes the situation different.
View 7 Replies
View Related
Jan 14, 2015
Is not the first time I upload this program i know, but the problem now is that i try to export files, because i need to create an excel graph. But when I try to run it, I don't have any result, no file and no result of the program.
Code:
#include<stdio.h>#include <time.h>
#include <cstdlib>
#include <math.h>
int randfun(double arrX[], double arrY[], int size);
int cenfun(double arrX[], double arrY[], int size);
int rotatefun(double arrX[], double arrY[], int size, double center_x, double center_y, const double angle);
[Code] .....
View 2 Replies
View Related
Dec 14, 2013
The only language I know so far is C. Is there any way I can use c programming to display a live chart for a price graph including volume in different time intervals that I want to select. I want it to look like this URL....
View 2 Replies
View Related
Jan 10, 2013
I have a network data file that looks like this:
2476
112
213
321
426
531
634
7312
843
945
...
...
...
The first row has two values - number of nodes (24) and number of links (76). Then it has all the link details (76 rows of data). I want to read this data. I have written out the following function:
First the structure definitions:
typedef struct {
int arcno;
int tail;
int head;
} arc_data;
typedef struct {
int forwardStarPoint;
int reverseStarPoint;
[Code] .....
The code is able to read the first line of data (i.e. it displays the numNodes and numArcs as 24 and 76). But then I get a lot of errors like this one
`Access violation writing location 0xCCCCCCD8`.
The program then crashes.
View 3 Replies
View Related
Mar 22, 2013
Any example of a graph search algorithm that uses a recursion and linked list based stacks to determine a route from a single point on a graph to another single point on a graph?
View 3 Replies
View Related
Apr 28, 2014
I'm working on a Dijkstra's algorithm with a fixed graph. My question is, how should I go about assign distance values to the graph. The user can start from any node.
View 4 Replies
View Related