Click here to Skip to main content
15,910,603 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Any suggestions with an app plug-in design? Pin
Roger Allen7-Apr-03 1:21
Roger Allen7-Apr-03 1:21 
GeneralDeleteFile Function question Pin
Martin Marvinski6-Apr-03 12:26
Martin Marvinski6-Apr-03 12:26 
GeneralRe: DeleteFile Function question Pin
Anders Molin6-Apr-03 13:31
professionalAnders Molin6-Apr-03 13:31 
GeneralRe: DeleteFile Function question Pin
Nish Nishant6-Apr-03 20:09
sitebuilderNish Nishant6-Apr-03 20:09 
Generalstring copy Pin
act_x6-Apr-03 11:18
act_x6-Apr-03 11:18 
GeneralRe: string copy Pin
Chris Losinger6-Apr-03 11:28
professionalChris Losinger6-Apr-03 11:28 
GeneralRe: string copy Pin
valikac6-Apr-03 15:08
valikac6-Apr-03 15:08 
GeneralBeginner C++ programmer... question on arrays, creating a histogram... Pin
Sheshi6-Apr-03 8:39
Sheshi6-Apr-03 8:39 
Hi All, wondering if someone could take a look at the following program and give me any hints/insight as to why I can't get the appropriate amount of asterisks to print above each number.

This program rolls two dice and is supposed to calculate the number of rolls for each number 2-12, and show that in a histogram.

Any suggestions? THANK YOU for any help! Roll eyes | :rolleyes:

<br />
#include <iostream><br />
<br />
using std::cout;<br />
using std::cin;<br />
using std::endl;<br />
<br />
#include <iomanip><br />
using std::setw;<br />
<br />
#include <ctime><br />
<br />
const int arraySize = 13;<br />
const int maxRolls = 50;<br />
<br />
int maximum (int [], int);<br />
int histogram(int [] [arraySize], int [], int, int);<br />
<br />
int main()<br />
{<br />
	srand(time(0));<br />
	int face, max, frequency[arraySize] = {0};<br />
<br />
	for (int i = 0; i < maxRolls; i++) <br />
		++frequency[(1 + rand() % 6) + (1 + rand() % 6)]; //generates all rolls, places data in array<br />
<br />
		cout << "Below shows random results of rolling a pair of die 50 times" << endl;<br />
		cout << "along with the number of times each number (2-12) was rolled." << endl;<br />
		<br />
	max = maximum (frequency, arraySize);<br />
	int table [maxRolls] [arraySize] = {0};<br />
	histogram (table, frequency, max, arraySize);<br />
		<br />
	for (face = 2; face < arraySize; face++)<br />
		cout << setw(4) << face << " ";<br />
		cout << endl << endl;<br />
<br />
	return 0;<br />
}<br />
<br />
int maximum (int x[], int size)<br />
{<br />
	int swap;<br />
	<br />
	for (int i = 0; i < (size-1); i++) <br />
<br />
		for (int j = 0; j < (size-1); j++) <br />
			<br />
			if (x[j] > x[j+1]) <br />
			{<br />
				swap = x[j];<br />
				x[j] = x[j+1];<br />
				x[j+1] = swap;<br />
			}<br />
<br />
			return x[size-1];<br />
}<br />
<br />
int histogram (int y[] [arraySize], int frequency [], int max, int size)<br />
{<br />
	//begins entering *s at max row<br />
	int start = maxRolls - max;<br />
	<br />
	//begin row loop<br />
	for (int i = start; i < maxRolls; i++)<br />
<br />
		//begin column loop<br />
		for (int j = 0; j < size; j++)<br />
		<br />
			if (frequency [j+2] <= max)<br />
				cout << y[i][j] << setw(4) << "*";<br />
<br />
			else<br />
				cout << y[i][j] << setw(4) << " ";<br />
<br />
			cout << endl;<br />
<br />
			return 0;<br />
}<br />





Sheshi
GeneralRe: Beginner C++ programmer... question on arrays, creating a histogram... Pin
Nick Parker6-Apr-03 15:15
protectorNick Parker6-Apr-03 15:15 
GeneralRe: Beginner C++ programmer... question on arrays, creating a histogram... Pin
PJ Arends6-Apr-03 21:34
professionalPJ Arends6-Apr-03 21:34 
GeneralToolbar Installation Pin
DuFF6-Apr-03 6:58
DuFF6-Apr-03 6:58 
GeneralRe: Toolbar Installation Pin
Xalon6-Apr-03 9:46
Xalon6-Apr-03 9:46 
GeneralRe: Toolbar Installation Pin
J. Dunlap6-Apr-03 10:45
J. Dunlap6-Apr-03 10:45 
Generalloading dll Pin
Member 3280826-Apr-03 6:32
Member 3280826-Apr-03 6:32 
GeneralRe: loading dll Pin
Nick Parker6-Apr-03 6:40
protectorNick Parker6-Apr-03 6:40 
GeneralRe: loading dll Pin
Reza Shademani6-Apr-03 6:47
Reza Shademani6-Apr-03 6:47 
GeneralRe: loading dll Pin
Michael Dunn6-Apr-03 9:09
sitebuilderMichael Dunn6-Apr-03 9:09 
GeneralA Custom EditBox Activex Control Pin
ZarrinPour6-Apr-03 6:28
ZarrinPour6-Apr-03 6:28 
Generalfind out which ports are open on the local machine Pin
d_kilshtein6-Apr-03 4:41
d_kilshtein6-Apr-03 4:41 
GeneralCreate my own color palette. Pin
sandbird6-Apr-03 0:50
sandbird6-Apr-03 0:50 
GeneralDialog Background Pin
yashraj6-Apr-03 0:47
yashraj6-Apr-03 0:47 
GeneralRe: Dialog Background Pin
Pavel Klocek6-Apr-03 1:48
Pavel Klocek6-Apr-03 1:48 
GeneralRe: Dialog Background Pin
yashraj6-Apr-03 5:33
yashraj6-Apr-03 5:33 
GeneralRe: Dialog Background Pin
Daniel Strigl6-Apr-03 1:50
Daniel Strigl6-Apr-03 1:50 
QuestionHow to create B&W bmp's from binary data... Pin
sandbird6-Apr-03 0:45
sandbird6-Apr-03 0:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.