<?xml version="1.0" encoding="utf-8"?>

<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
	<channel>
		<title>DaniWeb IT Discussion Community - C++</title>
		<link>http://www.daniweb.com/forums/</link>
		<description><![CDATA[Our C++ forum is the place for Q&A-style discussions related to this popular language.  Note we have a separate C forum for non-OOP straight C. Please direct C++ questions directly related to game development to our Game Development forum.]]></description>
		<language>en-US</language>
		<lastBuildDate>Fri, 20 Nov 2009 22:17:49 GMT</lastBuildDate>
		<generator>vBulletin</generator>
		<ttl>60</ttl>
		<image>
			<url>http://www.daniweb.com/alphaimages/misc/rss.jpg</url>
			<title>DaniWeb IT Discussion Community - C++</title>
			<link>http://www.daniweb.com/forums/</link>
		</image>
		<item>
			<title>Inheritance</title>
			<link>http://www.daniweb.com/forums/thread240094.html</link>
			<pubDate>Fri, 20 Nov 2009 21:13:08 GMT</pubDate>
			<description><![CDATA[Okay where should I begin....  I have this rather asinine program that as of right now only asks the user what quantity of dollars and particular coins they have then just spits out what was imputed. I need to add in a 'child' class that does all the following 
 
-Add a new private or protected...]]></description>
			<content:encoded><![CDATA[<div>Okay where should I begin....  I have this rather asinine program that as of right now only asks the user what quantity of dollars and particular coins they have then just spits out what was imputed. I need to add in a 'child' class that does all the following<br />
<br />
-Add a new private or protected data member for a cents. This should be a floating point variable.<br />
<br />
-Add the appropriate accessor and mutator methods to the class<br />
<br />
-It needs to have its own no argument constructor that calls the base class constructor and then initializes cents to 0. <br />
<br />
-The new class should override the inputInfo method of Money. This new method will use the base class method to retrieve the data from the user as dollars, quarters, dimes, nickels and pennies. After the data has been retrieved the method should convert and store the value of the dollars, quarters, dimes, nickels and pennies as a floating point value in cents.<br />
<br />
-The new class should override the outputInfo method so that in additional to calling the base classes method, it prints an additional line showing the amount of money as a decimal value. <br />
<br />
I attached a UML (i think)<br />
<br />
And heres the code:<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
using namespace std;<br />
<br />
class Money<br />
{<br />
private:<br />
// Private data members<br />
int dollars, quarters, dimes, nickels, pennies;<br />
public:<br />
// Default constructor<br />
Money() : dollars(0),quarters(0),dimes(0),nickels(0),pennies(0)<br />
{}<br />
// User input/output methods<br />
void inputInfo();<br />
void outputInfo();<br />
// Accessor methods<br />
int getDollars() { return(dollars); }<br />
int getQuarters() { return(quarters); }<br />
int getDimes() { return(dimes); }<br />
int getNickels() { return(nickels); }<br />
int getPennies() { return(pennies); }<br />
// Mutator methods<br />
void setDollars(int data) { dollars = data; }<br />
void setQuarters(int data) { quarters = data; }<br />
void setDimes(int data) { dimes = data; }<br />
void setNickels(int data) { nickels = data; }<br />
void setPennies(int data) { pennies = data; }<br />
};<br />
int main()<br />
{<br />
Money money;<br />
money.inputInfo ();<br />
money.outputInfo ();<br />
return 0;<br />
}<br />
void Money::outputInfo()<br />
{<br />
cout &lt;&lt; &quot;\n\nYou have &quot; &lt;&lt; getDollars() &lt;&lt; &quot; dollars, &quot;<br />
&lt;&lt; getQuarters() &lt;&lt; &quot; quarters, &quot;<br />
&lt;&lt; getDimes() &lt;&lt; &quot; dimes, &quot; &lt;&lt; getNickels()<br />
&lt;&lt; &quot; nickels and &quot; &lt;&lt; getPennies()<br />
&lt;&lt; &quot; pennies.\n&quot;;<br />
}<br />
void Money::inputInfo()<br />
{<br />
int input;<br />
cout &lt;&lt; &quot;Enter the number of dollars you have (whole numbers only): &quot;;<br />
cin &gt;&gt; input;<br />
setDollars(input);<br />
cout &lt;&lt; &quot;Enter the number of quarters you have (whole numbers only): &quot;;<br />
cin &gt;&gt; input;<br />
setQuarters(input);<br />
cout &lt;&lt; &quot;Enter the number of dimes you have (whole numbers only): &quot;;<br />
cin &gt;&gt; input;<br />
setDimes(input);<br />
cout &lt;&lt; &quot;Enter the number of nickels you have (whole numbers only): &quot;;<br />
cin &gt;&gt; input;<br />
setNickels(input);<br />
cout &lt;&lt; &quot;Enter the number of pennies you have (whole numbers only): &quot;;<br />
cin &gt;&gt; input;<br />
setPennies(input);<br />
}</pre><br />
Now what I need is some help as to how to implement this new derived class into my code.<br />
<br />
And please try to keep any explanations simple I am rather &quot;challenged&quot; in this field.</div>  <br /> <div style="padding:5px">    <fieldset class="fieldset"> <legend>Attached Images</legend> <table cellpadding="0" cellspacing="5" border="0"> <tr> <td><img class="inlineimg" src="http://www.daniweb.com/forums/images/attach/png.gif" alt="File Type: png" width="16" height="16" border="0" style="vertical-align:baseline" /></td> <td><a href="http://www.daniweb.com/forums/attachment.php?attachmentid=12658&amp;d=1258751196" target="_blank">UML.png</a> (61.1 KB)</td> </tr> </table> </fieldset>   </div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>itzaaron</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240094.html</guid>
		</item>
		<item>
			<title><![CDATA[separating left & right channels in array using libsndfile]]></title>
			<link>http://www.daniweb.com/forums/thread240084.html</link>
			<pubDate>Fri, 20 Nov 2009 20:48:10 GMT</pubDate>
			<description><![CDATA[Hi- 
 
I'm really new to c+ (this is day two) and I'm trying to write a program that will allow me to write audio data from a wave file into two arrays for the left channel and the right channel, i've pieced together this code so far and its definitely grabbing something from the wave file however...]]></description>
			<content:encoded><![CDATA[<div>Hi-<br />
<br />
I'm really new to c+ (this is day two) and I'm trying to write a program that will allow me to write audio data from a wave file into two arrays for the left channel and the right channel, i've pieced together this code so far and its definitely grabbing something from the wave file however i've no idea if its writing out left or right data or even a combination of the two.<br />
<br />
any ideas what I could be doing wrong?<br />
<br />
thanks<br />
<br />
domm<br />
<br />
<br />
 <pre style="margin:20px; line-height:13px">int ReadWave::waveFileToArray(){<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; //sndfile obj + soundfile info object<br />
&nbsp; &nbsp; &nbsp; &nbsp; SNDFILE *sf;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp;  SF_INFO info;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp;  int num;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int num_items;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; int numFrames;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int sampleRate;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int channels;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; int i;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int j;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp;  FILE *out;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; SNDFILE *outWave;<br />
&nbsp; &nbsp; &nbsp; &nbsp; // open the wave<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; info.format = 0;<br />
&nbsp;  sf = sf_open(filePath, SFM_READ,&amp;info);<br />
&nbsp;  if (sf == NULL)<br />
&nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp;  printf(&quot;Failed to open the file.\n&quot;);<br />
&nbsp; &nbsp; &nbsp;  exit(-1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; numFrames = info.frames;<br />
&nbsp;  sampleRate = info.samplerate;<br />
&nbsp;  channels = info.channels;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; num_items = numFrames * channels;<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; vector &lt;int&gt; buffer(num_items);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; num = sf_read_int(sf, &amp;buffer[0], num_items);<br />
&nbsp; &nbsp; &nbsp; &nbsp; sf_close(sf);<br />
<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; for (i = 0; i &lt; num; i += channels){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rawWaveDataArray.push_back(buffer[i]);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;the array size is: %d \n&quot;, rawWaveDataArray.size());<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp;  printf(&quot;frames=%d\n&quot;, numFrames);<br />
&nbsp;  printf(&quot;samplerate=%d\n&quot;, sampleRate);<br />
&nbsp;  printf(&quot;channels=%d\n&quot;,channels);<br />
<br />
&nbsp;  printf(&quot;num_items=%d\n&quot;,num_items);<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;Read %d items\n&quot;, num);<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; for(i = 0; i &lt; rawWaveDataArray.size(); i++){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;%d\n&quot;, rawWaveDataArray[i]);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp;  fclose(out);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>debugdom</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240084.html</guid>
		</item>
		<item>
			<title>simulating alt+2 (keypad) combination</title>
			<link>http://www.daniweb.com/forums/thread240082.html</link>
			<pubDate>Fri, 20 Nov 2009 20:47:06 GMT</pubDate>
			<description><![CDATA[I am trying to print the corresponding Unicode character for alt+2 to the Windows console window. (the console doesn't display the character, but should display ^B instead) 
The following doesn't seem to work. Just prints "2". 
 
keybd_event(VK_MENU,0 ,0 , 0); //Alt Press 
 
Sleep(10);...]]></description>
			<content:encoded><![CDATA[<div>I am trying to print the corresponding Unicode character for alt+2 to the Windows console window. (the console doesn't display the character, but should display ^B instead)<br />
The following doesn't seem to work. Just prints &quot;2&quot;.<br />
<br />
keybd_event(VK_MENU,0 ,0 , 0); //Alt Press<br />
<br />
Sleep(10);<br />
keybd_event(VK_NUMPAD2,0, 0 , 0); // 2 Press<br />
<br />
Sleep(10);<br />
keybd_event(VK_NUMPAD2,0, KEYEVENTF_KEYUP,0); // 2 Release<br />
<br />
Sleep(10);<br />
keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0); // Alt Release<br />
<br />
Sleep(10);<br />
<br />
Neither does this work. Again, just prints &quot;2&quot;.<br />
<br />
        INPUT inputs = {0}; <br />
	inputs.type = INPUT_KEYBOARD; <br />
<br />
	KEYBDINPUT ki = {0}; <br />
	ki.wVk = VK_LMENU;<br />
<br />
	inputs.ki = ki;<br />
	SendInput(1, &amp;inputs, sizeof(INPUT)); // Left alt<br />
<br />
	ki.wVk = VK_NUMPAD2;<br />
	inputs.ki = ki;<br />
	SendInput(1, &amp;inputs, sizeof(INPUT)); // Numpad 2<br />
<br />
	ki.dwFlags = KEYEVENTF_KEYUP;<br />
<br />
	ki.wVk = VK_NUMPAD2;<br />
	inputs.ki = ki;<br />
	SendInput(1, &amp;inputs, sizeof(INPUT)); // Numpad 2<br />
<br />
	ki.wVk = VK_LMENU;<br />
	inputs.ki = ki;<br />
	SendInput(1, &amp;inputs, sizeof(INPUT)); // Left alt</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>kangekraam</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240082.html</guid>
		</item>
		<item>
			<title>about this function..</title>
			<link>http://www.daniweb.com/forums/thread240081.html</link>
			<pubDate>Fri, 20 Nov 2009 20:33:24 GMT</pubDate>
			<description><![CDATA[I just want to know what does the below mentioned function means? 
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox" title="Help with Code Tags"...]]></description>
			<content:encoded><![CDATA[<div>I just want to know what does the below mentioned function means?<br />
<br />
 <pre style="margin:20px; line-height:13px"><span style="color:Green">void swap(char&amp; a, char&amp; b)</span></pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>maverick405</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240081.html</guid>
		</item>
		<item>
			<title>Create vector of strings with alphabet</title>
			<link>http://www.daniweb.com/forums/thread240078.html</link>
			<pubDate>Fri, 20 Nov 2009 20:12:47 GMT</pubDate>
			<description><![CDATA[So here is the question and it is really stumping me because I can print the alphabet once but cant figure out how to repeat it. 
 
First create a character array that contains the 26 letters as shown here. //Easy I can copy and paste ha. 
 
	  <div class="codeblock"> <div class="spaced"> <div...]]></description>
			<content:encoded><![CDATA[<div>So here is the question and it is really stumping me because I can print the alphabet once but cant figure out how to repeat it.<br />
<br />
First create a character array that contains the 26 letters as shown here. //Easy I can copy and paste ha.<br />
<br />
	 <pre style="margin:20px; line-height:13px">char cAlphabet[] = {'a','b','c','d','e','f',<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'g','h','i','j','k','l','m','n','o','p',<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'q','r','s','t','u','v','w','x','y','z'};</pre><br />
Then create a vector of strings where the first string is 'a' and the second is 'bc', the third, 'def', etc. Create the number of strings requested by the user. Once you reach the letter z, start again with first letter in the alphabet. When you are done, print each vector to the screen.<br />
<br />
How many strings would you like to create?<br />
8<br />
<br />
a<br />
bc<br />
def<br />
ghij<br />
klmno<br />
pqrstu<br />
vwxyzab<br />
cdefghij<br />
<br />
<br />
<br />
Here is what I have so far it works up until 6 or 7 strings but I dont know how to fix it so that it will continue to print strings with the alphabet starting over. Anything helps, Thanks.<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
#include &lt;vector&gt;<br />
#include &lt;string&gt;<br />
using namespace std;<br />
<br />
<br />
void printVector( vector&lt;string&gt; v )<br />
{<br />
&nbsp; for(unsigned int i = 0; i &lt; v.size(); i++)<br />
&nbsp; {<br />
&nbsp; &nbsp; cout &lt;&lt; v[i] &lt;&lt; &quot;\t&quot;;<br />
&nbsp; }<br />
&nbsp; cout &lt;&lt; endl;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; return;<br />
}<br />
<br />
int main()<br />
{<br />
int nStrings=0;<br />
<br />
string str1=&quot; &quot;;<br />
<br />
vector&lt;string&gt; myVector;<br />
<br />
char cAlphabet[] = {'a','b','c','d','e','f',<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'g','h','i','j','k','l','m','n','o','p',<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'q','r','s','t','u','v','w','x','y','z'};<br />
<br />
str1=cAlphabet;<br />
string str=&quot; &quot;;<br />
str= str1.substr(0,26);<br />
cout&lt;&lt;str&lt;&lt;endl;<br />
<br />
cout&lt;&lt;&quot;How many strings would you like?&quot;&lt;&lt;endl;<br />
cin&gt;&gt;nStrings;<br />
<br />
for(int i=0; i &lt; nStrings; i++)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; static int j=0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; j= j + i;<br />
<br />
myVector.push_back(str.substr( j, (i+1) ));<br />
<br />
printVector(myVector);<br />
myVector.clear();<br />
<br />
}<br />
<br />
<br />
return 1;<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>wh33lz</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240078.html</guid>
		</item>
		<item>
			<title><![CDATA[[][] operator?]]></title>
			<link>http://www.daniweb.com/forums/thread240070.html</link>
			<pubDate>Fri, 20 Nov 2009 19:27:27 GMT</pubDate>
			<description><![CDATA[Say you have a class that has members 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox" title="Help with Code Tags" target="_blank">Help with Code Tags</a>...]]></description>
			<content:encoded><![CDATA[<div>Say you have a class that has members<br />
 <pre style="margin:20px; line-height:13px">private:<br />
double a,b,c,d,e,f,g,h,i;</pre><br />
You can make an accessor like:<br />
 <pre style="margin:20px; line-height:13px">&nbsp; double operator[](int index)<br />
&nbsp; {<br />
&nbsp; &nbsp; if(index == 0)<br />
&nbsp; &nbsp; &nbsp; return a;<br />
&nbsp; &nbsp; else if(index == 1)<br />
&nbsp; &nbsp; &nbsp; return b;<br />
&nbsp; &nbsp; else if(index == 2)<br />
&nbsp; &nbsp; &nbsp; return c;<br />
&nbsp; }</pre><br />
But how would you do something like this:<br />
 <pre style="margin:20px; line-height:13px"> <br />
&nbsp; double operator[][](int rindex, int cindex)<br />
&nbsp; {<br />
&nbsp; &nbsp; if(rindex == 0 &amp;&amp; cindex == 0)<br />
&nbsp; &nbsp; &nbsp; return a;<br />
&nbsp; &nbsp; else if(rindex == 1 &amp;&amp; cindex == 0)<br />
&nbsp; &nbsp; &nbsp; return b;<br />
&nbsp; &nbsp; else if(rindex == 2 &amp;&amp; cindex == 0)<br />
&nbsp; &nbsp; &nbsp; return c;<br />
&nbsp; &nbsp; else if(rindex == 0 &amp;&amp; cindex == 1)<br />
&nbsp; &nbsp;  return d;<br />
..... etc ...<br />
&nbsp; }</pre><br />
The compiler doesn't like the above attempt. The behavior I'm looking for is:<br />
 <pre style="margin:20px; line-height:13px">MatrixClass Matrix;<br />
// ... fill it<br />
double test = Matrix[0][1];</pre><br />
Thoughts?<br />
<br />
Thanks,<br />
<br />
Dave</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>daviddoria</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240070.html</guid>
		</item>
		<item>
			<title>Algoritm Question</title>
			<link>http://www.daniweb.com/forums/thread240060.html</link>
			<pubDate>Fri, 20 Nov 2009 18:19:47 GMT</pubDate>
			<description><![CDATA[Hello there, 
 
I have the following situation : I have a moving ball in a rectangular 2D chamber. When the ball touches the walls of the chamber it changes it's direction. It is simple to implement the ball movement when the chamber is empty ( it has only 4 walls). My question is , how to I...]]></description>
			<content:encoded><![CDATA[<div>Hello there,<br />
<br />
I have the following situation : I have a moving ball in a rectangular 2D chamber. When the ball touches the walls of the chamber it changes it's direction. It is simple to implement the ball movement when the chamber is empty ( it has only 4 walls). My question is , how to I implement the movement of the ball in a chamber with numerous objects in it ? ( by objects I refer to rectangular or square shapes). Also , I know the initial ball direction. I've tried using a matrix to map the room, but I got stuck in it. Have any good ides of how could this be done ?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>spiriad</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240060.html</guid>
		</item>
		<item>
			<title>program does not read input</title>
			<link>http://www.daniweb.com/forums/thread240058.html</link>
			<pubDate>Fri, 20 Nov 2009 18:15:17 GMT</pubDate>
			<description>Hello all, 
 
I did this program below, it is meant to get a student name then 5 of his/her grades sums them up in a void function and calculate the average but outputs the average from the main  
 
the problem is that the loop goes on and prints the prompt but takes no input  
 
how can I fix that...</description>
			<content:encoded><![CDATA[<div>Hello all,<br />
<br />
I did this program below, it is meant to get a student name then 5 of his/her grades sums them up in a void function and calculate the average but outputs the average from the main <br />
<br />
the problem is that the loop goes on and prints the prompt but takes no input <br />
<br />
how can I fix that ?<br />
<br />
 <pre style="margin:20px; line-height:13px"># include &lt;iostream&gt;<br />
# include &lt;string&gt;<br />
using namespace std;<br />
<br />
void avg (int grade[]);<br />
<br />
int main()<br />
{<br />
&nbsp; char name;<br />
&nbsp; double average;<br />
&nbsp; int grade[5];<br />
<br />
&nbsp; cout &lt;&lt; &quot;Student name&quot; &lt;&lt;endl;<br />
&nbsp; cin.get(name);<br />
&nbsp; cout &lt;&lt;endl;<br />
<br />
&nbsp; avg (grade);<br />
&nbsp; cout &lt;&lt; &quot;The average is &quot; &lt;&lt; average &lt;&lt;endl;<br />
<br />
&nbsp;return 0;<br />
}<br />
<br />
&nbsp; void avg (int grade[])<br />
&nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; double sum=0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; double average;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int i=0; i&lt;5; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Please enter grade&quot; &lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; grade[i];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sum= sum+grade[i];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; average = sum/5;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; }</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>new programer</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240058.html</guid>
		</item>
		<item>
			<title>store numbers from a .txt file</title>
			<link>http://www.daniweb.com/forums/thread240034.html</link>
			<pubDate>Fri, 20 Nov 2009 15:15:38 GMT</pubDate>
			<description><![CDATA[Hi, I've just started with c++ and I have no clue how to do this. Right now I have a code that just printing out the text lines in my file and how many lines there is just to check that i can read from my file... 
 
But what I want to do and can't figure out is to pick out and store numbers from...]]></description>
			<content:encoded><![CDATA[<div>Hi, I've just started with c++ and I have no clue how to do this. Right now I have a code that just printing out the text lines in my file and how many lines there is just to check that i can read from my file...<br />
<br />
But what I want to do and can't figure out is to pick out and store numbers from text lines. <br />
<br />
Consider this as user inputs to a file:<br />
<br />
Number 10 Downing Street<br />
My birthday is 6 May 1980<br />
<br />
And now I want to read from the .txt file and store the number 10 from the first text line and then store 6 and 1980 from the second line of text. <br />
<br />
 <pre style="margin:20px; line-height:13px">//..Some codes to put in lines of user specific text to a file. [done]<br />
<br />
//And now the code that outputs the text rows and number of rows in<br />
//the file but have nothing to do with what i want to achive :(<br />
&nbsp; <br />
&nbsp; ifstream inputfile(filename);<br />
&nbsp; char text;<br />
&nbsp; int n = 0; <br />
&nbsp; <br />
&nbsp; while (inputfile.get(text))<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; cout.put(text);<br />
&nbsp; &nbsp; &nbsp; if (text == '\n')<br />
&nbsp; &nbsp; &nbsp; &nbsp; ++n;<br />
&nbsp; &nbsp; }<br />
&nbsp; <br />
&nbsp; cout &lt;&lt; endl &lt;&lt; There is &quot; &lt;&lt; n &lt;&lt; &quot; rows of text&quot;;</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>nunchuckie</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240034.html</guid>
		</item>
		<item>
			<title>Problems with compiling in VS10 Express Beta2</title>
			<link>http://www.daniweb.com/forums/thread240032.html</link>
			<pubDate>Fri, 20 Nov 2009 14:58:47 GMT</pubDate>
			<description>I decided to try Visual Studio 2010 express Beta 2. 
This code works fine on my other computer that uses Visual Studio 2009 Pro. 
 
I am going to make a Timer that count down from a fixed time depending on foodsource. But first this code need to work :P so I can add the rest :) I wish to get this...</description>
			<content:encoded><![CDATA[<div>I decided to try Visual Studio 2010 express Beta 2.<br />
This code works fine on my other computer that uses Visual Studio 2009 Pro.<br />
<br />
I am going to make a Timer that count down from a fixed time depending on foodsource. But first this code need to work :P so I can add the rest :) I wish to get this working in VS10E because I dont use VS08 on this computer.<br />
 <pre style="margin:20px; line-height:13px">#include &lt;Windows.h&gt;<br />
<br />
const char gClassName[] = &quot;TibiaTimer&quot;;<br />
<br />
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; switch(msg)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; case WM_CLOSE:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DestroyWindow(hwnd);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; case WM_DESTROY:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PostQuitMessage(0);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; default:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return DefWindowProc(hwnd, msg, wParam, lParam);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
}<br />
<br />
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; WNDCLASSEX wc;<br />
&nbsp; &nbsp; &nbsp; &nbsp; HWND hwnd;<br />
&nbsp; &nbsp; &nbsp; &nbsp; MSG msg;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; wc.cbSize&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = sizeof(WNDCLASSEX);<br />
&nbsp; &nbsp; &nbsp; &nbsp; wc.style&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; wc.lpfnWndProc&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = WndProc;<br />
&nbsp; &nbsp; &nbsp; &nbsp; wc.cbClsExtra&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; wc.cbWndExtra&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; wc.hInstance&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = hInstance;<br />
&nbsp; &nbsp; &nbsp; &nbsp; wc.hIcon&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = LoadIcon(NULL, IDI_APPLICATION);<br />
&nbsp; &nbsp; &nbsp; &nbsp; wc.hIconSm&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = LoadIcon(NULL, IDI_APPLICATION);<br />
&nbsp; &nbsp; &nbsp; &nbsp; wc.hCursor&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = LoadCursor(NULL, IDC_ARROW);<br />
&nbsp; &nbsp; &nbsp; &nbsp; wc.hbrBackground&nbsp; &nbsp; &nbsp; &nbsp; = (HBRUSH)(COLOR_WINDOW+1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; wc.lpszMenuName&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = NULL;<br />
&nbsp; &nbsp; &nbsp; &nbsp; wc.lpszClassName&nbsp; &nbsp; &nbsp; &nbsp; = &quot;TibiaTimer&quot;;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; if(!RegisterClassEx(&amp;wc))<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MessageBoxA(NULL, &quot;Window registration failed!&quot;, &quot;FATAL ERROR&quot;, MB_ICONEXCLAMATION | MB_OK);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; hwnd = CreateWindowEx(WS_EX_CLIENTEDGE, &quot;TibiaTimer&quot;, &quot;TibiaTimer&quot;, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 340, 240, NULL, NULL, hInstance, NULL);<br />
&nbsp; &nbsp; &nbsp; &nbsp; if(hwnd == NULL)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MessageBoxA(NULL, &quot;Window creation failed!&quot;, &quot;FATAL ERROR&quot;, MB_ICONEXCLAMATION | MB_OK);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; ShowWindow(hwnd, nCmdShow);<br />
&nbsp; &nbsp; &nbsp; &nbsp; UpdateWindow(hwnd);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; while(GetMessage(&amp;msg, NULL, 0, 0) &gt; 0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TranslateMessage(&amp;msg);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DispatchMessage(&amp;msg);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; return msg.wParam;<br />
}</pre><br />
I use char-set <span style="font-weight:bold">Use Multi-Byte Character Set</span> and have tried Unicode as well but then I get some compiler errors. But I get a lot of Linker errors in VS10E. Here is the list for anyone that wanna take a look and maybe shed some light on this.<br />
<br />
<div style="margin:20px; margin-top:5px; "> <div class="smallfont" style="margin-bottom:2px">Quote:</div> <table cellpadding="5" cellspacing="0" border="0" width="100%"> <tr> <td class="alt2"> <hr />  ------ Build started: Project: TibiaTimer, Configuration: Debug Win32 ------<br />
  main.cpp<br />
main.obj : error LNK2028: unresolved token (0A000020) &quot;extern &quot;C&quot; int __stdcall DestroyWindow(struct HWND__ *)&quot; (?DestroyWindow@@$$J14YGHPAUHWND__@@@Z) referenced in function &quot;long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)&quot; (?WndProc@@$$FYGJPAUHWND__@@IIJ@Z)<br />
main.obj : error LNK2028: unresolved token (0A000022) &quot;extern &quot;C&quot; int __stdcall GetMessageA(struct tagMSG *,struct HWND__ *,unsigned int,unsigned int)&quot; (?GetMessageA@@$$J216YGHPAUtagMSG@@PAUHWND__@@II@Z) referenced in function &quot;extern &quot;C&quot; int __cdecl GetMessage(struct tagMSG *,struct HWND__ *,unsigned int,unsigned int)&quot; (?GetMessage@@$$J0YAHPAUtagMSG@@PAUHWND__@@II@Z)<br />
main.obj : error LNK2028: unresolved token (0A000029) &quot;extern &quot;C&quot; unsigned short __stdcall RegisterClassExA(struct tagWNDCLASSEXA const *)&quot; (?RegisterClassExA@@$$J14YGGPBUtagWNDCLASSEXA@@@Z) referenced in function &quot;extern &quot;C&quot; int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)&quot; (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z)<br />
main.obj : error LNK2028: unresolved token (0A00002B) &quot;extern &quot;C&quot; void __stdcall PostQuitMessage(int)&quot; (?PostQuitMessage@@$$J14YGXH@Z) referenced in function &quot;long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)&quot; (?WndProc@@$$FYGJPAUHWND__@@IIJ@Z)<br />
main.obj : error LNK2028: unresolved token (0A000035) &quot;extern &quot;C&quot; struct HICON__ * __stdcall LoadIconA(struct HINSTANCE__ *,char const *)&quot; (?LoadIconA@@$$J18YGPAUHICON__@@PAUHINSTANCE__@@PBD@Z) referenced in function &quot;extern &quot;C&quot; int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)&quot; (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z)<br />
main.obj : error LNK2028: unresolved token (0A00003E) &quot;extern &quot;C&quot; int __stdcall TranslateMessage(struct tagMSG const *)&quot; (?TranslateMessage@@$$J14YGHPBUtagMSG@@@Z) referenced in function &quot;extern &quot;C&quot; int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)&quot; (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z)<br />
main.obj : error LNK2028: unresolved token (0A000043) &quot;extern &quot;C&quot; int __stdcall MessageBoxA(struct HWND__ *,char const *,char const *,unsigned int)&quot; (?MessageBoxA@@$$J216YGHPAUHWND__@@PBD1I@Z) referenced in function &quot;extern &quot;C&quot; int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)&quot; (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z)<br />
main.obj : error LNK2028: unresolved token (0A000046) &quot;extern &quot;C&quot; struct HWND__ * __stdcall CreateWindowExA(unsigned long,char const *,char const *,unsigned long,int,int,int,int,struct HWND__ *,struct HMENU__ *,struct HINSTANCE__ *,void *)&quot; (?CreateWindowExA@@$$J248YGPAUHWND__@@KPBD0KHHHHPAU1@PAUHMENU__@@PAUHINSTANCE__@@PAX@Z) referenced in function &quot;extern &quot;C&quot; int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)&quot; (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z)<br />
main.obj : error LNK2028: unresolved token (0A000048) &quot;extern &quot;C&quot; long __stdcall DefWindowProcA(struct HWND__ *,unsigned int,unsigned int,long)&quot; (?DefWindowProcA@@$$J216YGJPAUHWND__@@IIJ@Z) referenced in function &quot;long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)&quot; (?WndProc@@$$FYGJPAUHWND__@@IIJ@Z)<br />
main.obj : error LNK2028: unresolved token (0A00004C) &quot;extern &quot;C&quot; int __stdcall ShowWindow(struct HWND__ *,int)&quot; (?ShowWindow@@$$J18YGHPAUHWND__@@H@Z) referenced in function &quot;extern &quot;C&quot; int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)&quot; (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z)<br />
main.obj : error LNK2028: unresolved token (0A000050) &quot;extern &quot;C&quot; long __stdcall DispatchMessageA(struct tagMSG const *)&quot; (?DispatchMessageA@@$$J14YGJPBUtagMSG@@@Z) referenced in function &quot;extern &quot;C&quot; long __cdecl DispatchMessage(struct tagMSG const *)&quot; (?DispatchMessage@@$$J0YAJPBUtagMSG@@@Z)<br />
main.obj : error LNK2028: unresolved token (0A000055) &quot;extern &quot;C&quot; int __stdcall UpdateWindow(struct HWND__ *)&quot; (?UpdateWindow@@$$J14YGHPAUHWND__@@@Z) referenced in function &quot;extern &quot;C&quot; int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)&quot; (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z)<br />
main.obj : error LNK2028: unresolved token (0A000056) &quot;extern &quot;C&quot; struct HICON__ * __stdcall LoadCursorA(struct HINSTANCE__ *,char const *)&quot; (?LoadCursorA@@$$J18YGPAUHICON__@@PAUHINSTANCE__@@PBD@Z) referenced in function &quot;extern &quot;C&quot; int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)&quot; (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z)<br />
main.obj : error LNK2019: unresolved external symbol &quot;extern &quot;C&quot; int __stdcall GetMessageA(struct tagMSG *,struct HWND__ *,unsigned int,unsigned int)&quot; (?GetMessageA@@$$J216YGHPAUtagMSG@@PAUHWND__@@II@Z) referenced in function &quot;extern &quot;C&quot; int __cdecl GetMessage(struct tagMSG *,struct HWND__ *,unsigned int,unsigned int)&quot; (?GetMessage@@$$J0YAHPAUtagMSG@@PAUHWND__@@II@Z)<br />
main.obj : error LNK2019: unresolved external symbol &quot;extern &quot;C&quot; long __stdcall DispatchMessageA(struct tagMSG const *)&quot; (?DispatchMessageA@@$$J14YGJPBUtagMSG@@@Z) referenced in function &quot;extern &quot;C&quot; long __cdecl DispatchMessage(struct tagMSG const *)&quot; (?DispatchMessage@@$$J0YAJPBUtagMSG@@@Z)<br />
main.obj : error LNK2019: unresolved external symbol &quot;extern &quot;C&quot; long __stdcall DefWindowProcA(struct HWND__ *,unsigned int,unsigned int,long)&quot; (?DefWindowProcA@@$$J216YGJPAUHWND__@@IIJ@Z) referenced in function &quot;long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)&quot; (?WndProc@@$$FYGJPAUHWND__@@IIJ@Z)<br />
main.obj : error LNK2019: unresolved external symbol &quot;extern &quot;C&quot; void __stdcall PostQuitMessage(int)&quot; (?PostQuitMessage@@$$J14YGXH@Z) referenced in function &quot;long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)&quot; (?WndProc@@$$FYGJPAUHWND__@@IIJ@Z)<br />
main.obj : error LNK2019: unresolved external symbol &quot;extern &quot;C&quot; int __stdcall DestroyWindow(struct HWND__ *)&quot; (?DestroyWindow@@$$J14YGHPAUHWND__@@@Z) referenced in function &quot;long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)&quot; (?WndProc@@$$FYGJPAUHWND__@@IIJ@Z)<br />
main.obj : error LNK2019: unresolved external symbol &quot;extern &quot;C&quot; int __stdcall TranslateMessage(struct tagMSG const *)&quot; (?TranslateMessage@@$$J14YGHPBUtagMSG@@@Z) referenced in function &quot;extern &quot;C&quot; int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)&quot; (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z)<br />
main.obj : error LNK2019: unresolved external symbol &quot;extern &quot;C&quot; int __stdcall UpdateWindow(struct HWND__ *)&quot; (?UpdateWindow@@$$J14YGHPAUHWND__@@@Z) referenced in function &quot;extern &quot;C&quot; int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)&quot; (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z)<br />
main.obj : error LNK2019: unresolved external symbol &quot;extern &quot;C&quot; int __stdcall ShowWindow(struct HWND__ *,int)&quot; (?ShowWindow@@$$J18YGHPAUHWND__@@H@Z) referenced in function &quot;extern &quot;C&quot; int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)&quot; (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z)<br />
main.obj : error LNK2019: unresolved external symbol &quot;extern &quot;C&quot; struct HWND__ * __stdcall CreateWindowExA(unsigned long,char const *,char const *,unsigned long,int,int,int,int,struct HWND__ *,struct HMENU__ *,struct HINSTANCE__ *,void *)&quot; (?CreateWindowExA@@$$J248YGPAUHWND__@@KPBD0KHHHHPAU1@PAUHMENU__@@PAUHINSTANCE__@@PAX@Z) referenced in function &quot;extern &quot;C&quot; int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)&quot; (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z)<br />
main.obj : error LNK2019: unresolved external symbol &quot;extern &quot;C&quot; int __stdcall MessageBoxA(struct HWND__ *,char const *,char const *,unsigned int)&quot; (?MessageBoxA@@$$J216YGHPAUHWND__@@PBD1I@Z) referenced in function &quot;extern &quot;C&quot; int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)&quot; (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z)<br />
main.obj : error LNK2019: unresolved external symbol &quot;extern &quot;C&quot; unsigned short __stdcall RegisterClassExA(struct tagWNDCLASSEXA const *)&quot; (?RegisterClassExA@@$$J14YGGPBUtagWNDCLASSEXA@@@Z) referenced in function &quot;extern &quot;C&quot; int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)&quot; (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z)<br />
main.obj : error LNK2019: unresolved external symbol &quot;extern &quot;C&quot; struct HICON__ * __stdcall LoadCursorA(struct HINSTANCE__ *,char const *)&quot; (?LoadCursorA@@$$J18YGPAUHICON__@@PAUHINSTANCE__@@PBD@Z) referenced in function &quot;extern &quot;C&quot; int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)&quot; (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z)<br />
main.obj : error LNK2019: unresolved external symbol &quot;extern &quot;C&quot; struct HICON__ * __stdcall LoadIconA(struct HINSTANCE__ *,char const *)&quot; (?LoadIconA@@$$J18YGPAUHICON__@@PAUHINSTANCE__@@PBD@Z) referenced in function &quot;extern &quot;C&quot; int __stdcall WinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)&quot; (?WinMain@@$$J216YGHPAUHINSTANCE__@@0PADH@Z)<br />
C:\development\TibiaTimer\TibiaTimer\Debug\TibiaTimer.exe : fatal error LNK1120: 26 unresolved externals<br />
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========  <hr /> </td> </tr> </table> </div>I wanted to attach a zip file but I wasn't allowed :P maybe the file was to big.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>FrozenSnake</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240032.html</guid>
		</item>
		<item>
			<title>Converting wav file to text format  and vice versa</title>
			<link>http://www.daniweb.com/forums/thread240025.html</link>
			<pubDate>Fri, 20 Nov 2009 14:36:35 GMT</pubDate>
			<description>Hey all  
 
I need to convert audio file of wav format into text file in order to feed it as input to an encryption algorithm(IBE encrypt method of Miracl (http://www.shamus.ie/) library takes only texts as input) and have to reconvert the decrypted text file to audio format. 
 
Could you please...</description>
			<content:encoded><![CDATA[<div>Hey all <br />
<br />
I need to convert audio file of wav format into text file in order to feed it as input to an encryption algorithm(IBE encrypt method of <a rel="nofollow" class="t" href="http://www.shamus.ie/" target="_blank">Miracl</a> library takes only texts as input) and have to reconvert the decrypted text file to audio format.<br />
<br />
Could you please suggest me a way to accomplish this. I have rest of my code written in C++.<br />
<br />
regards <br />
bk</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>bkpally263</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240025.html</guid>
		</item>
		<item>
			<title>code tags....</title>
			<link>http://www.daniweb.com/forums/thread240024.html</link>
			<pubDate>Fri, 20 Nov 2009 14:28:36 GMT</pubDate>
			<description><![CDATA[I wonder if anyone can tell me how the code tags works? As per my understanding does it works like:   <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox" title="Help...]]></description>
			<content:encoded><![CDATA[<div>I wonder if anyone can tell me how the code tags works? As per my understanding does it works like:  <pre style="margin:20px; line-height:13px">MY CODE HERE.....</pre> for the enitre block of code? or I need to do this for every line of code?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>maverick405</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240024.html</guid>
		</item>
		<item>
			<title>Help In Structures !!!</title>
			<link>http://www.daniweb.com/forums/thread240015.html</link>
			<pubDate>Fri, 20 Nov 2009 13:41:29 GMT</pubDate>
			<description><![CDATA[Hello All ,This is me again :icon_mrgreen: 
 
I'm Making a programme which tell the user to input the name 
of the product he wants to show its Price and Amount ,but i have a problem: 
 
Here's The Code 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a...]]></description>
			<content:encoded><![CDATA[<div>Hello All ,This is me again :icon_mrgreen:<br />
<br />
I'm Making a programme which tell the user to input the name<br />
of the product he wants to show its Price and Amount ,but i have a problem:<br />
<br />
Here's The Code<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
#include &lt;conio.h&gt;<br />
using namespace std;<br />
<br />
struct Shop<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; int Price;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int Amount;<br />
};<br />
<br />
void PrintPrice (Shop Product);<br />
void PrintAmount (Shop Product);<br />
<br />
int main()<br />
{<br />
//For Input:<br />
&nbsp; &nbsp; &nbsp; &nbsp; Shop FI;<br />
<br />
//Products:<br />
&nbsp; &nbsp; &nbsp; &nbsp; Shop Apple;<br />
&nbsp; &nbsp; &nbsp; &nbsp; Shop Banana;<br />
&nbsp; &nbsp; &nbsp; &nbsp; Shop Orange;<br />
<br />
//Prices:<br />
&nbsp; &nbsp; &nbsp; &nbsp; Apple.Price = 3;<br />
&nbsp; &nbsp; &nbsp; &nbsp; Banana.Price = 5;<br />
&nbsp; &nbsp; &nbsp; &nbsp; Orange.Price = 7;<br />
<br />
//Amounts:<br />
&nbsp; &nbsp; &nbsp; &nbsp; Apple.Amount = 5;<br />
&nbsp; &nbsp; &nbsp; &nbsp; Banana.Amount = 10;<br />
&nbsp; &nbsp; &nbsp; &nbsp; Orange.Amount = 15;<br />
<br />
//Programme:<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Enter The Product's Name: &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; FI;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; PrintPrice(FI);<br />
&nbsp; &nbsp; &nbsp; &nbsp; PrintAmount(FI);<br />
<br />
//End Of Programme:<br />
&nbsp; &nbsp; &nbsp; &nbsp; getch();<br />
&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
}<br />
<br />
void PrintPrice (Shop Product)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;The Price Is: &quot; &lt;&lt; Product.Price &lt;&lt;endl;<br />
}<br />
<br />
void PrintAmount (Shop Product)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;The Amount Is: &quot; &lt;&lt; Product.Amount;<br />
}</pre><br />
I Know This Is Wrong:<br />
 <pre style="margin:20px; line-height:13px">cin &gt;&gt; FI;</pre>so what can it be replaced by?<br />
Hope you got it...</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>kim00000</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240015.html</guid>
		</item>
		<item>
			<title>Even Number Program</title>
			<link>http://www.daniweb.com/forums/thread240007.html</link>
			<pubDate>Fri, 20 Nov 2009 12:49:33 GMT</pubDate>
			<description>I wrote this program which takes the value from the user and makes it into a even number if the number entered was odd, if not then print out a message to say they need to enter a odd number. But the program continues to return a value from the makeEven function even though I just want it to print...</description>
			<content:encoded><![CDATA[<div>I wrote this program which takes the value from the user and makes it into a even number if the number entered was odd, if not then print out a message to say they need to enter a odd number. But the program continues to return a value from the makeEven function even though I just want it to print out the message saying enter an odd number.<br />
<br />
I'm relatively new to C++ and just cant get my head around where it is getting the value it happens to print out.<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
<br />
using namespace std;<br />
<br />
int makeEven(int x)<br />
{ <br />
&nbsp; &nbsp; &nbsp; &nbsp; if ( x % 2 != 0 ) <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return x-1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;Please enter an odd number!&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; goto /*line*/ 18;<br />
}<br />
<br />
int main()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; int x;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Please enter an integer: &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; x;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Your number is now: &quot; &lt;&lt; makeEven(x) &lt;&lt;endl; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
};</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>nedsnurb</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240007.html</guid>
		</item>
		<item>
			<title>Multiple Funcs passed to text file</title>
			<link>http://www.daniweb.com/forums/thread240001.html</link>
			<pubDate>Fri, 20 Nov 2009 12:01:02 GMT</pubDate>
			<description>Hi there, 
 
I am trying to make a program, as shown below.  I have used a snippet with hello and bye as the program is really very big.  Unfortunately I am unable to edit these functions as they are all part of a complex linked list. 
 
I am trying to pass both functions from the class CWrite into...</description>
			<content:encoded><![CDATA[<div>Hi there,<br />
<br />
I am trying to make a program, as shown below.  I have used a snippet with hello and bye as the program is really very big.  Unfortunately I am unable to edit these functions as they are all part of a complex linked list.<br />
<br />
I am trying to pass both functions from the class CWrite into a text file however what currently occurs is the second function overwrites the first function (i think).  I have genuinly no idea what to do to solve this.<br />
<br />
Any help fixing this would be greatly appreciated. <br />
<br />
 <pre style="margin:20px; line-height:13px">#inlcude &lt;iostream&gt;<br />
#include &lt;fstream&gt;<br />
#include &lt;sstream&gt;<br />
<br />
class CWrite<br />
{<br />
public:<br />
&nbsp; &nbsp; &nbsp; &nbsp; int write(std::string name);<br />
&nbsp; &nbsp; &nbsp; &nbsp; int write(std::string name);<br />
};<br />
<br />
#include “stdafx.h”<br />
#include “output.h”<br />
<br />
int CWrite::write(std::string name)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; std::ofstream output(name.c_str());<br />
&nbsp; &nbsp; &nbsp; &nbsp; output&lt;&lt;”HELLO”&lt;&lt;std::endl;<br />
output.close();<br />
return 0;<br />
}<br />
<br />
int CWrite::write(std::string name)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; std::ofstream output(name.c_str());<br />
&nbsp; &nbsp; &nbsp; &nbsp; output&lt;&lt;”HELLO”&lt;&lt;std::endl;<br />
output.close();<br />
return 0;<br />
}<br />
<br />
Private: System::Void ButOut_Click(System::object^ sneder, System::eventArgs^ e)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; SaveFileDialog ^ saveFileDialog1 = gcnew SaveFileDialog();<br />
&nbsp; &nbsp; &nbsp; &nbsp; savefileDialog1-&gt;Filter = “txt files (*.txt)|*.txt|All files (*.*)|*.*”;<br />
&nbsp; &nbsp; &nbsp; &nbsp; saveFileDialog1-&gt;InitialDirectory = “library”;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; if(saveFileDialog1-&gt;ShowDialog() == System::Windows::Forms::DialogResult::Ok)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CWrite a;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; std::string std_name = SystemToStdString(saveFileDialog1-&gt;FileName);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int success = a.write(std_name) + a.writeSDF(std_name);<br />
}</pre><br />
Please ignore any syntax errors as the code had to be written from Word.<br />
<br />
Thanks in advance, <br />
<br />
Andy</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>ab00120</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread240001.html</guid>
		</item>
		<item>
			<title>Errors in my code (using arrays)</title>
			<link>http://www.daniweb.com/forums/thread239997.html</link>
			<pubDate>Fri, 20 Nov 2009 11:26:35 GMT</pubDate>
			<description><![CDATA[Hello everyone; 
 
I did a program using arrays -for the first time- 
 
I've got errors, I fixed some and there are others left that I couldn't straighten  
 
any help is highly appreciated  
 
here is the code :]]></description>
			<content:encoded><![CDATA[<div>Hello everyone;<br />
<br />
I did a program using arrays -for the first time-<br />
<br />
I've got errors, I fixed some and there are others left that I couldn't straighten <br />
<br />
any help is highly appreciated <br />
<br />
here is the code :<br />
<br />
 <pre style="margin:20px; line-height:13px"># include &lt;iostream&gt;<br />
# include &lt;iomanip&gt;<br />
using namespace std;<br />
<br />
int read_car (int cars[], int n);<br />
double read_time (double time[], int n);<br />
double charge (time[]);<br />
void print ();<br />
<br />
double sum_time, sum_charge;<br />
<br />
int main()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; int time;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int cars[n];<br />
&nbsp; &nbsp; &nbsp; &nbsp; int n;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Welcome to the Car Parking fee calculater.&quot; &lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Please enter the numbers of the cars.&quot; &lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; n;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; read_car (cars,n);<br />
&nbsp; &nbsp; &nbsp; &nbsp; read_time(time,n);<br />
&nbsp; &nbsp; &nbsp; &nbsp; charge(time,n);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; print ();<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
}<br />
<br />
<br />
<br />
<br />
<br />
//1<br />
<br />
int read_car (int cars[], int n)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; int i;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (i=1; i&lt;=n; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; cars[i];<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; return cars;<br />
}<br />
<br />
//2<br />
double read_time (double time[], int n)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; int i;<br />
&nbsp; &nbsp; &nbsp; &nbsp; sum=0;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (i=1; i&lt;=n; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; time[i];<br />
&nbsp; &nbsp; &nbsp; &nbsp; time[i] = ceil(time);<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; sum_time= sum + time;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; return time;<br />
}<br />
//3<br />
double charge (double time[],int n)<br />
&nbsp; &nbsp; &nbsp; &nbsp; { <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; double charge;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; double sum=0;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for ( int i=1; i&lt;=n; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (time &lt;= 3.00)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; charge= 2.00;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (time == 24.0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; charge = 10.0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; charge = (time - 3)*0.5 + 2.00;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sum_charge= sum+charge;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return charge;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
}<br />
<br />
//4<br />
void print (n)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; left;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; setw(6) &lt;&lt;&quot;Car&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; setw(6) &lt;&lt;&quot;Hours&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; setw(6) &lt;&lt;&quot;Charge&quot; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt;&quot;__________________&quot;&lt;&lt;endl;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (i=1; i&lt;=n; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; setw(6) &lt;&lt; i<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; setw(6) &lt;&lt; time[i]<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; setw(6) &lt;&lt; charge (time,n)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt;&quot;__________________&quot;&lt;&lt;endl;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; setw(6) &lt;&lt;&quot;Total&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; setw(6) &lt;&lt; sum_time<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; setw(6) &lt;&lt; sum_charge<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt;endl;<br />
<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>new programer</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239997.html</guid>
		</item>
		<item>
			<title>C++ recursive function (very simple one)</title>
			<link>http://www.daniweb.com/forums/thread239964.html</link>
			<pubDate>Fri, 20 Nov 2009 08:43:52 GMT</pubDate>
			<description>How do I write a recursive function in C++ to display a triangle of * like this using a parameter size (e.g. 4 in the following example): 
 
* 
** 
*** 
**** 
 
I am able to write a recursive function to display an inverted triangle like this: 
 
****</description>
			<content:encoded><![CDATA[<div>How do I write a recursive function in C++ to display a triangle of * like this using a parameter size (e.g. 4 in the following example):<br />
<br />
*<br />
**<br />
***<br />
****<br />
<br />
I am able to write a recursive function to display an inverted triangle like this:<br />
<br />
****<br />
***<br />
**<br />
*<br />
<br />
The code for the inverted triangle function is:<br />
<br />
 <pre style="margin:20px; line-height:13px">void inverted(int a)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (a==1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;*&quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int i=0; i&lt;a; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;*&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inverted(a-1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}</pre><br />
I am allowed to use a loop (e.g. for loop) to print a row of * but I <span style="font-style:italic">must</span> use a recursive function to control the number of rows.<br />
<br />
Please, provide some insight into the problem. I need it to work urgently but I am not able to figure out a solution.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>codeyy</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239964.html</guid>
		</item>
		<item>
			<title>How To Bubble Sort</title>
			<link>http://www.daniweb.com/forums/thread239950.html</link>
			<pubDate>Fri, 20 Nov 2009 07:39:30 GMT</pubDate>
			<description>Can someone please explain the concept behind bubble sorting a vector step by step? I know this is a tedious task so whoever answers I will much appreciate it! :)  
 
Questions: 
 
1.) What variables are being used? 
2.) How and where is the function placed? 
3.) Where and why are the for loops?...</description>
			<content:encoded><![CDATA[<div>Can someone please explain the concept behind bubble sorting a vector step by step? I know this is a tedious task so whoever answers I will much appreciate it! :) <br />
<br />
Questions:<br />
<br />
1.) What variables are being used?<br />
2.) How and where is the function placed?<br />
3.) Where and why are the for loops?<br />
4.) Step by step procedure in example of vector bubble sort.<br />
<br />
THANK YOU!</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>EngneerNitemare</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239950.html</guid>
		</item>
		<item>
			<title>Revrse String</title>
			<link>http://www.daniweb.com/forums/thread239942.html</link>
			<pubDate>Fri, 20 Nov 2009 06:27:12 GMT</pubDate>
			<description><![CDATA[The code below runs fine but I want some help how can I get output of my original input and reverse of that  i.e. ABCDE Z. WXYZ ---> EDCBA .Z ZYXW The below is the code for this. 
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a...]]></description>
			<content:encoded><![CDATA[<div>The code below runs fine but I want some help how can I get output of my original input and reverse of that  i.e. ABCDE Z. WXYZ ---&gt; EDCBA .Z ZYXW The below is the code for this.<br />
<br />
 <pre style="margin:20px; line-height:13px"> <br />
#include &lt;iostream&gt;<br />
#include &lt;cstring&gt;<br />
<br />
using namespace std;<br />
void swap(char&amp; a, char&amp; b)<br />
{<br />
&nbsp; char tmp = a;<br />
&nbsp; a = b;<br />
&nbsp; b = tmp;<br />
}<br />
int main()<br />
{<br />
&nbsp; char name[19] = &quot;ABCDE Z. WXYX&quot;;<br />
&nbsp; int a = -1, b = -1;<br />
&nbsp; int nameLength = strlen(name);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  for (int i = 0; i &lt;= nameLength; ++i)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  if (i == nameLength || name[i] == ' ')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  b = i;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  for (int j = 0; j &lt; (b - a) / 2; ++j)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  swap(name[j + a], name[b - j - 1]);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  a = b + 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  if (a == -1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  a = i;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; name &lt;&lt;&quot;\n&quot;;<br />
<br />
&nbsp;  system(&quot;PAUSE&quot;);<br />
&nbsp;  return EXIT_SUCCESS;<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>maverick405</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239942.html</guid>
		</item>
		<item>
			<title>Arrays and Strings</title>
			<link>http://www.daniweb.com/forums/thread239941.html</link>
			<pubDate>Fri, 20 Nov 2009 06:26:11 GMT</pubDate>
			<description><![CDATA[I have been writing a program using arrays and strings.Here is my  question. 
A class of students takes a 20 question multiple-choice exam;each question has 5 choices(a,b,c,d,e)only one of them are correct.In "tests.dat"Each record of which consists of a student id, followed by a blank, followed by...]]></description>
			<content:encoded><![CDATA[<div>I have been writing a program using arrays and strings.Here is my  question.<br />
A class of students takes a 20 question multiple-choice exam;each question has 5 choices(a,b,c,d,e)only one of them are correct.In &quot;tests.dat&quot;Each record of which consists of a student id, followed by a blank, followed by students 20 responses. In &quot;answers.dat&quot; which consists of a single record, namely the correct answers to the exam.Then It needs to produce a grade summary report like this.If the answer is correct it should put a &quot;*&quot; by the correct answer<br />
<br />
<br />
student-id number correct<br />
1231231212312       12<br />
1233424325435        25<br />
....                              ..<br />
<br />
<br />
<br />
<br />
<br />
<br />
question A   B    C    D   E<br />
1            5   1    13* 3   1<br />
2            4   7*   5   12  7<br />
.<br />
.<br />
...<br />
<br />
<br />
<br />
this is what i got so far.Thank you<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;fstream&gt;<br />
#include &lt;iostream&gt;<br />
#include &lt;string&gt;<br />
#include &lt;cstdlib&gt;<br />
<br />
using namespace std;<br />
int question[20][5];<br />
int main()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; ifstream fanswers, fcorrect_keys;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; char correct_keys[21];<br />
&nbsp; &nbsp; &nbsp; &nbsp; char student_id[100][12], answers[100][21];<br />
&nbsp; &nbsp; &nbsp; &nbsp; char id_buf[12], answers_buf[21];<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; int student_count = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; fcorrect_keys.open(&quot;Answers.dat&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; while(!fcorrect_keys.eof())&nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fcorrect_keys &gt;&gt; answers_buf;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strcpy(correct_keys, answers_buf);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
//&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; correct_keys &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; fcorrect_keys.close();<br />
&nbsp; &nbsp; &nbsp; &nbsp; fanswers.open(&quot;Tests.dat&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; while(!fanswers.eof())&nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fanswers &gt;&gt; id_buf &gt;&gt; answers_buf;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strcpy(student_id[student_count], id_buf);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strcpy(answers[student_count],answers_buf);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; student_count++;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
//&nbsp; &nbsp; &nbsp; &nbsp; for(int i=0; i &lt; student_count;i++)<br />
//&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; student_id[i] &lt;&lt; &quot;&nbsp; &quot; &lt;&lt; answers[i] &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fanswers.close();// close the file&nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot; student_id&nbsp; &nbsp; &nbsp; number_correct&quot; &lt;&lt; endl &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; for(int i = 0; i &lt; student_count; i++)&nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int correct_count = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(int j = 0; j &lt; 20; j++)&nbsp; { <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (answers [i][j] == correct_keys[j])<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; correct_count++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; question[j][answers[i][j] - 'A']++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;%11.11s&nbsp; &nbsp; &nbsp; &nbsp;  %2d\n&quot;, student_id[i],correct_count);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; endl &lt;&lt; endl &lt;&lt; endl &lt;&lt; &quot;Number of students taking exam : &quot; &lt;&lt; student_count &lt;&lt; endl; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\nquestion&nbsp; &nbsp;  A&nbsp; &nbsp; B&nbsp; &nbsp; C&nbsp; &nbsp; D&nbsp; &nbsp; E\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; for(int k = 0; k &lt; 20 ; k++)&nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;&nbsp;  %2d&nbsp; &nbsp; &nbsp; &quot;,1+k);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(int l=0;l &lt; 5; l++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot; %2d%c &quot;, question[k][l], (l == (correct_keys[k] - 'A') ? '*' : ' '));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>thebeast91</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239941.html</guid>
		</item>
		<item>
			<title>DirectX 9 3D Models</title>
			<link>http://www.daniweb.com/forums/thread239938.html</link>
			<pubDate>Fri, 20 Nov 2009 06:19:44 GMT</pubDate>
			<description>How do I load 3D models that are in the .x format from DirectX 9? 
I am trying to make a simple engine and this is the part where I am stuck at.</description>
			<content:encoded><![CDATA[<div>How do I load 3D models that are in the .x format from DirectX 9?<br />
I am trying to make a simple engine and this is the part where I am stuck at.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>tomtetlaw</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239938.html</guid>
		</item>
		<item>
			<title>factory design or shared laibrary</title>
			<link>http://www.daniweb.com/forums/thread239924.html</link>
			<pubDate>Fri, 20 Nov 2009 05:14:03 GMT</pubDate>
			<description>Hi, 
 
some time back i faced question like this. 
we ca use factory design using factory desing implementation. we can do the same using the shared laibrary, like we will have  a static function in the shared laibrary which will be returning pointer to base class object. what is the difference...</description>
			<content:encoded><![CDATA[<div>Hi,<br />
<br />
some time back i faced question like this.<br />
we ca use factory design using factory desing implementation. we can do the same using the shared laibrary, like we will have  a static function in the shared laibrary which will be returning pointer to base class object. what is the difference between these two ?<br />
<br />
i hope u people got my question.<br />
</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>tarakant_sethy</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239924.html</guid>
		</item>
		<item>
			<title>Bad parameter: A bad object array</title>
			<link>http://www.daniweb.com/forums/thread239915.html</link>
			<pubDate>Fri, 20 Nov 2009 04:19:57 GMT</pubDate>
			<description><![CDATA[Hello All, 
  I am creating the array of size: 26627664 bytes then convert the byte to char array. 
  While deleting the array i got an code gaurd log error that Bad Parameter. 
 
I am doing like this 
Char* pBuffer = (Char*)new BYTE[26627664]; 
 
and deleting like this, 
if(pBuffer != NULL) 
     ...]]></description>
			<content:encoded><![CDATA[<div>Hello All,<br />
  I am creating the array of size: 26627664 bytes then convert the byte to char array.<br />
  While deleting the array i got an code gaurd log error that Bad Parameter.<br />
<br />
I am doing like this<br />
Char* pBuffer = (Char*)new BYTE[26627664];<br />
<br />
and deleting like this,<br />
if(pBuffer != NULL)<br />
            delete[] pBuffer;<br />
facing the problem<br />
Please Help.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>SagarSonu</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239915.html</guid>
		</item>
		<item>
			<title>Help!!!!!</title>
			<link>http://www.daniweb.com/forums/thread239895.html</link>
			<pubDate>Fri, 20 Nov 2009 03:01:28 GMT</pubDate>
			<description><![CDATA[// I am new to C++ and can not seem to get the falling man to output to the screen. Any help would be greatly appreciated. 
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680"...]]></description>
			<content:encoded><![CDATA[<div>// I am new to C++ and can not seem to get the falling man to output to the screen. Any help would be greatly appreciated.<br />
<br />
 <pre style="margin:20px; line-height:13px">&nbsp; &nbsp; #include &lt;iostream&gt;<br />
&nbsp; &nbsp; #include &lt;windows.h&gt;<br />
&nbsp; &nbsp; using namespace std;<br />
&nbsp; &nbsp;  <br />
&nbsp; &nbsp; void DrawBar(char guess);<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; int main()<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; char solution[8]; //holds solution<br />
&nbsp; &nbsp; &nbsp; &nbsp; char blank[8]; //holds &quot;*&quot;'s for unsolved letters<br />
&nbsp; &nbsp; &nbsp; &nbsp; int counter = 0; //general-use counter<br />
&nbsp; &nbsp; &nbsp; &nbsp; int right = 0; //1 = right guess, 0 = wrong guess.<br />
&nbsp; &nbsp; &nbsp; &nbsp; char guess;<br />
&nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;Enter phrase 8 chars or less.&quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cin.getline(solution, 8);<br />
&nbsp; &nbsp; &nbsp; &nbsp; int puzzLength = strlen(solution); //finds lengtrh of puzzle, stores INT value to puzzlength<br />
&nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; //convert puzzle to full uppercase<br />
&nbsp; &nbsp; for (counter = 0; counter &lt; puzzLength; counter++){<br />
&nbsp; &nbsp; &nbsp;  solution[counter] = toupper(solution[counter]);<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; //done converting<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; strcpy_s(blank, solution); //copy solution to the 'blank' array<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; for (counter = 0; counter &lt; puzzLength; counter++) { //converts characters to _'s to represent blanks<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp;  if (isalnum(solution[counter])) blank[counter] = '_';<br />
&nbsp;<br />
&nbsp; &nbsp; &nbsp;  else blank[counter] = solution[counter];<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; } //closes for loop<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; while (strcmp(solution, blank)) { //play game until the 'blank' puzzle becomes the 'right' answer<br />
&nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; cout&lt;&lt;endl&lt;&lt;&quot;Solution phrase is: &quot;&lt;&lt;solution&lt;&lt;&quot;.&quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; cout&lt;&lt;&quot;The current 'blank' puzzle is: &quot;&lt;&lt;blank&lt;&lt;&quot;.&quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; cout&lt;&lt;&quot;Enter a guess.&quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; cin&gt;&gt;guess;<br />
&nbsp; &nbsp; guess = toupper(guess);<br />
&nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; //cbeck guess!<br />
&nbsp; &nbsp; for (counter = 0; counter &lt;= puzzLength; counter++) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; if (guess == solution[counter]) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; blank[counter] = guess; //fill in the puzzle with the letter<br />
&nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; } //close loop, done checking guess<br />
&nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; } //game is over.<br />
&nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;Winner!&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cin.get();<br />
&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
&nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
//DrawBar(guess);&nbsp; &nbsp; &nbsp; &nbsp; //Draw the hanging bar at end of game<br />
&nbsp; &nbsp; &nbsp; &nbsp; //They lost if they are here so tell them the answer.<br />
&nbsp; &nbsp; &nbsp; &nbsp; //cout&lt;&lt;&quot;The word was : &quot;&lt;&lt;Words[Word]&lt;&lt;endl&lt;&lt;endl;&nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
<br />
<br />
// This will Draw the hanging bar according to the state<br />
void DrawBar(char guess)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; if(guess==5)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;endl&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  +--------+&nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp; 0&nbsp; &nbsp; &nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp;  /|\\&nbsp; &nbsp;  &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp;  / \\&nbsp; &nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  | AAHHH!!!&nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp; ============&quot;&lt;&lt;endl&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Sleep(500); // Message Sleep for 1 second<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;endl&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  +--------+&nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp; 0&nbsp; &nbsp;  &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp;  /|\\&nbsp;  &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp;  / \\&nbsp; &nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  | AAHHH!!!&nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp; ============&quot;&lt;&lt;endl&lt;&lt;endl;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Sleep(500); // Message Sleep for 1 second<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;endl&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  +--------+&nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp;  0&nbsp; &nbsp; &nbsp; &nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; /|\\&nbsp; &nbsp; &nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  | AAHHH!!!&nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp; ============&quot;&lt;&lt;endl&lt;&lt;endl; <br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Sleep(500); // Message Sleep for 1 second<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;endl&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  +--------+&nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp;  0&nbsp; &nbsp; &nbsp;  &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  | AAHHH!!!&nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp; ============&quot;&lt;&lt;endl&lt;&lt;endl; <br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Sleep(500); // Message Sleep for 1 second<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;endl&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  +--------+&nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  | AAHHH!!!&nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp; ============&quot;&lt;&lt;endl&lt;&lt;endl; <br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; else if(guess==4)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;endl&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  +---------+&nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp; \\0&nbsp; &nbsp;  &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp;  |\\&nbsp; &nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp; / \\&nbsp; &nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp; =============&quot;&lt;&lt;endl&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; else if(guess==3)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;endl&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  +----------+&nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp; \\0/&nbsp; &nbsp;  &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp;  |&nbsp; &nbsp; &nbsp;  &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp; / \\&nbsp; &nbsp;  &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp; =============&quot;&lt;&lt;endl&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; else if(guess==2)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;endl&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  +-----------+&nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; 0_:__:&nbsp; &nbsp; &nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp; &nbsp;  \\&nbsp; &nbsp;  &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp; =============&quot;&lt;&lt;endl&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; else if(guess==1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;endl&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  +-----------+&nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; 0_:__:&nbsp; &nbsp;  &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp;  |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;&lt;&lt;endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&nbsp; =============&quot;&lt;&lt;endl&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>KRal</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239895.html</guid>
		</item>
		<item>
			<title>Segmentation fault. help plz!</title>
			<link>http://www.daniweb.com/forums/thread239890.html</link>
			<pubDate>Fri, 20 Nov 2009 01:45:50 GMT</pubDate>
			<description>So i need help figurin out where my segmentation fault is comin from. Im not even close to finishing this program but i was just testing my progress so far to make sure that it was taking values correctly, but sometimes the program doesnt stop when its supposed to and when it does i get a...</description>
			<content:encoded><![CDATA[<div>So i need help figurin out where my segmentation fault is comin from. Im not even close to finishing this program but i was just testing my progress so far to make sure that it was taking values correctly, but sometimes the program doesnt stop when its supposed to and when it does i get a segmentation fault at the end, even if it works the way i want it to.<br />
<br />
heres the code:<br />
<br />
 <pre style="margin:20px; line-height:13px">#include&lt;iostream&gt;<br />
using namespace std;<br />
<br />
class Heapsort<br />
{<br />
&nbsp; private:<br />
&nbsp; &nbsp;  int mylist[];<br />
&nbsp; &nbsp;  int mysize;<br />
&nbsp; public:<br />
&nbsp; &nbsp;  void get_size();<br />
&nbsp; &nbsp;  bool empty();<br />
&nbsp; &nbsp;  void sort();<br />
&nbsp; &nbsp;  void fill_array();<br />
&nbsp; &nbsp;  void print(int);<br />
};<br />
<br />
<br />
void Heapsort::get_size()<br />
{<br />
&nbsp;  cout &lt;&lt;endl&lt;&lt;&quot;Please enter the size of the array you want to sort: &quot;;<br />
&nbsp;  cin &gt;&gt; mysize;<br />
&nbsp;  int mylist[mysize];<br />
}<br />
<br />
void Heapsort::fill_array()<br />
{<br />
&nbsp; &nbsp; int i;<br />
&nbsp; &nbsp; int num;<br />
<br />
&nbsp; &nbsp; for (i=0; i &lt; mysize; i++){<br />
&nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;Enter a number 1-100: &quot;;<br />
&nbsp; &nbsp; &nbsp;  cin &gt;&gt; num;<br />
&nbsp; &nbsp; &nbsp;  if ((num &lt; 1)||(num &gt; 100)){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;\n\nEnter a correct number please.\n\n&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  i = i - 1;<br />
&nbsp; &nbsp; &nbsp;  } else {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  mylist[i] = num;<br />
&nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; }<br />
}<br />
<br />
<br />
int main()<br />
{<br />
&nbsp; Heapsort heap;<br />
<br />
&nbsp; heap.get_size();<br />
<br />
&nbsp; cout &lt;&lt; endl &lt;&lt; endl;<br />
<br />
&nbsp; heap.fill_array();<br />
<br />
&nbsp; cout &lt;&lt; endl &lt;&lt; endl;<br />
&nbsp; &nbsp; <br />
&nbsp; return (0);<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>bigmaq</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239890.html</guid>
		</item>
		<item>
			<title>Tic-Tac-DOH!!</title>
			<link>http://www.daniweb.com/forums/thread239880.html</link>
			<pubDate>Fri, 20 Nov 2009 01:18:51 GMT</pubDate>
			<description>Here is my assignment.   
5.	Assignment:  Using the code given below develop a solution to the game Tic-Tac-Toe. 
a.	The game is played between a human user and the computer.  The computer’s moves are made randomly.  You must get 3-in-a-row to win; getting five of the nine squares is a tie game.  ...</description>
			<content:encoded><![CDATA[<div>Here is my assignment.  <br />
5.	Assignment:  Using the code given below develop a solution to the game Tic-Tac-Toe.<br />
a.	The game is played between a human user and the computer.  The computer’s moves are made randomly.  You must get 3-in-a-row to win; getting five of the nine squares is a tie game.  <br />
b.	Use proper designing strategies. All input and output should be done in a single module (I/O should not be done in strategy modules).  Have an introduction screen that explains how to play the game, let the user know the computer’s move at each turn, and have an ending screen announcing the winner.<br />
6.	Complete all function stubs and correct the logic of the main() to obtain a working program.<br />
<br />
The starting code;<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
#include &lt;ctime&gt;<br />
using namespace std; <br />
//Purpose: Prints to the screen the an introduction and <br />
// provides the rules of the game<br />
//Input: None<br />
//Output: None<br />
void Intro()&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
{<br />
}<br />
//Purpose: allows the computer to make a move<br />
//Input: B[][] a 2 dimensional array that represents the board<br />
//Output: B[][], the board that has been updated with the computer's move <br />
void ComputerMove(char B[][3])&nbsp; &nbsp;  <br />
{ int i=0, turn=0;&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;\n IN COMPUTER MOVE \n&quot;;<br />
&nbsp;//while (turn==0)&nbsp; &nbsp;  //Make sure the move is ok<br />
&nbsp; &nbsp; &nbsp; { <br />
&nbsp; &nbsp; &nbsp; i=rand()%9+1;&nbsp; &nbsp;  //randomize a move<br />
&nbsp; &nbsp; &nbsp; if (i==1)&nbsp; &nbsp; &nbsp; // make sure the first location is not taken<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ((B[0][0]!='x')&amp;&amp;(B[0][0]!='o'))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp;  B[0][0]='o';&nbsp; //if not taken, then move<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; turn=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; /*********<br />
&nbsp; &nbsp; &nbsp; repeat the above check for all locations<br />
&nbsp; &nbsp; &nbsp; ***********/<br />
&nbsp; &nbsp; &nbsp; }<br />
}<br />
<br />
<br />
<br />
<br />
<br />
//Purpose: allows the user to make a move<br />
//Input: B[][] a 2 dimensional array that represents the board<br />
//Output: B[][], the board that has been updated with the human's move <br />
void HumanMove(char B[][3]) <br />
{int i=0, turn=0;<br />
cout&lt;&lt;&quot;\n IN HUMAN MOVE \n&quot;;<br />
/*************<br />
// the logic is similar to the computer move except that <br />
// it takes the location from the keyboard<br />
****************/<br />
}<br />
//Purpose: Print out the board<br />
//Input: B[][] a 2 dimensional array that represents the board<br />
//Output: None<br />
void PrintBoard(char B[][3]) <br />
{&nbsp; &nbsp;  cout&lt;&lt;&quot;\n&nbsp;  &quot;&lt;&lt;B[0][0]&lt;&lt;&quot;|&nbsp;  &quot;&lt;&lt;B[0][1]&lt;&lt;&quot;|&nbsp;  &quot;&lt;&lt;B[0][2];&nbsp;  <br />
&nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;\n_________________&quot;;<br />
&nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;\n&nbsp;  &quot;&lt;&lt;B[1][0]&lt;&lt;&quot;|&nbsp;  &quot;&lt;&lt;B[1][1]&lt;&lt;&quot;|&nbsp;  &quot;&lt;&lt;B[1][2];<br />
&nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;\n_________________&quot;;<br />
&nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;\n&nbsp;  &quot;&lt;&lt;B[2][0]&lt;&lt;&quot;|&nbsp;  &quot;&lt;&lt;B[2][1]&lt;&lt;&quot;|&nbsp;  &quot;&lt;&lt;B[2][2];<br />
&nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;\n\n&quot;;<br />
}<br />
//Purpose: Check for a winner<br />
//Input: B[][] a 2 dimensional array that represents the board<br />
//Output: win and integer indicating winner status. <br />
//&nbsp; &nbsp; &nbsp;  0=no winner, 1= human winner, 2= computer winner<br />
int CheckWin(char B[][3])<br />
{&nbsp; &nbsp;  int win = 0;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;\n IN CHECK WIN &quot;&lt;&lt;win&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; return (win);<br />
}<br />
void main ()<br />
{int choice=0, done=0, t=0, w=0;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
char Board[3][3]={{'1','2','3'},{'4','5','6'},{'7','8','9'}};<br />
srand(time(0));<br />
Intro();<br />
PrintBoard(Board);<br />
cout&lt;&lt;&quot;Do you want to go first? Enter 1 for yes, 2 for no&quot;;<br />
cin&gt;&gt;choice;<br />
&nbsp; &nbsp; &nbsp; if (choice==1)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //if player wishes to go first<br />
&nbsp; &nbsp; &nbsp; { <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; do{ cout&lt;&lt;&quot;\n t = &quot;&lt;&lt;t&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HumanMove(Board);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; w=CheckWin(Board);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (w==1)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout&lt;&lt;&quot;Youwin!&quot;;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (w==2)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;You lose!&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (t==9&amp;&amp;w==0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;Tie Game&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PrintBoard(Board);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ComputerMove(Board);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; w=CheckWin(Board);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (w==1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;You Win!&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (w==2)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;You lose!&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (t==9&amp;&amp;w==0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;Tie Game&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PrintBoard(Board);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; t=t+1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }while((t!=9)||(w!=0));&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; else&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; do{&nbsp;  cout&lt;&lt;&quot;\n t = &quot;&lt;&lt;t&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ComputerMove(Board);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; w=CheckWin(Board);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  if(w==1)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;You Win!&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  else if (w==2)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;You lose!&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  else if (t==9&amp;&amp;w==0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;Tie Game&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PrintBoard(Board);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HumanMove(Board);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; w=CheckWin(Board);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (w==1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;You Win!&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (w==2)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;You lose!&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (t==9&amp;&amp;w==0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;Tie Game&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PrintBoard(Board);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; t=t+1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }while((t!=9)||(w!=0));&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; }<br />
}</pre><br />
I took this code did all the hard work below;<br />
<br />
 <pre style="margin:20px; line-height:13px">//Michelle Stokes CSI130 Lab 13<br />
//Code from hand out Lab14 TTT<br />
<br />
#include &lt;iostream&gt;<br />
#include &lt;ctime&gt;<br />
using namespace std; <br />
//Purpose: Prints to the screen the an introduction and <br />
// provides the rules of the game<br />
//Input: None<br />
//Output: None<br />
void Intro()&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;This game is played between a human user and the computer. \n&quot; &lt;&lt;&nbsp; &quot;The computers moves are made randomly. \n&quot; &lt;&lt;&nbsp; &quot;You must get 3-in-a-row to win; getting five of the nine squares is a tie game. \n&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;You player will be lower case 'x'.&nbsp; You will enter the number of the space you would like to play. \n&quot;;<br />
}<br />
//Purpose: allows the computer to make a move<br />
//Input: B[][] a 2 dimensional array that represents the board<br />
//Output: B[][], the board that has been updated with the computer's move <br />
void ComputerMove(char B[][3])&nbsp; &nbsp;  <br />
{ int i=0, turn=0;&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;\n IN COMPUTER MOVE \n&quot;;<br />
&nbsp;//while (turn==0)&nbsp; &nbsp;  //Make sure the move is ok<br />
&nbsp; &nbsp; &nbsp; { <br />
&nbsp; &nbsp; &nbsp; i=rand()%9+1;&nbsp; &nbsp;  //randomize a move<br />
&nbsp; &nbsp; &nbsp; if (i==1)&nbsp; &nbsp; &nbsp; // make sure the first location is not taken<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ((B[0][0]!='x')&amp;&amp;(B[0][0]!='o'))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp;  B[0][0]='o';&nbsp; //if not taken, then move<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; turn=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (i==2)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ((B[0][1]!='x')&amp;&amp;(B[0][1]!='o'))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp;  B[0][1]='o';&nbsp; //if not taken, then move<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; turn=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (i==3)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ((B[0][2]!='x')&amp;&amp;(B[0][2]!='o'))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp;  B[0][2]='o';&nbsp; //if not taken, then move<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; turn=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (i==4)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ((B[1][0]!='x')&amp;&amp;(B[1][0]!='o'))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp;  B[1][0]='o';&nbsp; //if not taken, then move<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; turn=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (i==5)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ((B[1][1]!='x')&amp;&amp;(B[1][1]!='o'))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp;  B[1][1]='o';&nbsp; //if not taken, then move<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; turn=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (i==6)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ((B[1][2]!='x')&amp;&amp;(B[1][2]!='o'))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp;  B[1][2]='o';&nbsp; //if not taken, then move<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; turn=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (i==7)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ((B[2][0]!='x')&amp;&amp;(B[2][0]!='o'))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp;  B[2][0]='o';&nbsp; //if not taken, then move<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; turn=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (i==8)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ((B[2][1]!='x')&amp;&amp;(B[2][1]!='o'))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp;  B[2][1]='o';&nbsp; //if not taken, then move<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; turn=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (i==9)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ((B[2][2]!='x')&amp;&amp;(B[2][2]!='o'))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp;  B[2][2]='o';&nbsp; //if not taken, then move<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; turn=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; }<br />
<br />
<br />
//Purpose: allows the user to make a move<br />
//Input: B[][] a 2 dimensional array that represents the board<br />
//Output: B[][], the board that has been updated with the human's move <br />
void HumanMove(char B[][3]) <br />
{int i=0, turn=0;<br />
cout&lt;&lt;&quot;\n IN HUMAN MOVE \n&quot;;<br />
//while (turn==0)&nbsp; &nbsp;  //Make sure the move is ok<br />
&nbsp; &nbsp; &nbsp; { <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Please enter the number of the space you would like to move to: &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; i;&nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; if (i==1)&nbsp; &nbsp; &nbsp; // make sure the first location is not taken<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ((B[0][0]!='x')&amp;&amp;(B[0][0]!='o'))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp;  B[0][0]='x';&nbsp; //if not taken, then move<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; turn=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (i==2)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ((B[0][1]!='x')&amp;&amp;(B[0][1]!='o'))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp;  B[0][1]='x';&nbsp; //if not taken, then move<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; turn=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (i==3)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ((B[0][2]!='x')&amp;&amp;(B[0][2]!='o'))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp;  B[0][2]='x';&nbsp; //if not taken, then move<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; turn=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (i==4)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ((B[1][0]!='x')&amp;&amp;(B[1][0]!='o'))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp;  B[1][0]='x';&nbsp; //if not taken, then move<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; turn=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (i==5)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ((B[1][1]!='x')&amp;&amp;(B[1][1]!='o'))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp;  B[1][1]='x';&nbsp; //if not taken, then move<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; turn=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (i==6)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ((B[1][2]!='x')&amp;&amp;(B[1][2]!='o'))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp;  B[1][2]='x';&nbsp; //if not taken, then move<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; turn=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (i==7)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ((B[2][0]!='x')&amp;&amp;(B[2][0]!='o'))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp;  B[2][0]='x';&nbsp; //if not taken, then move<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; turn=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (i==8)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ((B[2][1]!='x')&amp;&amp;(B[2][1]!='o'))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp;  B[2][1]='x';&nbsp; //if not taken, then move<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; turn=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (i==9)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ((B[2][2]!='x')&amp;&amp;(B[2][2]!='o'))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp;  B[2][2]='x';&nbsp; //if not taken, then move<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; turn=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
//Purpose: Print out the board<br />
//Input: B[][] a 2 dimensional array that represents the board<br />
//Output: None<br />
void PrintBoard(char B[][3]) <br />
{&nbsp; &nbsp;  cout&lt;&lt;&quot;\n&nbsp;  &quot;&lt;&lt;B[0][0]&lt;&lt;&quot;|&nbsp;  &quot;&lt;&lt;B[0][1]&lt;&lt;&quot;|&nbsp;  &quot;&lt;&lt;B[0][2];&nbsp;  <br />
&nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;\n_________________&quot;;<br />
&nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;\n&nbsp;  &quot;&lt;&lt;B[1][0]&lt;&lt;&quot;|&nbsp;  &quot;&lt;&lt;B[1][1]&lt;&lt;&quot;|&nbsp;  &quot;&lt;&lt;B[1][2];<br />
&nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;\n_________________&quot;;<br />
&nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;\n&nbsp;  &quot;&lt;&lt;B[2][0]&lt;&lt;&quot;|&nbsp;  &quot;&lt;&lt;B[2][1]&lt;&lt;&quot;|&nbsp;  &quot;&lt;&lt;B[2][2];<br />
&nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;\n\n&quot;;<br />
}<br />
//Purpose: Check for a winner<br />
//Input: B[][] a 2 dimensional array that represents the board<br />
//Output: win and integer indicating winner status. <br />
//&nbsp; &nbsp; &nbsp;  0=no winner, 1= human winner, 2= computer winner<br />
int CheckWin(char B[][3])<br />
{&nbsp; &nbsp;  int win = 0;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; if((B[0][0] == B[0][1] &amp;&amp; B[0][1] == B[0][2]))<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (B[0][0]=='x')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (B[0][0]=='o')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (B[0][1]=='x')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (B[0][1]=='o')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (B[0][2]=='x')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (B[0][2]=='o')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; if ((B[1][0] == B[1][1] &amp;&amp; B[1][1] == B[1][2]))<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (B[1][0]=='x')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (B[1][0]=='o')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (B[1][1]=='x')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (B[1][1]=='o')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (B[1][2]=='x')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (B[1][2]=='o')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; if ((B[2][0] == B[2][1] &amp;&amp; B[2][1] == B[2][2]))<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (B[2][0]=='x')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (B[2][0]=='o')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (B[2][1]=='x')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (B[2][1]=='o')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (B[2][2]=='x')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (B[2][2]=='o')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; if ((B[0][0] == B[1][1] &amp;&amp; B[1][1] == B[2][2]))<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (B[0][0]=='x')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (B[0][0]=='o')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (B[1][1]=='x')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (B[1][1]=='o')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (B[2][2]=='x')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (B[2][2]=='o')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=2;&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; if ((B[0][2] == B[1][1] &amp;&amp; B[1][1] == B[2][0]))<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (B[0][2]=='x')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (B[0][2]=='o')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (B[1][1]=='x')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (B[1][1]=='o')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (B[2][0]=='x')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (B[2][0]=='o')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=2;&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; if ((B[0][0] == B[1][0] &amp;&amp; B[1][0] == B[2][0]))<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (B[0][0]=='x')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (B[0][0]=='o')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (B[1][0]=='x')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (B[1][0]=='o')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (B[2][0]=='x')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (B[2][0]=='o')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=2;&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; if ((B[0][1] == B[1][1] &amp;&amp; B[1][1] == B[2][1]))<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (B[0][1]=='x')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (B[0][1]=='o')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (B[1][1]=='x')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (B[1][1]=='o')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (B[2][1]=='x')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (B[2][1]=='o')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=2;&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; if ((B[0][2] == B[1][2] &amp;&amp; B[1][2] == B[2][2]))<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (B[0][2]=='x')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (B[0][2]=='o')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (B[1][2]=='x')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (B[1][2]=='o')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (B[2][2]=='x')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (B[2][2]=='o')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win=2;&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;\n IN CHECK WIN &quot;&lt;&lt;win&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; return (win);<br />
}<br />
void main ()<br />
{int choice=0, done=0, t=0, w=0;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
char Board[3][3]={{'1','2','3'},{'4','5','6'},{'7','8','9'}};<br />
srand(time(0));<br />
Intro();<br />
PrintBoard(Board);<br />
cout&lt;&lt;&quot;Do you want to go first? Enter 1 for yes, 2 for no: &quot;;<br />
cin&gt;&gt;choice;<br />
&nbsp; &nbsp; &nbsp; if (choice==1)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //if player wishes to go first<br />
&nbsp; &nbsp; &nbsp; { <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; do{ cout&lt;&lt;&quot;\n turn = &quot;&lt;&lt;t&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HumanMove(Board);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; w=CheckWin(Board);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (w==1)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout&lt;&lt;&quot;Youwin!&quot;;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (w==2)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;You lose!&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (t==9&amp;&amp;w==0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;Tie Game&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PrintBoard(Board);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ComputerMove(Board);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; w=CheckWin(Board);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (w==1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;You Win!&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (w==2)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;You lose!&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (t==9&amp;&amp;w==0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;Tie Game&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PrintBoard(Board);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; t=t+1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }while((t!=9)||(w!=0));&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; else&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; do{&nbsp;  cout&lt;&lt;&quot;\n turn = &quot;&lt;&lt;t&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ComputerMove(Board);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; w=CheckWin(Board);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  if(w==1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout&lt;&lt;&quot;You Win!&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  else if (w==2)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout&lt;&lt;&quot;You lose!&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  else if (t==9&amp;&amp;w==0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout&lt;&lt;&quot;Tie Game&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PrintBoard(Board);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HumanMove(Board);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; w=CheckWin(Board);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (w==1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;You Win!&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (w==2)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;You lose!&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (t==9&amp;&amp;w==0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;Tie Game&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PrintBoard(Board);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; t=t+1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }while((t!=9)||(w!=0));&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
}</pre><br />
While still in the lab I was able to get the program going. However I can't get it to stop after someone wins, nor can I get the tie to work (might be related).<br />
<br />
Please help!  The program has to be in this format as he gave us the guide line and told us something in main was broken.... :)</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>mitchstokes225</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239880.html</guid>
		</item>
		<item>
			<title>.h file of class</title>
			<link>http://www.daniweb.com/forums/thread239876.html</link>
			<pubDate>Fri, 20 Nov 2009 01:08:14 GMT</pubDate>
			<description><![CDATA[So this is just the beginning of my questions, but I'm seriously having problems using classes in C++, I'm writing a program right now to plot points using asterisks on a 40 by 40 plain.  right now I'm just trying to write the .h for the point class and i cant even get that to compile. 
 
heres...]]></description>
			<content:encoded><![CDATA[<div>So this is just the beginning of my questions, but I'm seriously having problems using classes in C++, I'm writing a program right now to plot points using asterisks on a 40 by 40 plain.  right now I'm just trying to write the .h for the point class and i cant even get that to compile.<br />
<br />
heres what I have followed by errors I'm receiving... any help in regards to classes or just help with the errors will be appreciated.<br />
<br />
 <pre style="margin:20px; line-height:13px"><br />
#ifndef POINT_H<br />
#define POINT_H<br />
<br />
#include &lt;iostream&gt;<br />
#include &quot;arrayholder.h&quot;<br />
<br />
class Point{<br />
<br />
&nbsp;public:<br />
&nbsp; Point(): x(0.0), y(0.0), next() {};<br />
<br />
&nbsp; void addPoint( char a&#91;&#93;&#91;&#93; );<br />
<br />
private:<br />
double x;<br />
double y;<br />
Point* next;<br />
<br />
};<br />
<br />
#endif</pre><br />
and my arrayholder.h file<br />
<br />
 <pre style="margin:20px; line-height:13px">#ifndef ARRAYHOLDER_H<br />
#define ARRAYHOLDER_H<br />
<br />
#include &lt;iostream&gt;<br />
using namespace std;<br />
<br />
#include &quot;rectangle.h&quot;<br />
#include &quot;point.h&quot;<br />
<br />
class arrayholder{<br />
<br />
private:<br />
char a&#91;40&#93;&#91;40&#93;;<br />
Point* listpointer;<br />
<br />
public:<br />
<br />
&nbsp;char** initarray();<br />
&nbsp;void printRect();<br />
&nbsp;void printPoints();<br />
};<br />
<br />
#endif</pre><br />
<br />
In file included from point.h:13:<br />
arrayholder.h:22: error: ISO C++ forbids declaration of `Point' with no type<br />
arrayholder.h:22: error: expected `;' before '*' token<br />
<br />
I'm getting the same two errors for rectangle.h</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>Dewey1040</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239876.html</guid>
		</item>
		<item>
			<title>Link external stylesheet in Visual studio 2008</title>
			<link>http://www.daniweb.com/forums/thread239870.html</link>
			<pubDate>Fri, 20 Nov 2009 00:12:35 GMT</pubDate>
			<description><![CDATA[I'm making a project in Visual studio 2008.  
The details of the project are: 
- It is a MFC Application 
- The application type is Dialog based with Use HTML Dialog enabled 
- The project style is MFC standard and... 
- The use of the MFC is in a shared DLL 
 
When it creates the project, I have...]]></description>
			<content:encoded><![CDATA[<div>I'm making a project in Visual studio 2008. <br />
The details of the project are:<br />
- It is a MFC Application<br />
- The application type is Dialog based with Use HTML Dialog enabled<br />
- The project style is MFC standard and...<br />
- The use of the MFC is in a shared DLL<br />
<br />
When it creates the project, I have an HTML file called myApp.htm<br />
which contains the HTML code of the dialog.<br />
<br />
I want to apply an external css file to this HTML, so i add:<br />
&lt;link rel=&quot;stylesheet&quot; src=&quot;myApp.css&quot; type=&quot;text/css&quot;/&gt;<br />
in the head of the document. But it doesn't work.<br />
So I try using:<br />
&lt;link rel=&quot;stylesheet&quot; src=&quot;file://myApp.css&quot; type=&quot;text/css&quot;/&gt;<br />
but it doesn't work either.<br />
I think there must be a way to do it.<br />
I added the css file to the project.<br />
I have tried everything, but no luck. Can someone give me a hand?<br />
thanks!</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>Tales</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239870.html</guid>
		</item>
		<item>
			<title><![CDATA[need help with using f'riend' to design this program. also, overloading.]]></title>
			<link>http://www.daniweb.com/forums/thread239868.html</link>
			<pubDate>Fri, 20 Nov 2009 00:03:41 GMT</pubDate>
			<description>Design a PhoneCall class that holds a phone number to which a call is placed, the length of the call in minutes, and the rate charged per minute.  Overload extraction and insertion operations for the class. 
 
Overload the == operator to compare two PhoneCalls. Consider one PhoneCall to be equal to...</description>
			<content:encoded><![CDATA[<div>Design a PhoneCall class that holds a phone number to which a call is placed, the length of the call in minutes, and the rate charged per minute.  Overload extraction and insertion operations for the class.<br />
<br />
Overload the == operator to compare two PhoneCalls. Consider one PhoneCall to be equal to another if both calls are placed to the same number.<br />
<br />
Create a main() function that allows you to enter 10 PhoneCalls into an array.  If a PhoneCall is already been placed to a number, do not allow a second PhoneCall to the same number<br />
<br />
<br />
<br />
I'm pretty good at logic so i think i can figure that part out, its the syntax and the declarations that i cant wrap my head around<br />
<br />
please help!<br />
thank you.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>simplyscottif</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239868.html</guid>
		</item>
		<item>
			<title>My Program wont Stop?</title>
			<link>http://www.daniweb.com/forums/thread239861.html</link>
			<pubDate>Thu, 19 Nov 2009 23:23:21 GMT</pubDate>
			<description>so i guess there must be some sort of an error in my logic but on line 119 i started a counter that only goes up when a pair is made in the game.  Since there are a total of 8 pairs, i set that when the counter is 8 the bool nullexists turns false.  when it is false it should skip the while loop...</description>
			<content:encoded><![CDATA[<div>so i guess there must be some sort of an error in my logic but on line 119 i started a counter that only goes up when a pair is made in the game.  Since there are a total of 8 pairs, i set that when the counter is 8 the bool nullexists turns false.  when it is false it should skip the while loop and output that you have won.<br />
<br />
Any ideas on what is actually wrong here? I did check and the counter is going up at the correct times<br />
<br />
here is the code<br />
 <pre style="margin:20px; line-height:13px">//*******************************************************************************************************************<br />
// Homework 5<br />
// <br />
//&nbsp; &nbsp;  <br />
//&nbsp; &nbsp;  <br />
//<br />
// This program is a matching game.&nbsp; The user uses a cordinant system to select<br />
// cards on a 4x4 board.<br />
// Input:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; the user inputs the cordinants of the cards they want to flip<br />
// Processing:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  the program randomly generates pairs of cards in random locations<br />
//&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; on the 4x4 board.&nbsp; it also adjusts the user input so that the<br />
//&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cordinants match with the matrix counting system.<br />
// Output:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  the game board, the cards fliped, if they match, and the next board piece<br />
//*******************************************************************************************************************<br />
<br />
<br />
#include &lt;iostream&gt;<br />
#include &lt;cstdlib&gt;<br />
#include &lt;ctime&gt;<br />
using namespace std;<br />
<br />
int main()<br />
{<br />
&nbsp; &nbsp; char comma;<br />
&nbsp; &nbsp; int row1, row1a, column1, column1a, row2, row2a, column2, column2a, cards[4][4], cards_unflipped[4][4] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} , counter(0), g(0);<br />
&nbsp; &nbsp; &nbsp; &nbsp; bool nullexists = true;<br />
&nbsp; &nbsp; srand((unsigned)time(NULL));<br />
&nbsp;  <br />
&nbsp; &nbsp; //fill board with pairs<br />
&nbsp; &nbsp; bool makeNext = false;<br />
&nbsp; &nbsp; memset(cards, 0, sizeof(cards));<br />
&nbsp; &nbsp; srand(time(NULL));<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; for( int i = 1; i &lt; 9; i++ )<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; makeNext = false;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while(!makeNext)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int x1, y1, x2, y2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x1 = rand()%4;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; y1 = rand()%4;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x2 = rand()%4;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; y2 = rand()%4;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if( (x1 != x2 || y1 != y2) &amp;&amp; (cards[x1][y1] == 0 &amp;&amp; cards[x2][y2] == 0) )<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cards[x1][y1] = i;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cards[x2][y2] = i;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; makeNext = true;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; // initial display board<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;&nbsp; &nbsp; 1 2 3 4\n&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;&nbsp; &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (int i=0; i&lt;=8; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;-&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;endl;<br />
&nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; for (int r=0; r&lt;4; r++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;r+1&lt;&lt;&quot; | &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int c=0; c&lt;4; c++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;cards_unflipped[r][c]&lt;&lt;&quot; &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
<br />
<br />
&nbsp;  //Game Loop --------------------------------------------------------------------------------<br />
&nbsp;  while (nullexists = true)<br />
<br />
&nbsp;  {<br />
&nbsp; &nbsp;  //selection of cards<br />
&nbsp; &nbsp; cout &lt;&lt; &quot;Please select the first card row and column seperated by a comma.\n&quot;;<br />
&nbsp; &nbsp; cin &gt;&gt; row1a &gt;&gt; comma &gt;&gt; column1a;<br />
<br />
&nbsp; &nbsp; cout&lt;&lt;&quot;Please select the second card row and column seperated by a comma.\n&quot;;<br />
&nbsp; &nbsp; cin&gt;&gt;row2a&gt;&gt;comma&gt;&gt;column2a;<br />
&nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; // adjusting for matrix cordinants<br />
&nbsp; &nbsp; &nbsp; &nbsp; row1 = row1a - 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; row2 = row2a - 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; column1 = column1a - 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; column2 = column2a - 1;<br />
<br />
&nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; // make sure that the cordinants are on the board<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (row1a &gt; 4 || row2a &gt; 4 || column1a &gt; 4 || column2a &gt; 4 || row1a &lt; 1 || row2a &lt; 1 || column1a &lt; 1 || column2a &lt; 1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;please pick cordinants on the board.&quot; &lt;&lt; endl &lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Please select the first card row and column seperated by a comma.\n&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; row1a &gt;&gt;comma &gt;&gt; column1a;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Please select the second card row and column seperated by a comma.\n&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; row2a &gt;&gt; comma &gt;&gt; column2a;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; // cards chosen<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;The cards you picked were &quot; &lt;&lt; cards[row1][column1] &lt;&lt; &quot; and &quot; &lt;&lt; cards[row2][column2] &lt;&lt; endl;<br />
&nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp;  if (cards[row1][column1]== cards[row2][column2])<br />
<br />
&nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cards_unflipped[row1][column1] = cards[row1][column1];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cards_unflipped[row2][column2] = cards[row2][column2];<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; counter = counter++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (counter == 8)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bool nullexists = false;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (bool nullexists = false)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot; Congrats, You Won!&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Press n to continue.&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while (1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  if (getchar() == 'n')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  // move to blank screen<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  for (g=0; g &lt;= 20; g++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
<br />
&nbsp; &nbsp; //reveal the flipped cards<br />
&nbsp; &nbsp; cout&lt;&lt;&quot;&nbsp; &nbsp; 1 2 3 4\n&quot;;<br />
&nbsp; &nbsp; cout&lt;&lt;&quot;&nbsp; &quot;;<br />
&nbsp; &nbsp; for (int i=0; i&lt;=8; i++)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;-&quot;;<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; cout&lt;&lt;endl;<br />
&nbsp; &nbsp; for (int r=0; r&lt;4; r++)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;r+1&lt;&lt;&quot; | &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (int c=0; c&lt;4; c++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;cards_unflipped[r][c]&lt;&lt;&quot; &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp;  }<br />
&nbsp;  <br />
&nbsp; &nbsp; &nbsp;  else<br />
&nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cards_unflipped[row1][column1] = cards[row1][column1];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cards_unflipped[row2][column2] = cards[row2][column2];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //reveal the flipped cards<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;&nbsp; &nbsp; 1 2 3 4\n&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;&nbsp; &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int i=0; i&lt;=8; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;-&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int r=0; r&lt;4; r++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;r+1&lt;&lt;&quot; | &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int c=0; c&lt;4; c++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;cards_unflipped[r][c]&lt;&lt;&quot; &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // pause for user to look at the cards they flipped<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Press n to continue.&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while (1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (getchar() == 'n')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //reset flipped cards<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cards_unflipped[row1][column1] = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cards_unflipped[row2][column2] = 0;<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // move to blank screen<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (g=0; g &lt;= 20; g++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //reveal the flipped cards<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;&nbsp; &nbsp; 1 2 3 4\n&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;&nbsp; &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int i=0; i&lt;=8; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;-&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int r=0; r&lt;4; r++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;r+1&lt;&lt;&quot; | &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int c=0; c&lt;4; c++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;cards_unflipped[r][c]&lt;&lt;&quot; &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; //GAME LOOP END -------------------------------------------------------------------------------<br />
<br />
&nbsp;  cout &lt;&lt; &quot;You Won!&quot; &lt;&lt; endl;<br />
&nbsp;<br />
<br />
&nbsp; &nbsp; return 0;<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>Ponomous</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239861.html</guid>
		</item>
		<item>
			<title>Confused about my pseudocodes</title>
			<link>http://www.daniweb.com/forums/thread239860.html</link>
			<pubDate>Thu, 19 Nov 2009 23:03:29 GMT</pubDate>
			<description><![CDATA[Pseudocode is still somewhat confusing and I've been reading and this assignment for the a while now and I wanted to make sure I am understanding what's being asked of me. Could someone please tell me if my pseudocodes are correct? 
 
Question: 
 
1. Using pseudocode declare a Real number named...]]></description>
			<content:encoded><![CDATA[<div>Pseudocode is still somewhat confusing and I've been reading and this assignment for the a while now and I wanted to make sure I am understanding what's being asked of me. Could someone please tell me if my pseudocodes are correct?<br />
<br />
Question:<br />
<br />
1. Using pseudocode declare a Real number named temperature.<br />
<br />
2. Using pseudocode declare a variable to store the Julian day (1-366) named JDay<br />
<br />
3. Write pseudocode that asks a user to enter string variables to store a person’s lastname and  birthdate. Then output the lastname and birthdate separated by a comma.<br />
<br />
<br />
My pseudocode:<br />
<br />
1. Declare temperature as double<br />
<br />
2. Declare JDay as Integer<br />
<br />
3. Declare LastName as string<br />
Declare BirthDate as string<br />
Write “Enter your last name”<br />
Input LastName<br />
Write “Enter your birthdate”<br />
Input BirthDate<br />
Set UserInfo = LastName = “ , “ + Birthdate</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>confusedndazed</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239860.html</guid>
		</item>
		<item>
			<title>Reverse number</title>
			<link>http://www.daniweb.com/forums/thread239856.html</link>
			<pubDate>Thu, 19 Nov 2009 22:35:12 GMT</pubDate>
			<description><![CDATA[Hi, I wounder if anyone can help me start a program which takes "USER INPUT" for any 10 numbers and then print them in reverse order using arrays what should I need to do to get started with this. Please help. 
 
Thanks, 
Maverick]]></description>
			<content:encoded><![CDATA[<div>Hi, I wounder if anyone can help me start a program which takes &quot;USER INPUT&quot; for any 10 numbers and then print them in reverse order using arrays what should I need to do to get started with this. Please help.<br />
<br />
Thanks,<br />
Maverick</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>maverick405</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239856.html</guid>
		</item>
		<item>
			<title>reading date using classes</title>
			<link>http://www.daniweb.com/forums/thread239849.html</link>
			<pubDate>Thu, 19 Nov 2009 21:29:02 GMT</pubDate>
			<description>hello  
i have given a program which uses the class. It reads the date of birth. And do all the necessary checks on the given value. e.g. What is the limit of that particular month, whether it is a leap year or not. I am writting the first program using classes. I am having problemin my switch...</description>
			<content:encoded><![CDATA[<div>hello <br />
i have given a program which uses the class. It reads the date of birth. And do all the necessary checks on the given value. e.g. What is the limit of that particular month, whether it is a leap year or not. I am writting the first program using classes. I am having problemin my switch statements which i used for checks the more I try to solve the more I get confused. Need your help. Please check my program. I know it is having many other mistakes also.<br />
 <pre style="margin:20px; line-height:13px">#include&lt;iostream.h&gt;<br />
#include&lt;conio.h&gt;<br />
class date<br />
{<br />
public:<br />
date();<br />
void setdate(int, char, int);<br />
void printdate();<br />
private:<br />
int day;<br />
char month[50];<br />
int year;<br />
};<br />
date::date()<br />
{<br />
day=1;<br />
month= 'January';<br />
year= 1990;<br />
}<br />
void date::setdate(int d, char m[50], int y)<br />
{<br />
day = d;<br />
month =m; <br />
year = (y&gt;= 1900 &amp;&amp; y&lt;= 3000)? y : 1900;<br />
switch (m)<br />
{<br />
case 1: 'January'<br />
&nbsp; &nbsp; d&gt;=1&amp;&amp;d&lt;=31;<br />
&nbsp; &nbsp; break;<br />
case 2: 'Febrary'<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; if (y%4==0)<br />
&nbsp; &nbsp; d&gt;=1&amp;&amp;d&lt;=29;<br />
&nbsp; &nbsp; else<br />
&nbsp; &nbsp; d&gt;=1&amp;&amp;d&lt;=28;<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; break;<br />
case 3: 'March'<br />
&nbsp; &nbsp; d&gt;=1&amp;&amp;d&lt;=31;<br />
&nbsp; &nbsp; break;<br />
case 4: 'Apirl'<br />
&nbsp; &nbsp; d&gt;=1&amp;&amp;d&lt;=30;<br />
&nbsp; &nbsp; break;<br />
case 5: 'May'<br />
&nbsp; &nbsp; d&gt;=1&amp;&amp;d&lt;=31;<br />
&nbsp; &nbsp; break;<br />
case 6: 'June'<br />
&nbsp; &nbsp; d&gt;=1&amp;&amp;d&lt;=30;<br />
&nbsp; &nbsp; break;<br />
case 7: 'July'<br />
&nbsp; &nbsp; d&gt;=1&amp;&amp;d&lt;=31;<br />
&nbsp; &nbsp; break;<br />
case 8: 'August'<br />
&nbsp; &nbsp; d&gt;=1&amp;&amp;d&lt;=31;<br />
&nbsp; &nbsp; break;<br />
case 9: 'September'<br />
&nbsp; &nbsp; d&gt;=1&amp;&amp;d&lt;=30;<br />
&nbsp; &nbsp; break;<br />
case 10: 'October'<br />
&nbsp; &nbsp; d&gt;=1&amp;&amp;d&lt;=31;<br />
&nbsp; &nbsp; break;<br />
case 11: 'November'<br />
&nbsp; &nbsp; d&gt;=1&amp;&amp;d&lt;=30;<br />
&nbsp; &nbsp; break;<br />
case 12: 'December'<br />
&nbsp; &nbsp; d&gt;=1&amp;&amp;d&lt;=31;<br />
&nbsp; &nbsp; break;<br />
}<br />
}<br />
void date::printdate()<br />
{<br />
cout&lt;&lt;day&lt;&lt;&quot; &quot;&lt;&lt;month&lt;&lt;&quot; &quot;&lt;&lt;year&lt;&lt;endl;<br />
}<br />
void main()<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; date da;<br />
&nbsp; &nbsp; da.setdate(20,Febrary,1990)<br />
&nbsp; &nbsp; cout&lt;&lt;&quot;The date of birth is : &quot;;<br />
&nbsp; &nbsp; da.printdate;<br />
&nbsp; &nbsp; getch();<br />
&nbsp; &nbsp; }</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>the great</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239849.html</guid>
		</item>
		<item>
			<title>functions that take in iostream as parameter</title>
			<link>http://www.daniweb.com/forums/thread239839.html</link>
			<pubDate>Thu, 19 Nov 2009 20:33:21 GMT</pubDate>
			<description><![CDATA[I recently needed to add member functions like these into my class 
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox" title="Help with Code Tags"...]]></description>
			<content:encoded><![CDATA[<div>I recently needed to add member functions like these into my class<br />
<br />
 <pre style="margin:20px; line-height:13px">istream&amp; read(istream&amp;) ;<br />
ostream&amp; print(ostream&amp;);</pre><br />
I am a little confused on how to actually call these functions within my class. I am more familiar with overloading the insertion and extraction operator since the prototype for those makes a lot more sense to me; however, one of my program spec is that I need to use these. What do I need to put into the function as a parameter?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>red999</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239839.html</guid>
		</item>
		<item>
			<title>Please Help Me with this little bug in my program (Program due in 8 hrs)</title>
			<link>http://www.daniweb.com/forums/thread239833.html</link>
			<pubDate>Thu, 19 Nov 2009 19:58:45 GMT</pubDate>
			<description><![CDATA[My program deals with the Genetic Algorithm and Hill Climber Algorithm. I have a program that compiles without any errs, its just the data is gives is incorrect. I explain my error on the bottom part of my post 
 
Header File 
  <div class="codeblock"> <div class="spaced"> <div style="float:right;...]]></description>
			<content:encoded><![CDATA[<div>My program deals with the Genetic Algorithm and Hill Climber Algorithm. I have a program that compiles without any errs, its just the data is gives is incorrect. I explain my error on the bottom part of my post<br />
<br />
Header File<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
using namespace std;<br />
//------------------------------------------------------------------------------<br />
&nbsp; &nbsp; template&lt;class T&gt;<br />
&nbsp; &nbsp; class redefinedVector<br />
&nbsp;  {<br />
&nbsp;  public:<br />
&nbsp; &nbsp; &nbsp; redefinedVector();<br />
&nbsp; &nbsp; &nbsp; int get_size() const; <br />
&nbsp; &nbsp; &nbsp; int get_capacity() const; <br />
&nbsp; &nbsp; &nbsp; void push_back(T);<br />
&nbsp; &nbsp; &nbsp; void pop(); <br />
&nbsp; &nbsp; &nbsp; void resize(); <br />
&nbsp; &nbsp; &nbsp; void print(); <br />
&nbsp; &nbsp; &nbsp; T&amp; operator[](int index); <br />
&nbsp; &nbsp; &nbsp; ~redefinedVector(); <br />
&nbsp; <br />
&nbsp;  private:<br />
&nbsp; &nbsp; &nbsp; T *basket; <br />
&nbsp; &nbsp; &nbsp; int capacity, size;<br />
&nbsp;  };<br />
//------------------------------------------------------------------------------&nbsp;  <br />
&nbsp; &nbsp; class Individual<br />
&nbsp;  {<br />
&nbsp;  public:<br />
&nbsp; &nbsp; &nbsp; friend class GeneticAlgorithm;<br />
&nbsp; &nbsp; &nbsp; friend class HillClimberAlgorithm;<br />
&nbsp; &nbsp; &nbsp; friend class UserInterface;<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; Individual(); <br />
&nbsp; &nbsp; &nbsp; Individual(int problem); <br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; double randomization(double, double); <br />
&nbsp; &nbsp; &nbsp; double GetData(int index) const;<br />
&nbsp; &nbsp; &nbsp; double GetFitness() const<br />
&nbsp; &nbsp; &nbsp;  { <br />
&nbsp; &nbsp; &nbsp; &nbsp;  return fitness;<br />
&nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; void SetProblem(int problem);<br />
&nbsp; &nbsp; &nbsp; void MathProblemsFitness();&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; void setData(int index,double numbers); <br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; int getProblem()const<br />
&nbsp; &nbsp; &nbsp;  { <br />
&nbsp; &nbsp; &nbsp; &nbsp;  return problem;<br />
&nbsp; &nbsp; &nbsp;  }<br />
&nbsp;  private:<br />
&nbsp; &nbsp; &nbsp; double data[30]; <br />
&nbsp; &nbsp; &nbsp; double fitness; <br />
&nbsp; &nbsp; &nbsp; double max; <br />
&nbsp; &nbsp; &nbsp; double min; <br />
&nbsp; &nbsp; &nbsp; int problem; <br />
&nbsp;  };<br />
&nbsp;<br />
//------------------------------------------------------------------------------<br />
<br />
class UserInterface<br />
&nbsp;  {<br />
&nbsp;  public:<br />
&nbsp; &nbsp; &nbsp; UserInterface();<br />
&nbsp; &nbsp; &nbsp; UserInterface(bool parameters, bool Problem, bool Optimization); <br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; void setTimeResult(int,int);<br />
&nbsp; &nbsp; &nbsp; void setDataResult(int,Individual);<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; Individual GetDataResult(int)const;&nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; int getTimeResult(int) const;<br />
&nbsp;  private:<br />
&nbsp; &nbsp; &nbsp; int highestTimes [3];<br />
&nbsp; &nbsp; &nbsp; Individual best [3];<br />
&nbsp;  }; <br />
//------------------------------------------------------------------------------ <br />
&nbsp;class GeneticAlgorithm<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp;  friend class UserInterface;<br />
&nbsp;  public:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; GeneticAlgorithm(); <br />
&nbsp; &nbsp; &nbsp; GeneticAlgorithm(int,int,double,double); <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; redefinedVector&lt;Individual&gt; individualResults;<br />
&nbsp; &nbsp; &nbsp; redefinedVector&lt;int&gt; iterationVector;<br />
&nbsp; &nbsp; &nbsp; redefinedVector&lt;Individual&gt; mainVector;<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; int selection(int); <br />
&nbsp; &nbsp; &nbsp; int randomization(int,int); <br />
&nbsp; &nbsp; &nbsp; int checkAnswer(); <br />
&nbsp; &nbsp; &nbsp; int rando(double);<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; double randomizationDouble(double min, double max);<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; void Breed(int,int,int,double,double); <br />
&nbsp; &nbsp; &nbsp; void replace(Individual);&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; void Optimize(int, int,double,double);<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp;  private:<br />
&nbsp; &nbsp; &nbsp; int parent1, parent2;<br />
&nbsp; &nbsp; &nbsp; int iterationNumber; <br />
&nbsp;  };<br />
//------------------------------------------------------------------------------<br />
class HillClimberAlgorithm<br />
{<br />
&nbsp; &nbsp; &nbsp; public:<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  HillClimberAlgorithm ();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  HillClimberAlgorithm(int problem, double mutation_chance, double mutation_amount);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  redefinedVector&lt;Individual&gt; finalHillClimber;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  redefinedVector&lt;int&gt;runTime;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  redefinedVector&lt;Individual&gt; hillVector;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  int randomization(int,int); <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  int checkAnswer();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  int rando(double mutation_rate);<br />
&nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  double randomizationDouble(double min, double max);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  void replace(Individual individual);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; private:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  int inidividualA, individualB;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  int counter;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  double fitness;<br />
};</pre><br />
Implementation<br />
 <pre style="margin:20px; line-height:13px">#include &lt;cmath&gt;<br />
#include &lt;cstdlib&gt;<br />
#include &lt;ctime&gt;<br />
#include &lt;string.h&gt;<br />
#include &lt;fstream&gt;<br />
#include &lt;sstream&gt;<br />
#include &lt;stdexcept&gt;<br />
#include &lt;stdio.h&gt;<br />
#include &lt;ctype.h&gt;<br />
#include &lt;vector&gt;<br />
#include &lt;cctype&gt;<br />
#include &lt;algorithm&gt;<br />
#include &lt;iterator&gt;<br />
#include &lt;iomanip&gt;<br />
#include &lt;cstdlib&gt;<br />
#include &lt;iostream&gt;<br />
#include &lt;math.h&gt;<br />
#include &quot;bpt0004_3.h&quot;<br />
<br />
using namespace std;<br />
using std :: ifstream;<br />
using std :: ofstream;<br />
using std :: endl;<br />
<br />
template&lt;class T&gt;<br />
&nbsp; &nbsp; redefinedVector&lt;T&gt;::redefinedVector() :capacity(2), size(0)<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; basket = new T [capacity];<br />
&nbsp;  }<br />
<br />
&nbsp; &nbsp; template&lt;class T&gt;<br />
&nbsp; &nbsp; void redefinedVector&lt;T&gt;::push_back(T element)<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; if(size &lt; capacity)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  basket[size] = element; <br />
&nbsp; &nbsp; &nbsp; &nbsp;  size++;<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; else <br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  resize();<br />
&nbsp; &nbsp; &nbsp; &nbsp;  basket[size] = element;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  size++; <br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp;  }<br />
&nbsp;<br />
&nbsp; &nbsp; template&lt;class T&gt;<br />
&nbsp; &nbsp; T&amp; redefinedVector&lt;T&gt;::operator[](int index)<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; if(index &gt;= size) <br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;Illegal index.&quot; &lt;&lt; endl; <br />
&nbsp; &nbsp; &nbsp; &nbsp;  exit(0);<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; return basket[index]; <br />
&nbsp;  }<br />
&nbsp; <br />
&nbsp; &nbsp; template&lt;class T&gt;<br />
&nbsp; &nbsp; void redefinedVector&lt;T&gt;::pop()<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; if(size != 0)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  size--; <br />
&nbsp; &nbsp; &nbsp; &nbsp;  capacity = size + 1; <br />
&nbsp; &nbsp; &nbsp; &nbsp;  T *newBasket = new T[capacity]; <br />
&nbsp; &nbsp; &nbsp; &nbsp;  for(int i = 0; i &lt; size; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; newBasket[i] = basket[i];<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  delete [] basket; <br />
&nbsp; &nbsp; &nbsp; &nbsp;  basket = newBasket; <br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;Vector is Empty.&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; } <br />
&nbsp;  }<br />
<br />
&nbsp; &nbsp; template&lt;class T&gt;<br />
&nbsp; &nbsp; redefinedVector&lt;T&gt;::~redefinedVector()<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; delete [] basket;<br />
&nbsp;  }<br />
<br />
&nbsp; &nbsp; template&lt;class T&gt;<br />
&nbsp; &nbsp; void redefinedVector&lt;T&gt;::resize()<br />
&nbsp;  { <br />
&nbsp; &nbsp; &nbsp; T *newBasket = new T[capacity + 2]; <br />
&nbsp; &nbsp; &nbsp; for(int i = 0; i &lt; size; i++) <br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  newBasket[i] = basket[i];<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; delete [] basket; <br />
&nbsp; &nbsp; &nbsp; basket = newBasket; <br />
&nbsp; &nbsp; &nbsp; capacity += 2; <br />
&nbsp;  }<br />
&nbsp;<br />
&nbsp; &nbsp; template&lt;class T&gt;<br />
&nbsp; &nbsp; void redefinedVector&lt;T&gt;::print()<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; for(int i = 0; i &lt; size; i++)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; basket[i] &lt;&lt; &quot; &quot;;<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp;  }<br />
&nbsp;<br />
&nbsp; &nbsp; template&lt;class T&gt;<br />
&nbsp; &nbsp; int redefinedVector&lt;T&gt;::get_size() const<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; return size;<br />
&nbsp;  }<br />
<br />
&nbsp; &nbsp; template&lt;class T&gt;<br />
&nbsp; &nbsp; int redefinedVector&lt;T&gt;::get_capacity() const<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; return capacity;<br />
&nbsp;  } <br />
//-----------------------------------------------------------------------------<br />
<br />
UserInterface::UserInterface()<br />
&nbsp;  {<br />
&nbsp;  }<br />
&nbsp;<br />
int UserInterface::getTimeResult(int index)const<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; return highestTimes[index];<br />
&nbsp;  }<br />
void UserInterface::setTimeResult(int index, int numbers)&nbsp; <br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; highestTimes[index] = numbers;<br />
&nbsp;  } <br />
Individual UserInterface::GetDataResult(int index)const<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; return best[index];<br />
&nbsp;  }<br />
void UserInterface::setDataResult(int index, Individual indiv)&nbsp; <br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; best[index] = indiv;<br />
&nbsp;  }<br />
UserInterface::UserInterface(bool parameters, bool Problem, bool Optimization)<br />
&nbsp;  {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp;  /*<br />
&nbsp;  UserInterface Method that is the main menu for the user. Each bool parameter<br />
&nbsp;  ensures that values are entered into various parts within the menu.<br />
&nbsp;  */<br />
&nbsp;  srand (time(0));<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; bool sc = false;<br />
&nbsp; &nbsp; &nbsp; bool ro = false;<br />
&nbsp; &nbsp; &nbsp; bool gr = false;<br />
&nbsp; &nbsp; &nbsp; int userChoice = 0;<br />
&nbsp; &nbsp; &nbsp; int populationSize= 0; <br />
&nbsp; &nbsp; &nbsp; int problem =0;<br />
&nbsp; &nbsp; &nbsp; int algoChoice=0;<br />
&nbsp; &nbsp; &nbsp; double mutation_amount=0; <br />
&nbsp; &nbsp; &nbsp; double mutation_rate=0;<br />
&nbsp; &nbsp; &nbsp; bool menuBool=true;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; while(userChoice != 6)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  do{ <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Function Optimizer:\n&quot; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; &quot;\n&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; &quot;1. Choose Algorithm \n&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; &quot;2. Choose Algorithm Parameters\n&quot; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; &quot;3. Choose Problem (Schwefel, Rosenbrock, Griewangk).\n&quot; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; &quot;4. Perform Optimization\n&quot;&nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; &quot;5. Show All Optimization Results\n&quot; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; &quot;6. Exit the System\n&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; &quot;\n&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; &quot;&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(!(cin &gt;&gt; userChoice))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;Unknown Value!&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  exit(0);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp;  while(userChoice &gt; 6 || userChoice &lt; 1); <br />
&nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp;  if(userChoice ==1)<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; do<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Enter Algorithm Choice\n&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; &quot;1. HillClimber\n&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; &quot;2. GeneticAlgorithm\n&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (!(cin &gt;&gt;algoChoice))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Unknown Value!&quot; &lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit(0);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (algoChoice==1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt;&quot;Hill Climber Chosen \n&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (algoChoice==2)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt;&quot;GeneticAlgorithm Chosen\n&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&quot;&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while((algoChoice &lt; 0)&amp;&amp;(algoChoice &gt;2));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp;  if(userChoice == 2)<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt;&quot;Enter parameters for each algorithm. Only the mutation amount and mutation\n&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt;&quot;chance will be used for the Hillclimber, the Genetic will take in the muation \n&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt;&quot;chance, mutation amount, and population size.\n&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt;&quot;\n&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; do{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;Enter Mutation Amount(.03-1.0): &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  if(!(cin &gt;&gt; mutation_amount))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Unknown Value!&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit(0);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while(mutation_amount &lt; -1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; do{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;Enter Mutation Rate (.03-.25): &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  if(!(cin &gt;&gt; mutation_rate))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Unknown Value!&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit(0);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }while(mutation_rate &lt; -1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; do{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;Enter Population Size (2-50): &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  if(!(cin &gt;&gt; populationSize))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Unknown Value!&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit(0);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while(populationSize &lt; 2);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; parameters = true;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp;  else if(userChoice == 3)<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; do{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;Choose a problem (Schwefel, Rosenbrock, Griewangk).&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;1 Schwefel&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;2 Rosenbrock&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;3 Griewangk&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  if(!(cin &gt;&gt; problem))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Unknown Value!&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit(0);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  if(problem == 1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sc = true;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  else if(problem == 2)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ro = true;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  else if(problem == 3)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; gr = true;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }while(problem &gt; 3 || problem &lt; 1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Problem = true;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp;  else if(userChoice == 4)<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(!parameters || !Problem)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;Error&quot; &lt;&lt; endl &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (algoChoice==1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  HillClimberAlgorithm(problem, mutation_rate, mutation_amount);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  Optimization = true;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (algoChoice==2)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  GeneticAlgorithm(problem,populationSize,mutation_rate,mutation_amount);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  Optimization = true;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp;  else if(userChoice == 5)<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(!Optimization)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;Optimization not run&quot; &lt;&lt; endl &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  if(sc == true)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt;&quot;Iterations: &quot; &lt;&lt; highestTimes[0] &lt;&lt;&quot;\n&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Schwefel information empty\n&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt;&quot; &quot; ;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  if(ro == true)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt;&quot;Iterations: &quot; &lt;&lt; highestTimes[1] &lt;&lt;&quot;\n&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Rosenbrock information empty\n&quot; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; &quot; &quot; ;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  if(gr == true)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt;&quot;Iterations: &quot; &lt;&lt; highestTimes[2] &lt;&lt;&quot;\n&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Griewangk information empty&quot; &lt;&lt; endl &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp;  else if(userChoice == 6)<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Exiting&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit(0);<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }&nbsp;  <br />
&nbsp;  }<br />
//------------------------------------------------------------------------------<br />
HillClimberAlgorithm::HillClimberAlgorithm() <br />
<br />
{<br />
}<br />
void HillClimberAlgorithm::replace(Individual newIndividual)<br />
/*Replace takes the least fit individual and replaces it the the newIndividual<br />
Pre-condition: takes in a newIndividual of type Individual, which sets a vector of random integers between a range<br />
determined by the problem.<br />
Post-condition replaces the current individual at hillvector[i] with the newIndividual<br />
*/<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; double temp = hillVector[0].GetFitness(); <br />
&nbsp; &nbsp; &nbsp; int index = 0; <br />
&nbsp; &nbsp; &nbsp; for(int i = 1; i &lt; hillVector.get_size(); i++)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  if(temp &lt; hillVector[i].GetFitness())<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; temp = hillVector[i].GetFitness();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; index = i; <br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; for(int i = 0; i &lt; 30; i++)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  hillVector[index].setData(i,newIndividual.GetData(i));<br />
&nbsp; &nbsp; &nbsp; &nbsp;  hillVector[index].MathProblemsFitness();<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; counter++;<br />
&nbsp; &nbsp;  }<br />
int HillClimberAlgorithm::rando(double mutation_rate)<br />
/*<br />
Pre-condition: user entered mutation_rate<br />
Post-condition: generates a random double based on the mutation_rate<br />
*/<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; double number = rand() / (double)RAND_MAX;<br />
&nbsp; &nbsp; &nbsp; return number &lt; mutation_rate;<br />
&nbsp;  }<br />
int HillClimberAlgorithm::randomization(int min, int max)<br />
/*<br />
Pre-condition: 2 integers<br />
Post-condition: random generated integer between the range of min and max<br />
*/<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; return static_cast&lt;int&gt;(( static_cast&lt;double&gt;(rand()))/ static_cast&lt;double&gt;( RAND_MAX) *(max-min + 1) + min);<br />
&nbsp;  }<br />
double HillClimberAlgorithm::randomizationDouble(double min, double max)<br />
/*<br />
Pre-condition: 2 double<br />
Post-condition: random generated double between the range of min and max<br />
*/<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; return static_cast&lt;double&gt;(rand())/ static_cast&lt;double&gt;( RAND_MAX) *(max-min + 1) + min;<br />
&nbsp;  }<br />
HillClimberAlgorithm::HillClimberAlgorithm(int problem, double mutation_rate, double mutation_amount)<br />
/*<br />
Main constructor used in the HillClimber Algorithm<br />
Pre-condition: takes in three parameters: problem, mutation_rate, mutation_amount<br />
Post-condition: Passes the Individual through the MathProblemsFitness and generates a fitness,<br />
if the fitness is less than the current fitness, than the newIndividual replaces individual<br />
*/<br />
{<br />
&nbsp; &nbsp; &nbsp;  Individual newIndividualA(problem);<br />
&nbsp; &nbsp; &nbsp;  fitness= newIndividualA.GetFitness();<br />
&nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp;  double range=0;<br />
&nbsp; &nbsp; &nbsp;  if(problem == 1) <br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  range = 131.072;<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; else if(problem == 2)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  range = 4.096;<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  range = 1200;<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp;  while( fitness &lt; .1)<br />
&nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  int chance = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  int choice = rando(mutation_rate);<br />
&nbsp; &nbsp; &nbsp; &nbsp;  int selection = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  selection = randomization(1,2);<br />
&nbsp; &nbsp; &nbsp; &nbsp;  Individual newIndividualB;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  for(int i = 0; i &lt; 30; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  if(choice == 1)<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; double newData = hillVector[selection].GetData(i); //get the data from the chosen parent<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; newData = newData + range*(randomizationDouble(0,2)-1)*mutation_amount; //mutate it occording to the formula<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; newIndividualB.setData(i,newData); //set the new data into the corresponding index of the child object<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(newData &gt; range/2) //if the number goes out of the upper bounds<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  newIndividualB.setData(i,range/2);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if(newData &lt; ((range/2)*-1)) //if the number gooes out of the lower bounds<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  newIndividualB.setData(i,((range/2)*-1));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  else <br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; newIndividualB.setData(i,hillVector[selection].GetData(i));<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int iterations=0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int i=0; i &lt; 30; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  Individual newIndividualB (problem);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  newIndividualB.setData(i,newIndividualB.GetData(i)+newIndividualB.GetData(i)*((static_cast&lt;double&gt;(rand())/ static_cast&lt;double&gt;( RAND_MAX) *(2-0 + 1) + 0))*mutation_amount); <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  double newFitness=newIndividualB.GetFitness();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  iterations++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  if (newFitness &lt; fitness)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  { newIndividualB.MathProblemsFitness();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  replace(newIndividualB);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; iterations &lt;&lt; endl;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }&nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp;  }&nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp;  }<br />
//------------------------------------------------------------------------------<br />
Individual::Individual() <br />
&nbsp;  {<br />
&nbsp;  }<br />
&nbsp; <br />
double Individual::GetData(int index) const<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; return data[index]; <br />
&nbsp;  }<br />
&nbsp; <br />
void Individual::setData(int index, double numbers) <br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; data[index] = numbers;<br />
&nbsp;  }<br />
&nbsp; <br />
void Individual::SetProblem(int Problem) <br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; problem = Problem; <br />
&nbsp;  }<br />
<br />
Individual::Individual(int problem)<br />
/*<br />
Creates a new individual, and based on the problem, enters random values into <br />
a vector and passes that vector through MathProblemsFitness to create a fitness<br />
<br />
Pre-condition:user entered problem<br />
Post-condition: New individual created based on the problem choice and a fitness calculated<br />
*/<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; SetProblem(problem); <br />
&nbsp; &nbsp; &nbsp; if(problem == 1)<br />
&nbsp; &nbsp; &nbsp; {&nbsp; <br />
&nbsp; &nbsp; &nbsp; for(int i = 0; i &lt; 30; i++)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  data[i] = randomization(-65.536,65.536);<br />
&nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; else if(problem == 2)<br />
&nbsp; &nbsp; &nbsp; { <br />
&nbsp; &nbsp; &nbsp; for(int i = 0; i &lt; 30; i++)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  data[i] = randomization(-2.048,2.048);<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; else if(problem == 3)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; for(int i = 0; i &lt; 30; i++)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  data[i] = randomization(-600,600);<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; MathProblemsFitness();<br />
&nbsp;  }<br />
&nbsp;<br />
&nbsp;double Individual::randomization(double min, double max) <br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; return static_cast&lt;double&gt;(rand())/ static_cast&lt;double&gt;( RAND_MAX) *(max-min + 1) + min;<br />
&nbsp;  }<br />
&nbsp;<br />
&nbsp; &nbsp; void Individual::MathProblemsFitness()<br />
&nbsp; &nbsp; /*<br />
&nbsp; &nbsp; MathProblemsFitness defines the three math probelems (Schwefel, Rosenbrock, Griewangk)<br />
&nbsp; &nbsp; each vector from individual passes through these problems to calculate a fitness<br />
&nbsp; &nbsp; */<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; double holder = 0;<br />
&nbsp; &nbsp; &nbsp; double temp2 = 1;<br />
&nbsp; &nbsp; &nbsp; fitness = 0; <br />
&nbsp; &nbsp; &nbsp; int next = 1; <br />
&nbsp; &nbsp; &nbsp; if(problem == 1) <br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  for(int i = 0; i &lt; 30; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; holder = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(int j = 0; j &lt; next; j++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  holder = holder + data[j];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; next++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fitness = fitness + (holder*holder);<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; else if(problem == 2)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  for(int i = 0; i &lt; 29; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; holder = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; holder = 100*(data[i+1]-(data[i]*data[i]))*(data[i+1]-(data[i]*data[i])) + (data[i] - 1)*(data[i] - 1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fitness = fitness + holder;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; else if(problem == 3)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  for(int i = 0; i &lt; 30; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; holder = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; holder = (data[i]*data[i])/4000;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fitness = fitness+ holder;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  fitness = fitness + 1;<br />
&nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp;  for(int i = 0; i &lt; 30; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; holder = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; holder = cos(data[i]/sqrt(i+1));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; temp2 = temp2 * holder;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  fitness = fitness - temp2;<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp;  }<br />
//------------------------------------------------------------------------------&nbsp; &nbsp; <br />
GeneticAlgorithm::GeneticAlgorithm() <br />
&nbsp;  {<br />
&nbsp; <br />
&nbsp;  }<br />
&nbsp; <br />
&nbsp; GeneticAlgorithm::GeneticAlgorithm(int problem, int populationSize, double mutation_rate, double mutation_amount)<br />
&nbsp; /*<br />
&nbsp; Builds the population of individuals and pushes it into the mainVector, then loop through 5 times<br />
&nbsp; until the desired value is reached.<br />
&nbsp; */<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; UserInterface m;<br />
&nbsp; &nbsp; &nbsp; int iterations;<br />
&nbsp; &nbsp; &nbsp; for(int i = 0; i &lt; 5;&nbsp; i++)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  iterationNumber = 0; <br />
&nbsp; &nbsp; &nbsp; &nbsp;  for(int i = 0; i &lt; populationSize; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Individual I(problem); <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mainVector.push_back(I); <br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  int foundIt = 0; <br />
&nbsp; &nbsp; &nbsp; &nbsp;  checkAnswer(); <br />
&nbsp; &nbsp; &nbsp; &nbsp;  while(foundIt == 0 &amp;&amp; iterationNumber &lt; 5000000) <br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; foundIt = checkAnswer();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Optimize(problem, populationSize,mutation_rate, mutation_amount); <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; foundIt++;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }&nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp;  int index = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  double temp = mainVector[0].GetFitness(); <br />
&nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp;  for(int i = 1; i &lt; mainVector.get_size(); i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(temp &gt; mainVector[i].GetFitness())<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  temp = mainVector[i].GetFitness();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  index = i; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  individualResults.push_back(mainVector[index]);<br />
&nbsp; &nbsp; &nbsp; &nbsp;  iterationVector.push_back(iterationNumber);<br />
&nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp;  if(problem == 1)<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(iterationNumber &lt; m.getTimeResult(0))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  m.setTimeResult(0,iterationNumber);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  m.setDataResult(0,mainVector[index]);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp;  else if(problem == 2)<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(iterationNumber &lt; m.getTimeResult(1))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  m.setTimeResult(1,iterationNumber);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  m.setDataResult(1,mainVector[index]);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  else<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(iterationNumber &lt; m.getTimeResult(2))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  m.setTimeResult(2,iterationNumber);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  m.setDataResult(2,mainVector[index]);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  for(int i = 0; i &lt; populationSize; i++) <br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mainVector.pop();<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; <br />
&nbsp; &nbsp; &nbsp; cout &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Results: \n&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; &quot;\n&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; &quot;&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; for(int i = 0; i &lt; individualResults.get_size(); i++)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;Individual Best: &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  for(int j = 0; j &lt; 30; j++)<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; individualResults[i].data[j] &lt;&lt; &quot;\n&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt;&quot;&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;\n&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt; &quot;Fitness Level: &quot; &lt;&lt; individualResults[i].GetFitness() &lt;&lt; &quot;\n&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt; &quot;Iterations: &quot; &lt;&lt; iterationVector[i] &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; for(int i = 0; i &lt; individualResults.get_size(); i++)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  individualResults.pop();<br />
&nbsp; &nbsp; &nbsp; &nbsp;  iterationVector.pop();<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; cout &lt;&lt; endl;<br />
&nbsp;  }<br />
<br />
<br />
&nbsp; &nbsp; <br />
void&nbsp; GeneticAlgorithm::Optimize(int problem, int populationSize, double mutRate, double mutAmount)<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; parent1 = selection(populationSize);<br />
&nbsp; &nbsp; &nbsp; parent2= selection(populationSize);<br />
&nbsp; &nbsp; &nbsp; Breed(parent1,parent2,problem,mutRate,mutAmount); <br />
&nbsp;  }<br />
<br />
&nbsp; &nbsp; void GeneticAlgorithm::Breed(int parent1, int parent2, int problem, double mutation_rate,double mutation_amount)<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; Individual child(problem); <br />
&nbsp; &nbsp; &nbsp; double range = 0;<br />
&nbsp; &nbsp; &nbsp; if(problem == 1) <br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  range = 131.072;<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; else if(problem == 2)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  range = 4.096;<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  range = 1200;<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; for(int i = 0; i &lt; 30; i++)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  int selection = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  selection = randomization(1,2); <br />
&nbsp; &nbsp; &nbsp; &nbsp;  if(selection == 1)<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; selection = parent1; <br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  else<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; selection = parent2; <br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  int chance = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  int choice = rando(mutation_rate); <br />
&nbsp; &nbsp; &nbsp; &nbsp;  if(choice == 1) <br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; double newData = mainVector[selection].GetData(i);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; newData = newData + range*(randomizationDouble(0,2)-1)*mutation_amount; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; child.setData(i,newData); <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(newData &gt; range/2) <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  child.setData(i,range/2);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if(newData &lt; ((range/2)*-1)) <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  child.setData(i,((range/2)*-1));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  else <br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; child.setData(i,mainVector[selection].GetData(i));<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; child.SetProblem(mainVector[parent1].getProblem()); <br />
&nbsp; &nbsp; &nbsp; child.MathProblemsFitness(); <br />
&nbsp; &nbsp; &nbsp; replace(child); <br />
&nbsp;  }<br />
&nbsp; <br />
int GeneticAlgorithm::rando(double mutRate)<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; double number = rand() / (double)RAND_MAX;<br />
&nbsp; &nbsp; &nbsp; return number &lt; mutRate;<br />
&nbsp;  }<br />
<br />
void GeneticAlgorithm::replace(Individual child)<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; double temp = mainVector[0].GetFitness(); <br />
&nbsp; &nbsp; &nbsp; int index = 0; <br />
&nbsp; &nbsp; &nbsp; for(int i = 1; i &lt; mainVector.get_size(); i++)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  if(temp &lt; mainVector[i].GetFitness())<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; temp = mainVector[i].GetFitness();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; index = i; <br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; for(int i = 0; i &lt; 30; i++)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  mainVector[index].setData(i,child.GetData(i));<br />
&nbsp; &nbsp; &nbsp; &nbsp;  mainVector[index].MathProblemsFitness();<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; iterationNumber++; <br />
&nbsp;while (iterationNumber ==0)<br />
&nbsp; &nbsp; &nbsp; //if(iterationNumber %100 == 0) <br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp;  temp = mainVector[0].GetFitness(); <br />
&nbsp; &nbsp; &nbsp; &nbsp;  for(int i = 1; i &lt; mainVector.get_size(); i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(temp &gt; mainVector[i].GetFitness())<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  temp = mainVector[i].GetFitness();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;Best Fitness: &quot; &lt;&lt; iterationNumber &lt;&lt;&quot; &quot; &lt;&lt; temp &lt;&lt;endl; <br />
&nbsp; &nbsp; &nbsp; }&nbsp; <br />
<br />
&nbsp; &nbsp; <br />
&nbsp;  <br />
&nbsp;  }<br />
&nbsp; <br />
int GeneticAlgorithm::checkAnswer()<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; for(int i = 0; i &lt; mainVector.get_size(); i++)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  if(mainVector[i].GetFitness() &lt; .1)<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  else<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp;  }<br />
<br />
int GeneticAlgorithm::selection(int populationSize)<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; int choice = rand() % populationSize;<br />
&nbsp; &nbsp; &nbsp; int choice2 = rand() % populationSize;<br />
&nbsp; &nbsp; &nbsp; if(mainVector[choice].GetFitness() &lt; mainVector[choice2].GetFitness())<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  return choice;<br />
&nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp;  return choice2;<br />
&nbsp;  }<br />
&nbsp;<br />
&nbsp;int GeneticAlgorithm::randomization(int min, int max)<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; return static_cast&lt;int&gt;(( static_cast&lt;double&gt;(rand()))/ static_cast&lt;double&gt;( RAND_MAX) *(max-min + 1) + min);<br />
&nbsp;  }<br />
&nbsp; <br />
&nbsp; &nbsp; double GeneticAlgorithm::randomizationDouble(double min, double max)<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; return static_cast&lt;double&gt;(rand())/ static_cast&lt;double&gt;( RAND_MAX) *(max-min + 1) + min;<br />
&nbsp;  }</pre><br />
and Main<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
#include &quot;bpt0004_3.h&quot;<br />
<br />
using namespace std;<br />
<br />
int main() <br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; bool parameters = false, Problem = false, Optimization = false; <br />
&nbsp; &nbsp; &nbsp; UserInterface(parameters, Problem, Optimization);<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; return 0;<br />
&nbsp;  }</pre><br />
My error:<br />
1. first choose 1, then choose 2 for genetic algorithm<br />
2. choose 2, then input parameters within the ranges given<br />
3. choose 3, and choose 1(schwefel)<br />
4. choose 4 to optimize<br />
5. choose 5 &lt;-----this displays the correct number of iterations<br />
6. choose 3, and choose 2 or 1(Rosenbrock or Griewangk)<br />
7. choose 4 to optimize<br />
8. choose 5 &lt;-----This displays the error<br />
<br />
Error<br />
Genetic Iterations Schwefel: -1209686560<br />
Genetic Iterations Rosenbrock: 1<br />
Genetic Iterations Griewangk: -1079226444<br />
<br />
<br />
Why am i getting negative numbers and why is the iterations for rosenbrock just 1?? Please help me, this program is due tonight.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>bpt0004</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239833.html</guid>
		</item>
		<item>
			<title>Just after a little claification im on the right track</title>
			<link>http://www.daniweb.com/forums/thread239823.html</link>
			<pubDate>Thu, 19 Nov 2009 19:02:22 GMT</pubDate>
			<description>Good morning all, 
 
So i have started teaching myself C++ in preparation for taking software engineering at university next year, after many hours i have managed to put a simple program together, Im just asking if someone can tell me on in the right track to understanding what each function does...</description>
			<content:encoded><![CDATA[<div>Good morning all,<br />
<br />
So i have started teaching myself C++ in preparation for taking software engineering at university next year, after many hours i have managed to put a simple program together, Im just asking if someone can tell me on in the right track to understanding what each function does if i break it down, <br />
<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
using namespace std;</pre>So the iostream allows for keyboard input and the namespace is where code is stored? <br />
<br />
 <pre style="margin:20px; line-height:13px">&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Enter a real number: &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; x;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Enter a real number: &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; y;</pre>So the user is inputting a number to replace the x and the y with a value, <br />
<br />
 <pre style="margin:20px; line-height:13px">float x = 0.0;<br />
float y = 0.0;</pre>This is setting the integer value to 0, allowing the user to input a number to replace the 0, and i am using float because of the decimal point <br />
<br />
 <pre style="margin:20px; line-height:13px"> float a = x;<br />
&nbsp; &nbsp; &nbsp; &nbsp; float b = x;<br />
&nbsp; &nbsp; &nbsp; &nbsp; float c = x;<br />
&nbsp; &nbsp; &nbsp; &nbsp; float d = x;<br />
&nbsp; &nbsp; &nbsp; &nbsp; float e = x;</pre>This is storing the input from the console window? not 100% sure on what its doing...<br />
<br />
 <pre style="margin:20px; line-height:13px">&nbsp; &nbsp; &nbsp; &nbsp; a += y;<br />
&nbsp; &nbsp; &nbsp; &nbsp; b -= y;<br />
&nbsp; &nbsp; &nbsp; &nbsp; c *= y;<br />
&nbsp; &nbsp; &nbsp; &nbsp; d /= y;</pre>And i have no idea what this section does...<br />
<br />
 <pre style="margin:20px; line-height:13px">&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;x += y &quot; &lt;&lt; a &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;x -= y &quot; &lt;&lt; b &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;x *= y &quot; &lt;&lt; c &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;x /= y &quot; &lt;&lt; d &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;x %= y &quot; &lt;&lt; e &lt;&lt; endl;</pre>And this just outputs the information into the console window, Im pretty down with console output ;)<br />
<br />
As i said above, just looking for clarification that i have my mind on the right sort of track and am not embedding wrong information into my head.<br />
<br />
Thanks heaps in advance<br />
<br />
-Privoxy<br />
<br />
Edit:<br />
<br />
The full code in view<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
using namespace std;<br />
<br />
int main()<br />
<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; float x = 0.0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; float y = 0.0;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Enter a real number: &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; x;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Enter a real number: &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; y;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; float a = x;<br />
&nbsp; &nbsp; &nbsp; &nbsp; float b = x;<br />
&nbsp; &nbsp; &nbsp; &nbsp; float c = x;<br />
&nbsp; &nbsp; &nbsp; &nbsp; float d = x;<br />
&nbsp; &nbsp; &nbsp; &nbsp; float e = x;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; a += y;<br />
&nbsp; &nbsp; &nbsp; &nbsp; b -= y;<br />
&nbsp; &nbsp; &nbsp; &nbsp; c *= y;<br />
&nbsp; &nbsp; &nbsp; &nbsp; d /= y;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;x += y &quot; &lt;&lt; a &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;x -= y &quot; &lt;&lt; b &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;x *= y &quot; &lt;&lt; c &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;x /= y &quot; &lt;&lt; d &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;x %= y &quot; &lt;&lt; e &lt;&lt; endl;<br />
<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>Privoxy</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239823.html</guid>
		</item>
		<item>
			<title>return value is deleted before being passed on... how to avoid?</title>
			<link>http://www.daniweb.com/forums/thread239821.html</link>
			<pubDate>Thu, 19 Nov 2009 18:46:14 GMT</pubDate>
			<description><![CDATA[polynomial polynomial :: derivative(void) 
{ 
	polynomial outpoly; 
	outpoly._coef = new double [_degree]; 
	outpoly._degree = (_degree-1); 
	for(int i=0; i<(_degree); i++) 
	{ 
		outpoly._coef[i]=(i+1)*_coef[i+1]; 
	} 
	return outpoly;]]></description>
			<content:encoded><![CDATA[<div> <pre style="margin:20px; line-height:13px">polynomial polynomial :: derivative(void)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; polynomial outpoly;<br />
&nbsp; &nbsp; &nbsp; &nbsp; outpoly._coef = new double &#91;_degree&#93;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; outpoly._degree = (_degree-1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; for(int i=0; i&lt;(_degree); i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; outpoly._coef&#91;i&#93;=(i+1)*_coef&#91;i+1&#93;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; return outpoly;<br />
}<br />
<br />
//header:<br />
#pragma once<br />
<br />
#include &lt;complex&gt;<br />
#include &lt;iostream&gt;<br />
#include &lt;string&gt;<br />
#include &lt;sstream&gt;<br />
<br />
using namespace std;<br />
<br />
class polynomial<br />
{<br />
&nbsp; private:<br />
&nbsp; &nbsp; double * _coef;<br />
&nbsp; &nbsp; int _degree;&nbsp; &nbsp; <br />
&nbsp; public:<br />
&nbsp; &nbsp; // constructors&nbsp; &nbsp; <br />
&nbsp; &nbsp; polynomial(void);&nbsp; <br />
&nbsp; &nbsp; polynomial(int degree, double * coef);<br />
&nbsp; &nbsp; &nbsp; &nbsp; ~polynomial(void);<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; // at: evaluates the polynomial at x or z<br />
&nbsp; &nbsp; //&nbsp;  returns the real/complex value of the polynomial at x/z<br />
&nbsp; &nbsp; double at(double x) const;<br />
&nbsp; &nbsp; complex&lt;double&gt; at ( complex&lt;double&gt; z) const;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; polynomial derivative(void) const;<br />
&nbsp; &nbsp; &nbsp; &nbsp; bool isEmpty(void);<br />
&nbsp; &nbsp; &nbsp; &nbsp; string tostring(void);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; polynomial&amp; operator = (const polynomial&amp; rhs);<br />
&nbsp; &nbsp; friend ostream&amp; operator &lt;&lt; (ostream&amp; os, polynomial&amp; m);<br />
&nbsp; &nbsp; <br />
};<br />
<br />
//How I use it in main:<br />
double * coef;<br />
int degree;<br />
cout&lt;&lt; &quot;INPUT degree: &quot;;<br />
cin&gt;&gt;degree;<br />
coef = new double &#91;degree+1&#93;;<br />
for(int n = 0; n&lt;(degree+1); n++)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt; &quot;INPUT &quot; &lt;&lt; n &lt;&lt; &quot;th degree: &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cin&gt;&gt; coef&#91;n&#93;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;endl;<br />
}<br />
polynomial poly(degree, coef);<br />
cout&lt;&lt;&quot;INPUT converted to: &quot; &lt;&lt; poly&lt;&lt;endl;<br />
cout&lt;&lt;&quot;EVALUATE for x = &quot;;<br />
double x;<br />
cin &gt;&gt; x;<br />
cout &lt;&lt; poly &lt;&lt; &quot; = &quot; &lt;&lt; poly.at(x) &lt;&lt; endl;<br />
cout &lt;&lt; &quot;DERIVATIVE of fxn is: &quot; &lt;&lt; poly.derivative() &lt;&lt;endl;</pre><br />
I have code for handling polynomials via an array of coefficients. Now I want to create a function that returns its derivative in polynomial form.<br />
<br />
Unfortunately, the return value is deleted before it is passed on. I discovered this the hardway by following the debugger as closely as I could.<br />
<br />
How can I avoid this error?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>denizen08</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239821.html</guid>
		</item>
		<item>
			<title>Polynomial division</title>
			<link>http://www.daniweb.com/forums/thread239812.html</link>
			<pubDate>Thu, 19 Nov 2009 17:48:53 GMT</pubDate>
			<description><![CDATA[cout<<"hello,everybody!"; 
 
Can somebody come for the rescue? 
 
Please *My_problem(Is writing a fuction that divides two polynomials ) 
{ 
      return rescue; 
}]]></description>
			<content:encoded><![CDATA[<div>cout&lt;&lt;&quot;hello,everybody!&quot;;<br />
<br />
Can somebody come for the rescue?<br />
<br />
Please *My_problem(Is writing a fuction that divides two polynomials )<br />
{<br />
      return rescue;<br />
}</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>Rapmanseele</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239812.html</guid>
		</item>
		<item>
			<title>Counting vowels + consonants in string and using pointers</title>
			<link>http://www.daniweb.com/forums/thread239811.html</link>
			<pubDate>Thu, 19 Nov 2009 17:46:25 GMT</pubDate>
			<description><![CDATA[I'm confused with pointers. I'm not sure how to get the vowels to show up in Case A.  
 
Also, I would need help by how to get the program to run again after case A instead of ending the program after each case. Should it be in if/else statement instead of switch? Or use while loop with switch...]]></description>
			<content:encoded><![CDATA[<div>I'm confused with pointers. I'm not sure how to get the vowels to show up in Case A. <br />
<br />
Also, I would need help by how to get the program to run again after case A instead of ending the program after each case. Should it be in if/else statement instead of switch? Or use while loop with switch statement? <br />
<br />
Thanks and I appreciate any hints/help! :)<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;fstream&gt;<br />
#include &lt;iostream&gt;<br />
<br />
using namespace std;<br />
<br />
char* getStringFromUser();<br />
int consonants(char* str);&nbsp; //function to print out consonants<br />
int vowels(char* str);&nbsp; //function to print out vowels<br />
void stringCopy(char* str1, char* str2);<br />
<br />
int main ()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; //declare variables to use for storing user's input<br />
&nbsp; &nbsp; &nbsp; &nbsp; char choice; //first menu<br />
&nbsp; &nbsp; &nbsp; &nbsp; char line;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; //declare variables to use for program<br />
&nbsp; &nbsp; &nbsp; &nbsp; bool goagain = true;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int getNumStrings();<br />
&nbsp; &nbsp; &nbsp; &nbsp; fstream dataFile; //input stream for file&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; // introduction to the program <br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;\n\n------------------------------------------------&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;\n\nVowels &amp; Consonants&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dataFile.open(&quot;stringFile.txt&quot;, ios::out | ios::app); //open file<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (! dataFile) // test for error<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Error opening file.\n&quot;;&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;\n\nPlease select from the following menu items:\n&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;\t A)&nbsp; Count the vowels of a string.\n&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;\t B)&nbsp; Count the consonants of a string.\n&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;\t C)&nbsp; Count both vowels and consonants of a string.\n&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;\t D)&nbsp; Enter a string in the file.\n&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;\t E)&nbsp; Count the number of strings in the file.\n&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;\t F)&nbsp; Exit this program.\n\n&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;\t Enter A, B, C, D, E, or F: &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; choice; //user choice of menu<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; switch(choice)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 'A':&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; getStringFromUser();<br />
//&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; vowels(line, vowels);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 'B':&nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;choice B&quot;;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 'C':&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;choice C&quot;; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 'D':&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;choice D&quot;; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 'E':&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;choice E&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 'F':&nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;\n\nGoodbye!&quot; &lt;&lt; endl;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; default: cout &lt;&lt; &quot;That is an invalid choice.\n&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dataFile.close(); //close text file&nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
}//end of function<br />
<br />
char* getStringFromUser()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; char line[100];<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Enter a string: &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cin.ignore();<br />
&nbsp; &nbsp; &nbsp; &nbsp; cin.getline(line, 100, '\n');<br />
}&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
int vowels(char* str)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; char vowelsArray[] = {'A', 'a', 'E', 'e', 'I', 'i', 'O', 'o', 'U', 'u', '\0'};<br />
&nbsp; &nbsp; &nbsp; &nbsp; char *vowelsPtr = vowelsArray;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int numVowels = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int count;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;The vowels in the string are: &quot;;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; while(*str != '\0')<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(count = 0; count &lt;10; count++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (*str == *vowelsPtr)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; numVowels++; //Point to next element<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;The vowels in the string are: &quot; &lt;&lt; *vowelsPtr &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; str++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vowelsPtr = vowelsArray; //set vowelsPtr to first element again<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;\n\n&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; return numVowels;<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>kryz</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239811.html</guid>
		</item>
		<item>
			<title>need help</title>
			<link>http://www.daniweb.com/forums/thread239810.html</link>
			<pubDate>Thu, 19 Nov 2009 17:36:59 GMT</pubDate>
			<description><![CDATA[Hi everyone!! I am Kevin, and I am new to this site. I am taking C++ classes and have trouble writing this program. I  know I have to use several "for" loops and "rand" commands to write it but i am not exactly sure how to do that?? so, please can anyone help me with this?  the question is: 
 
Use...]]></description>
			<content:encoded><![CDATA[<div>Hi everyone!! I am Kevin, and I am new to this site. I am taking C++ classes and have trouble writing this program. I  know I have to use several &quot;for&quot; loops and &quot;rand&quot; commands to write it but i am not exactly sure how to do that?? so, please can anyone help me with this?  the question is:<br />
<br />
Use a two dimensional array to solve the following problem. A company has four salesperson (1 to 4) who sell five different different products (1 to 5). Once a day, each salesperson passes in a slip for each different type of product sold. Each slip contains:<br />
     1) salesperson number.<br />
     2) the product number.<br />
     3) total dollar value of the product sold that day.<br />
<br />
Each sales person passes between 0 to 5 sales slips perday. Assume that the information from all of the slips for last week is avaible. Write a program that will read all this information and summarize the total sales by salesperson by products. All totals should be stored in a two dimensional array sales. After processing all the information print the result in tabular format with each column representing a particular salesperson and each row representing a particular product. Cross total each row to get the total sales of each product and cross total each column to get the total sales by salesperson. your tabular printout should include these cross totals to the right of the totaled rows and bottom of the totaled columns.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>kkevin</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239810.html</guid>
		</item>
		<item>
			<title>not sure why i am outputting all zeros</title>
			<link>http://www.daniweb.com/forums/thread239800.html</link>
			<pubDate>Thu, 19 Nov 2009 16:57:16 GMT</pubDate>
			<description><![CDATA[So this is a matching game, flip over two cards, if they match they stay up if not they flip over again.  I have the matching system and coordinate system working.  My problem is that when i use my array of zeros to "hide" the numbers, all that is ever output is the zeros. 
 
Any ideas on why this...]]></description>
			<content:encoded><![CDATA[<div>So this is a matching game, flip over two cards, if they match they stay up if not they flip over again.  I have the matching system and coordinate system working.  My problem is that when i use my array of zeros to &quot;hide&quot; the numbers, all that is ever output is the zeros.<br />
<br />
Any ideas on why this might be happening?  also any ideas on using something other than the number 0 for my grid? like an *? i couldn't figure out how to get an array to take them.<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
#include &lt;cstdlib&gt;<br />
#include &lt;ctime&gt;<br />
using namespace std;<br />
<br />
int main()<br />
{<br />
&nbsp; &nbsp; char comma;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int row1, column1, row2, column2, cards[4][4], cards_unflipped[4][4] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} , counter(0);<br />
<br />
&nbsp; &nbsp; srand((unsigned)time(NULL));<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; //fill board with pairs<br />
&nbsp; &nbsp; &nbsp; &nbsp; bool makeNext = false;<br />
&nbsp; &nbsp; &nbsp; &nbsp; bool nullexists = true;<br />
&nbsp; &nbsp; &nbsp; &nbsp; memset(cards, 0, sizeof(cards));<br />
&nbsp; &nbsp; &nbsp; &nbsp; srand(time(NULL));<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for( int i = 1; i &lt; 9; i++ )<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; makeNext = false;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while(!makeNext)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int x1, y1, x2, y2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x1 = rand()%4;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; y1 = rand()%4;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x2 = rand()%4;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; y2 = rand()%4;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if( (x1 != x2 || y1 != y2) &amp;&amp; (cards[x1][y1] == 0 &amp;&amp; cards[x2][y2] == 0) )<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cards[x1][y1] = i;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cards[x2][y2] = i;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; makeNext = true;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for( int i = 0; i &lt; 4; i++ )<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for( int c = 0; c &lt; 4; c++ )<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; cards[i][c] &lt;&lt; &quot; &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; //display board<br />
&nbsp;  while (nullexists = true)<br />
<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  //selection<br />
&nbsp; &nbsp; cout&lt;&lt;&quot;Please select the first card row and column seperated by a comma.\n&quot;;<br />
&nbsp; &nbsp; cin&gt;&gt;row1&gt;&gt;comma&gt;&gt;column1;<br />
<br />
&nbsp; &nbsp; cout&lt;&lt;&quot;Please select the second card row and column seperated by a comma.\n&quot;;<br />
&nbsp; &nbsp; cin&gt;&gt;row2&gt;&gt;comma&gt;&gt;column2;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  if (cards[row1][column1]==cards[row2][column2])<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cards_unflipped[row1][column1] = cards[row1][column1];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cards_unflipped[row2][column2] = cards[row2][column2];<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; counter = counter++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (counter == 8)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bool nullexists = false;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  //reveal the flipped cards<br />
&nbsp; &nbsp; cout&lt;&lt;&quot;&nbsp; &nbsp; 1 2 3 4\n&quot;;<br />
&nbsp; &nbsp; cout&lt;&lt;&quot;&nbsp; &quot;;<br />
&nbsp; &nbsp; for (int i=0; i&lt;=8; i++)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;-&quot;;<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; cout&lt;&lt;endl;<br />
&nbsp; &nbsp; for (int r=0; r&lt;4; r++)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;r+1&lt;&lt;&quot; | &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (int c=0; c&lt;4; c++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;cards_unflipped[r][c]&lt;&lt;&quot; &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; }<br />
<br />
&nbsp;  cout &lt;&lt; &quot;You Won!&quot; &lt;&lt; endl;<br />
&nbsp; <br />
<br />
&nbsp; &nbsp; return 0;<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>Ponomous</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239800.html</guid>
		</item>
		<item>
			<title>Help with a big project if you can help.</title>
			<link>http://www.daniweb.com/forums/thread239786.html</link>
			<pubDate>Thu, 19 Nov 2009 15:37:42 GMT</pubDate>
			<description>I have a project that requires me to make a search engine for classes. If i were to enter Biology, then classes such as genetics, chemistry, anatomy and physiology are to show up. But the thing is i have the classes and their descriptions in a file and i was wondering if anyone can give me some...</description>
			<content:encoded><![CDATA[<div>I have a project that requires me to make a search engine for classes. If i were to enter Biology, then classes such as genetics, chemistry, anatomy and physiology are to show up. But the thing is i have the classes and their descriptions in a file and i was wondering if anyone can give me some pointers on how to atleast start the project. I really don't know how to group the classes together so that I can compare the words and come up with results....or is there a better way?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>reese27</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239786.html</guid>
		</item>
		<item>
			<title>Calculate percentage problem</title>
			<link>http://www.daniweb.com/forums/thread239792.html</link>
			<pubDate>Thu, 19 Nov 2009 15:10:16 GMT</pubDate>
			<description><![CDATA[hi, I'm trying to calculate the percentage of an ammount of boxes in C. Ex: 4400. 
I have the next code:  
#include<iostream.h> 
#include<conio.h> 
main() 
{ 
double a=2400; 
double b=8000; 
double per=0; 
per=2400*100/8000;]]></description>
			<content:encoded><![CDATA[<div>hi, I'm trying to calculate the percentage of an ammount of boxes in C. Ex: 4400.<br />
I have the next code: <br />
 <pre style="margin:20px; line-height:13px">#include&lt;iostream.h&gt;<br />
#include&lt;conio.h&gt;<br />
main()<br />
{<br />
double a=2400;<br />
double b=8000;<br />
double per=0;<br />
per=2400*100/8000;<br />
cout&lt;&lt;per;<br />
getch();<br />
}</pre>and return a negative value. I try to asign values at differents variables like:<br />
<br />
 <pre style="margin:20px; line-height:13px">double confused=241541;<br />
double moreconfused=145621;<br />
long int percf=1452145;<br />
cout&lt;&lt;confused&lt;&lt;endl&lt;&lt;moreconfused&lt;&lt;percf;</pre>and return negatives values too, <br />
please, somebody can help me?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>bernaprog</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239792.html</guid>
		</item>
		<item>
			<title>help me to loop pls</title>
			<link>http://www.daniweb.com/forums/thread239755.html</link>
			<pubDate>Thu, 19 Nov 2009 13:49:51 GMT</pubDate>
			<description>this is the output 
when enter 1 
*********O* 
when enter 2 
********O** 
---------------------------- 
1*********O* 
2********O** 
3*******O*** 
4******O****</description>
			<content:encoded><![CDATA[<div>this is the output<br />
when enter 1<br />
*********O*<br />
when enter 2<br />
********O**<br />
----------------------------<br />
1*********O*<br />
2********O**<br />
3*******O***<br />
4******O****<br />
5*****O*****<br />
.<br />
.<br />
.<br />
.<br />
.<br />
.<br />
.<br />
<br />
help me plss<br />
tnx</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>xtian3</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239755.html</guid>
		</item>
		<item>
			<title>please take a look at this C++ MySQL issue and help</title>
			<link>http://www.daniweb.com/forums/thread239753.html</link>
			<pubDate>Thu, 19 Nov 2009 13:47:37 GMT</pubDate>
			<description><![CDATA[Hi there, 
 
here what my problem is - I'm trying to get data from MySQL database put in on global array and make calculation. The data in the MySQL table is 3000 rows and 2 columns. The type of data is double and date  
 
Here is the code: 
  <div class="codeblock"> <div class="spaced"> <div...]]></description>
			<content:encoded><![CDATA[<div>Hi there,<br />
<br />
here what my problem is - I'm trying to get data from MySQL database put in on global array and make calculation. The data in the MySQL table is 3000 rows and 2 columns. The type of data is double and date <br />
<br />
Here is the code:<br />
 <pre style="margin:20px; line-height:13px">#include &lt;stdlib.h&gt;<br />
#include &lt;iostream&gt;<br />
#include &lt;mysql.h&gt;<br />
#include &lt;stdio.h&gt;<br />
<br />
MYSQL conn;<br />
MYSQL_RES *res;<br />
MYSQL_ROW msq_row;<br />
<br />
int main()<br />
{<br />
<br />
&nbsp; &nbsp; double mysql_result[3000][2];<br />
&nbsp; &nbsp; int i;<br />
&nbsp; &nbsp; int j;<br />
&nbsp; &nbsp; int history=3000;<br />
<br />
&nbsp; <br />
&nbsp; &nbsp; mysql_init(&amp;conn);<br />
&nbsp; &nbsp; mysql_real_connect(&amp;conn, &quot;localhost&quot;, &quot;root&quot;, &quot;1a2s3d&quot;, &quot;portfolio&quot;, 0, NULL, 0);<br />
<br />
&nbsp; &nbsp; mysql_query(&amp;conn, &quot;SELECT date, close from quotes where companyID=1&quot;);<br />
<br />
&nbsp; &nbsp; res=mysql_use_result(&amp;conn);<br />
<br />
&nbsp; <br />
<br />
&nbsp; &nbsp; for (j=0;j=history;j++)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (i=0;i=mysql_num_fields(res);i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; msq_row=mysql_fetch_row(res);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mysql_result[3000][2]=msq_row;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;%d\n&quot;,msq_row[i]);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; mysql_free_result(res);<br />
&nbsp; &nbsp; mysql_close(&amp;conn);<br />
&nbsp; &nbsp;  <br />
<br />
<br />
&nbsp; &nbsp; return (EXIT_SUCCESS);<br />
}</pre><br />
the cygwin g++ compiler give this:<br />
<br />
/usr/bin/make -f nbproject/Makefile-Debug.mk SUBPROJECTS= .build-conf<br />
make[1]: Entering directory `/cygdrive/c/Program Files/MyPrograms/Apache/htdocs/QuadProg++/Pordotovka'<br />
/usr/bin/make  -f nbproject/Makefile-Debug.mk dist/Debug/Cygwin-Windows/pordotovka.exe<br />
make[2]: Entering directory `/cygdrive/c/Program Files/MyPrograms/Apache/htdocs/QuadProg++/Pordotovka'<br />
mkdir -p build/Debug/Cygwin-Windows<br />
rm -f build/Debug/Cygwin-Windows/main.o.d<br />
g++    -c -g -MMD -MP -MF build/Debug/Cygwin-Windows/main.o.d -o build/Debug/Cygwin-Windows/main.o main.cpp<br />
main.cpp: In function `int main()':<br />
<span style="text-decoration:underline"><span style="color:Red">main.cpp:45: error: cannot convert `char**' to `double' in assignment</span></span><br />
make[2]: *** [build/Debug/Cygwin-Windows/main.o] Error 1<br />
make[2]: Leaving directory `/cygdrive/c/Program Files/MyPrograms/Apache/htdocs/QuadProg++/Pordotovka'<br />
make[1]: *** [.build-conf] Error 2<br />
make[1]: Leaving directory `/cygdrive/c/Program Files/MyPrograms/Apache/htdocs/QuadProg++/Pordotovka'<br />
make: *** [.build-impl] Error 2<br />
BUILD FAILED (exit value 2, total time: 828ms)<br />
<br />
Please give me gleam ... thank you</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>spekulanta</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239753.html</guid>
		</item>
		<item>
			<title>Asyncronous Overlapped structure problem (using HttpwaitforDisconnect)</title>
			<link>http://www.daniweb.com/forums/thread239706.html</link>
			<pubDate>Thu, 19 Nov 2009 10:59:26 GMT</pubDate>
			<description>Hello guys, I am having trouble getting an asyncronous communications set up using overlapping. Actually to be more specific I am having problems with using httpWaitForDisconnect to work as async. 
Using the code below I am able to enter the function, but it is in a blocking state which defeats all...</description>
			<content:encoded><![CDATA[<div>Hello guys, I am having trouble getting an asyncronous communications set up using overlapping. Actually to be more specific I am having problems with using httpWaitForDisconnect to work as async.<br />
Using the code below I am able to enter the function, but it is in a blocking state which defeats all the purposes of me trying to use this function in the first place.<br />
The Code:<br />
<br />
 <pre style="margin:20px; line-height:13px">HANDLE hQueue;<br />
HTTP_REQUEST* pHttpData;<br />
ULONG ulReturn = 0;<br />
<br />
OVERLAPPED* ovlp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; ZeroMemory(&amp;ovlp, sizeof(&amp;ovlp));<br />
ulReturn = HttpReceiveHttpRequest(hQueue, RequestId, 0, pHttpData, dwBufferSize, &amp;dwSizeReceived, ovlp);<br />
RequestId = pHttpData-&gt;RequestId;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (ulReturn == ERROR_INVALID_PARAMETER)&nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AddToTraceLog(&quot;HttpReceiveHttpRequest : Invalid Parameter&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AddToTraceLog(&quot;Going into the disconnect&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ulReturn = HttpWaitForDisconnect(hQueue, pHttpData-&gt;ConnectionId, ovlp);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; switch(ulReturn)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case NO_ERROR:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AddToTraceLog(&quot;User Has Disconnected...&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case ERROR_IO_PENDING:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AddToTraceLog(&quot;IO Pending, next request not ready...&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case ERROR_INVALID_PARAMETER:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AddToTraceLog(&quot;Error&quot; + getLastError());<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</pre><br />
Thank you in advance.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>JenniLei</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239706.html</guid>
		</item>
		<item>
			<title><![CDATA[Compiler skips "cin.get();"]]></title>
			<link>http://www.daniweb.com/forums/thread239691.html</link>
			<pubDate>Thu, 19 Nov 2009 09:44:15 GMT</pubDate>
			<description><![CDATA[this is a simple example of a problem I have been having with differing programs, i am using linux ubuntu 9.10 and codeblocks 8.02 .  
 
this is the code   <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a...]]></description>
			<content:encoded><![CDATA[<div>this is a simple example of a problem I have been having with differing programs, i am using linux ubuntu 9.10 and codeblocks 8.02 . <br />
<br />
this is the code  <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
<br />
using namespace std;<br />
int main()<br />
{<br />
&nbsp; &nbsp; int hiya;<br />
&nbsp; &nbsp; cout&lt;&lt;&quot;hello world \n&quot;;<br />
&nbsp; &nbsp; cin.get();<br />
&nbsp; &nbsp; cout&lt;&lt;&quot;enter a number \n&quot;;<br />
&nbsp; &nbsp; cin&gt;&gt;hiya;<br />
&nbsp; &nbsp; cout&lt;&lt;&quot;you entered \n&quot;&lt;&lt; hiya;<br />
&nbsp; &nbsp; cin.get();<br />
}</pre><br />
it compiles but show an error message &quot;warning GDB: Failed to set controlling terminal: operation not permitted&quot;<br />
<br />
then the program runs<br />
<br />
when it gets to the last cin instead of waiting for some input it exits</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>duke.tim</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239691.html</guid>
		</item>
		<item>
			<title>Help</title>
			<link>http://www.daniweb.com/forums/thread239683.html</link>
			<pubDate>Thu, 19 Nov 2009 08:38:31 GMT</pubDate>
			<description>Problem Statement: File Handling in C/C++ 
On the basis of the given scenario create a file Expenses.txt, Open the file and copy into another  Expenses2.txt, Also show output on screen 
A college has announced the total budget of 50,000Rs.for each game. Games are done four times in a year. Take...</description>
			<content:encoded><![CDATA[<div>Problem Statement: File Handling in C/C++<br />
On the basis of the given scenario create a file Expenses.txt, Open the file and copy into another  Expenses2.txt, Also show output on screen<br />
A college has announced the total budget of 50,000Rs.for each game. Games are done four times in a year. Take expenses as an input from user. <br />
Calculate the average expenses for a game:<br />
<br />
<br />
<br />
<br />
<br />
1.	If the expenses greater than 80% show as” Very Expensive”.<br />
2.	If the expenses  are greater than 60% and less than 80% than show “Expensive ”<br />
3.	If the expenses  are greater than 50% and less than 60% than show “Less Expensive ”<br />
4.	If the expenses are greater than 40% and less than 50% than show “Not Costly”.<br />
5.	If the expenses are less than 40% than show “Best”.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>ihtesham4deni</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239683.html</guid>
		</item>
		<item>
			<title>complex number</title>
			<link>http://www.daniweb.com/forums/thread239643.html</link>
			<pubDate>Thu, 19 Nov 2009 04:51:11 GMT</pubDate>
			<description><![CDATA[the program is ok(i think)but the data is fixed.i want it able to input your own data.i tried cin>>c1.real>>c1.image; 
                                   cin>>c2.real>>c2.image; 
but it cannot use them because they are private... 
 
 
#include<iostream> 
using namespace std; 
class complex 
{...]]></description>
			<content:encoded><![CDATA[<div>the program is ok(i think)but the data is fixed.i want it able to input your own data.i tried cin&gt;&gt;c1.real&gt;&gt;c1.image;<br />
                                   cin&gt;&gt;c2.real&gt;&gt;c2.image;<br />
but it cannot use them because they are private...<br />
<br />
 <pre style="margin:20px; line-height:13px">#include&lt;iostream&gt;<br />
using namespace std;<br />
class complex<br />
{<br />
public:<br />
<br />
complex(){real=0;image=0;}<br />
<br />
complex(double r,double i){real=r;image=i;}<br />
<br />
complex complex_add(complex &amp;c2);<br />
<br />
complex complex_sub(complex &amp;c2);<br />
<br />
complex complex_mult(complex &amp;c2);<br />
<br />
complex complex_div(complex &amp;c2);<br />
void display();<br />
<br />
private:<br />
&nbsp; &nbsp; &nbsp; &nbsp; double real;<br />
&nbsp; &nbsp; &nbsp; &nbsp; double image;<br />
};<br />
<br />
<br />
complex complex::complex_add(complex &amp;c2)<br />
{<br />
complex c;<br />
<br />
c.real=real+c2.real;<br />
<br />
c.image=image+c2.image;<br />
<br />
return c;<br />
}<br />
<br />
complex complex::complex_sub(complex &amp;c2)<br />
<br />
{<br />
&nbsp;complex d;<br />
<br />
d.real=real-c2.real;<br />
<br />
d.image=image-c2.image;<br />
<br />
return d;<br />
}<br />
<br />
complex complex::complex_mult(complex &amp;c2)<br />
{<br />
complex f;<br />
<br />
f.real=real*c2.real;<br />
<br />
f.image=image*c2.image;<br />
<br />
return f;<br />
}<br />
<br />
complex complex::complex_div(complex &amp;c2)<br />
{<br />
&nbsp;complex g;<br />
&nbsp;g.real=real/c2.real;<br />
&nbsp;g.image=image/c2.image;<br />
&nbsp;return g;<br />
}<br />
<br />
<br />
void complex::display()<br />
{<br />
&nbsp; cout&lt;&lt;&quot;(&quot;&lt;&lt;real&lt;&lt;&quot;,&quot;&lt;&lt;image&lt;&lt;&quot;i)&quot;&lt;&lt;endl;<br />
}<br />
<br />
<br />
int main()<br />
{<br />
complex c1(2,5),c2(4,9),c3;&nbsp; //i want input my own complex number.<br />
c3=c1.complex_add(c2);<br />
cout&lt;&lt;&quot;c1=&quot;;c1.display();<br />
cout&lt;&lt;&quot;c2=&quot;;c2.display();<br />
cout&lt;&lt;&quot;c1+c2=&quot;;c3.display();<br />
<br />
c3=c1.complex_sub(c2);<br />
cout&lt;&lt;&quot;c1=&quot;;c1.display();<br />
cout&lt;&lt;&quot;c2=&quot;;c2.display();<br />
cout&lt;&lt;&quot;c1-c2=&quot;;c3.display();<br />
<br />
c3=c1.complex_mult(c2);<br />
cout&lt;&lt;&quot;c1=&quot;;c1.display();<br />
cout&lt;&lt;&quot;c2=&quot;;c2.display();<br />
cout&lt;&lt;&quot;c1*c2=&quot;;c3.display();<br />
<br />
c3=c1.complex_div(c2);<br />
cout&lt;&lt;&quot;c1=&quot;;c1.display();<br />
cout&lt;&lt;&quot;c2=&quot;;c2.display();<br />
cout&lt;&lt;&quot;c1/c2=&quot;;c3.display();<br />
<br />
return 0;<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>nick30266</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239643.html</guid>
		</item>
		<item>
			<title>Class Composition Confusion</title>
			<link>http://www.daniweb.com/forums/thread239639.html</link>
			<pubDate>Thu, 19 Nov 2009 04:24:46 GMT</pubDate>
			<description><![CDATA[Today was my first time trying composition. It's for a lab project due Friday, and I have a lot of tomorrow to work on it. However, up until we have just been using one class per program. Now, my teacher wants us to use composition and arrays, despite only lecturing on them for a few minutes....]]></description>
			<content:encoded><![CDATA[<div>Today was my first time trying composition. It's for a lab project due Friday, and I have a lot of tomorrow to work on it. However, up until we have just been using one class per program. Now, my teacher wants us to use composition and arrays, despite only lecturing on them for a few minutes. Worse, there is no section on composition (and arrays in compositions) in our notes/textbook. So, could you check this code and tell me if I'm on the right track. I don't even need help with syntactical errors (yet); I just need an idea of what I need to do, and what I'm not understanding about composition. <br />
<br />
There are five files, and an input file. And the program (as you can see from the input file) reads the student info and stores it in an array and then outputs (1) all information in a table, (2) a student searched by last name, (3) lowest gpa student information, (4) highest units gpa information.<br />
<br />
Thank you very much.<br />
<br />
student.h<br />
 <pre style="margin:20px; line-height:13px"> #ifndef student_H<br />
#define student_H<br />
<br />
#include &lt;string&gt;<br />
<br />
using namespace std;<br />
<br />
class Student{<br />
&nbsp; &nbsp; &nbsp; &nbsp; public:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; void set_Name(string, string);&nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bool readStudent(ifstream &amp;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; void printStudent () const;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Student();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; string get_Last();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; string get_First();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; void set_Major(string);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; string get_Major( );<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int get_Units();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; void set_Units(int);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; float get_GPA();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; void set_GPA(float);<br />
&nbsp; &nbsp; &nbsp; &nbsp; private:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; string&nbsp; First, Last;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Units;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; float&nbsp; &nbsp; &nbsp; &nbsp; GPA;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; string&nbsp; &nbsp; &nbsp; &nbsp; Major; <br />
};<br />
<br />
#endif</pre><br />
Student Implementation<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
#include &lt;fstream&gt;<br />
#include &quot;student.h&quot;<br />
<br />
using namespace std;<br />
void Student::set_Name(string first, string last){<br />
&nbsp; &nbsp; &nbsp; &nbsp; First = first;<br />
&nbsp; &nbsp; &nbsp; &nbsp; Last = last ;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
}<br />
<br />
bool Student::readStudent(ifstream &amp; fin){<br />
&nbsp; &nbsp; &nbsp; &nbsp; getline(fin, First);<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (fin){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  getline(fin, Last);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; getline(fin, Major);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fin &gt;&gt; Units ;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fin &gt;&gt; GPA ;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fin.ignore(10,'\n');<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; return (fin.good());<br />
}<br />
void Student::printStudent () const<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt;&quot;\n\tStudent information:\n&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Name:&nbsp;  \t&quot; &lt;&lt; Last +&quot;, &quot;+ First &lt;&lt;endl ;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Major:&nbsp; \t&quot; &lt;&lt; Major &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Units : \t&quot;&lt;&lt; Units &lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;GPA:&nbsp; &nbsp; \t&quot; &lt;&lt; GPA &lt;&lt; endl &lt;&lt;endl;<br />
}<br />
<br />
Student::Student(){<br />
&nbsp; &nbsp; &nbsp; &nbsp; Units = 0 ;<br />
&nbsp; &nbsp; &nbsp; &nbsp; GPA = 0 ;<br />
};<br />
string Student::get_Last(){<br />
&nbsp; &nbsp; &nbsp; &nbsp; return Last; <br />
}<br />
<br />
void Student::set_Major(string t_major){<br />
&nbsp; &nbsp; &nbsp; &nbsp; Major = t_major;<br />
}<br />
int Student::get_Units(){<br />
&nbsp; &nbsp; &nbsp; &nbsp; return Units;<br />
}&nbsp; &nbsp; &nbsp; &nbsp; <br />
float Student::get_GPA(){<br />
&nbsp; &nbsp; &nbsp; &nbsp; return GPA;<br />
}&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
string Student::get_First(){<br />
&nbsp; &nbsp; &nbsp; &nbsp; return First ;<br />
}<br />
string Student::get_Major( ){<br />
&nbsp; &nbsp; &nbsp; &nbsp; return Major ;<br />
}<br />
void Student::set_Units(int units){<br />
&nbsp; &nbsp; &nbsp; &nbsp; Units = units ;<br />
}<br />
void Student::set_GPA(float gpa){<br />
&nbsp; &nbsp; &nbsp; &nbsp; GPA = gpa ;<br />
}</pre><br />
school.h<br />
 <pre style="margin:20px; line-height:13px"> #ifndef school_H<br />
#define school_H<br />
#define SIZE 15<br />
<br />
#include &lt;string&gt;<br />
#include &quot;student.h&quot;<br />
<br />
using namespace std;<br />
<br />
class School{<br />
&nbsp; &nbsp; &nbsp; &nbsp; public:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int read_list(Student list[], int size);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bool open_file(ifstream &amp;fin);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; void print_list(Student list[], int size);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int search(Student list[], int);&nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int low_GPA(Student list[], int);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int high_Units(Student list[], int);<br />
&nbsp; &nbsp; &nbsp; &nbsp; private:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Student CS101[SIZE];<br />
};<br />
<br />
#endif</pre><br />
School Implementation<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
#include &lt;fstream&gt;<br />
#include &lt;iomanip&gt;<br />
#include &quot;school.h&quot;<br />
<br />
using namespace std;<br />
int School::search(Student list[], int size){<br />
&nbsp; &nbsp; &nbsp; &nbsp; string&nbsp; &nbsp; &nbsp; &nbsp; target;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt;&quot;\nPlease enter last name of student to locate:(all lower case) &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; getline(cin, target);<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (target.length()&gt; 0){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; target[0] = toupper(target[0]); // convert first character to lower case<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int i = 0 ; i &lt; size ; i++){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if((int)(list[i].get_Last()).find(target)&gt;=0 )<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return i ;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt;&quot;No name was entered.\n&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; return -1 ;&nbsp; // Student was not found on the list;<br />
}<br />
<br />
int School::read_list(Student list[], int size)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; ifstream fin ;<br />
&nbsp; &nbsp; &nbsp; &nbsp; bool&nbsp; &nbsp; &nbsp; &nbsp; flag ;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int i = 0 ;<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (open_file(fin))<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; flag = list[i].readStudent(fin);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while(flag &amp;&amp; !fin.eof())<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; i++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (i &lt; size)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; flag = list[i].readStudent(fin);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt;&quot;\n*********** Array is full.\n&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break ;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; return i ;<br />
}<br />
<br />
bool School::open_file(ifstream &amp;fin)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; string&nbsp; f_name ;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; counter = 3 ;<br />
&nbsp; &nbsp; &nbsp; &nbsp; bool&nbsp; &nbsp; &nbsp; &nbsp; flag = true;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; do{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; flag = true ;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt;&quot;Please enter input file name: &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; getline(cin, f_name) ;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fin.open(f_name.c_str());<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (fin.fail())<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; counter-- ;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt;&quot;\nBad file name, you have &quot;&lt;&lt; counter &lt;&lt; &quot; chances, try again.\n&quot; ;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fin.clear();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; flag =&nbsp; false ;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }while (!flag &amp;&amp; counter &gt;= 0);<br />
&nbsp; &nbsp; &nbsp; &nbsp; return flag ;<br />
}<br />
void School::print_list(Student list[], int size)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (size &gt; 0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt;endl &lt;&lt;endl&lt;&lt;left&lt;&lt; setprecision(2) &lt;&lt;showpoint&lt;&lt;fixed;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; setw(50)&lt;&lt; &quot;Name&quot;&lt;&lt;setw(30)&lt;&lt;&quot;Major&quot;&lt;&lt;setw(12)&lt;&lt;&quot;Units&quot;&lt;&lt;&quot;GPA\n&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; setfill('-') &lt;&lt; setw(100)&lt;&lt;&quot;-&quot; &lt;&lt; setfill(' ')&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int i = 0 ; i &lt; size ; i++){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; setw(50)&lt;&lt;list[i].get_Last() + &quot;, &quot; + list[i].get_First() &lt;&lt; setw(30) &lt;&lt; list[i].get_Major();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; setw(12) &lt;&lt; list[i].get_Units() &lt;&lt; list[i].get_GPA() &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt;endl &lt;&lt;endl &lt;&lt; &quot;****** end of report ******\n\n&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}<br />
<br />
int School::low_GPA(Student list[], int size)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; int lowIndex;<br />
&nbsp; &nbsp; &nbsp; &nbsp; float first, second, lowGPA = 5.0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; if(size &gt; 0){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int i = 0 ; i &lt; size ; i++){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; first = list[i].CS101.get_GPA();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; second = list[i+1].CS101.get_GPA();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (first &lt; lowGPA &amp;&amp; first &gt; 0.00){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lowIndex = i;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lowGPA = list[i].CS101.get_GPA();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (second &lt; lowGPA &amp;&amp; second &gt; 0.00){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lowIndex = (i+1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lowGPA = list[i+1].CS101.get_GPA();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return lowIndex;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
}<br />
<br />
int School::high_Units(Student list[], int size)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; int first, second, highIndex, highUnits = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; if(size &gt; 0){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int i = 0 ; i &lt; size ; i++){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; first = list[i].CS101.get_Units();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; second = list[i+1].CS101.get_Units();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (first &gt; highUnits){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; highIndex = i;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; highUnits = list[i].CS101.get_Units();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (second &gt; highUnits){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; highIndex = (i+1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; highUnits = list[i+1].CS101.get_Units();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return highIndex;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}</pre><br />
Main/Driver <br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
#include &lt;fstream&gt;<br />
#include &lt;iomanip&gt;<br />
#include &quot;student.h&quot;<br />
#include &quot;school.h&quot;<br />
#define SIZE 15<br />
using namespace std;<br />
<br />
<br />
int main()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; Student CS101[SIZE];<br />
&nbsp; &nbsp; &nbsp; &nbsp; int size, index;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; ifstream fin;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; size = CS101.read_list(CS101, SIZE);<br />
&nbsp; &nbsp; &nbsp; &nbsp; CS101.print_list(CS101,size);&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; if(size &gt; 0){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; index = CS101.search(CS101, size);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (index != -1){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;You searched for: &quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CS101[index].printStudent();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Student is not on the list.\n&quot; ;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; index = CS101.low_GPA(CS101, size);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (index != -1){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; endl &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;The student with the lowest GPA is: &quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CS101[index].printStudent();&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; index = CS101.high_Units(CS101, size);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (index != -1){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;The student with the highest number of units is: &quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CS101[index].printStudent();&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; fin.close();<br />
&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
}</pre><br />
Input File: student.txt<br />
 <pre style="margin:20px; line-height:13px">Joe<br />
Smith Jr.<br />
Electrical Engineering<br />
45 3.45<br />
Nancy Karen<br />
Brown<br />
Industrial Engineering<br />
34 4.0<br />
Adam<br />
Jonhson<br />
Computer Science<br />
56 3.89<br />
Gorden<br />
Khalbandy<br />
Mechanical Engineering<br />
89 3.28<br />
Alan<br />
Jackson<br />
Computer Science<br />
34 3.95</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>swolll</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239639.html</guid>
		</item>
		<item>
			<title>Reading char strings and int data from text file</title>
			<link>http://www.daniweb.com/forums/thread239634.html</link>
			<pubDate>Thu, 19 Nov 2009 04:16:36 GMT</pubDate>
			<description><![CDATA[I'm writing a program that is supposed to be able to bubble sort data by name and by average. The data I'm given is student last name followed by 3 scores, all put into a text document. I'm to read the names and scores into their respective parallel arrays, and get the averages of the scores for...]]></description>
			<content:encoded><![CDATA[<div>I'm writing a program that is supposed to be able to bubble sort data by name and by average. The data I'm given is student last name followed by 3 scores, all put into a text document. I'm to read the names and scores into their respective parallel arrays, and get the averages of the scores for each student put into a 3rd and final array. Looks like this:<br />
 <pre style="margin:20px; line-height:13px">Lastname 90 91 92<br />
Lastname 80 81 82</pre><br />
This is the code I have for the read function:<br />
 <pre style="margin:20px; line-height:13px">int read(char filename[], char names[][30], int scores[][3], double averages[])<br />
{<br />
&nbsp; &nbsp; int sum = 0;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // the base of finding the average<br />
&nbsp; &nbsp; int numStu = 0;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  // how many students we will have<br />
&nbsp; &nbsp; int col = 0;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // column for names<br />
&nbsp; &nbsp; // read text document<br />
&nbsp; &nbsp; ifstream infile(filename);&nbsp; &nbsp; &nbsp; // define<br />
&nbsp; &nbsp; infile.open(filename);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // open<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; for (int i = 0; i &lt; 100; i++)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; infile.getline(names[i], 30, ' ');&nbsp; // get the name, stop when white space is found<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (! names == 'z')&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  // no names start with lowercase 'z'<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (int j = 0; j &lt; 4; j++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; infile &gt;&gt; scores[i][j]; // start plugging in scores<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sum += scores[i][j];&nbsp; &nbsp; // while we're at it, get the sum of the scores<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; averages[i] = sum / 3.0;&nbsp; &nbsp; // get the average for this name&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; numStu = i;<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; infile.close();&nbsp; &nbsp; &nbsp; &nbsp;  // close<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; return numStu;<br />
}</pre><br />
<br />
This is the code for my write function (outfile stuff in comments because I'm trying to make this work with screen output first):<br />
 <pre style="margin:20px; line-height:13px">void write(char filename[], ios::openmode, char description[], char names[][30], int scores[][3], double averages[], int numberOfStud)<br />
{<br />
&nbsp; &nbsp; // write to text file<br />
&nbsp; &nbsp; // ofstream outfile(filename, mode); // define<br />
&nbsp; &nbsp; cout &lt;&lt; description &lt;&lt; endl;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; for (int i = 0; i &lt; numberOfStud; i++)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; names[i] &lt;&lt; ' ';&nbsp; &nbsp; &nbsp; &nbsp;  // print the name<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; fixed &lt;&lt; setw(7) &lt;&lt; setprecision(2) &lt;&lt; averages[i] &lt;&lt; ' ';<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  // then the averages<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (int j = 0; j &lt; 4; j++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; scores[i][j] &lt;&lt; ' '; // then the three exam scores<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; endl;&nbsp;  // then go to the next line<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; // outfile.close();<br />
}</pre><br />
I'm having a problem with garbage output. It comes up with long lines of irrational numbers, intersparsed with many 0's. I'm not sure what I'm missing here. I think the problem is located in the read function.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>muffinhead</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239634.html</guid>
		</item>
		<item>
			<title>Finding maximum in a 10x20 2D array using rand()</title>
			<link>http://www.daniweb.com/forums/thread239631.html</link>
			<pubDate>Thu, 19 Nov 2009 04:01:16 GMT</pubDate>
			<description><![CDATA[I am currently stuck on part a of this problem. I am having a problem with my stub, I am also running this on visual C++ 2008 express. My stub is a program i had to create to find the maximum value from the 10x20 array. For some reason that's not setting up right. I will post y errors the compiler...]]></description>
			<content:encoded><![CDATA[<div>I am currently stuck on part a of this problem. I am having a problem with my stub, I am also running this on visual C++ 2008 express. My stub is a program i had to create to find the maximum value from the 10x20 array. For some reason that's not setting up right. I will post y errors the compiler gave me, but my compiler also don't least lines for whatever reason. so the errors may not make sense, but i'll point them out as carefully as possible.<br />
<br />
okay the official problem states this: <br />
<br />
A. Write a function named findmax() that finds and displays the maximum values<br />
in a two dimensional array of integers. The array should be declared as a 10 row<br />
by 20 column array of integers in main() and populated with random numbers<br />
between 0 and 100.<br />
<br />
B. Modify the function written above so that it also displays the row and column<br />
numbers of the element with the maximum value.<br />
<br />
Here's what I have so far: <br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
#include &lt;iomanip&gt;<br />
#include &lt;ctime&gt;<br />
#include &lt;cstdlib&gt;<br />
using namespace std;<br />
<br />
int findMax(int[][20]);<br />
<br />
int main()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; const int j = 10;<br />
&nbsp; &nbsp; &nbsp; &nbsp; const int k = 20;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int i,u;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int max;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; int grade[j][k];<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; srand(time(NULL));<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; for(i=0;i&lt;j;i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(u=0;u&lt;k;u++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; grade[i][u]=rand()%100;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; setw(4) &lt;&lt; grade[i][u];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;  findMax(grade);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt;&quot;The max value is &quot; &lt;&lt; max;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; system(&quot;pause&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
}<br />
<br />
int findMax(int grade[][20])<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; int i, u;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int j = 10;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int k = 20;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int max = 0;<br />
&nbsp;for(i=0;i&lt;j; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(u=0; u&lt;k; u++)<br />
&nbsp; &nbsp; &nbsp; &nbsp;  { if (max &lt; grade[i][u])<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; max = max+grade[i][u];<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  return max;<br />
}</pre><br />
New Errors:<br />
<br />
Run-Time Check Failure #3 - The variable 'max' is being used without being initialized.<br />
<br />
So After the changes were made, the stub runs, but for some reason it isn't return my max to the int main. When I have it set to cout the maximum value it says the variable max wasn't initialized with a value.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>jinjishu</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239631.html</guid>
		</item>
		<item>
			<title>crazy internet problem</title>
			<link>http://www.daniweb.com/forums/thread239620.html</link>
			<pubDate>Thu, 19 Nov 2009 02:53:59 GMT</pubDate>
			<description><![CDATA[Long story short, I'm using curl to download a file off my site. I've done tests and successfully downloaded a few txt files. 
 
The main point, though, is to download an exe file. So I uploaded the exe file to my site, and downloaded it straight from my browser with no problems, and the exe ran...]]></description>
			<content:encoded><![CDATA[<div>Long story short, I'm using curl to download a file off my site. I've done tests and successfully downloaded a few txt files.<br />
<br />
The main point, though, is to download an exe file. So I uploaded the exe file to my site, and downloaded it straight from my browser with no problems, and the exe ran fine. But when I tried downloading it with the curl program, it downloaded, yet exe was corrupt and crashed on start. <br />
<br />
Any ideas from you smart guys? my theory is maybe its not downloading it binary-wise or something confusing like that. Any solutions? Thanks<br />
<br />
<br />
<br />
<br />
Code:<br />
 <pre style="margin:20px; line-height:13px">#include &lt;curl/curl.h&gt;<br />
#include &lt;cstdio&gt;<br />
&nbsp;<br />
void get_page( const char* url, const char* file_name )<br />
{<br />
&nbsp; CURL* easyhandle = curl_easy_init() ;<br />
&nbsp;<br />
&nbsp; curl_easy_setopt( easyhandle, CURLOPT_URL, url ) ;<br />
&nbsp;<br />
&nbsp; std::FILE* file = std::fopen( file_name, &quot;w&quot; ) ;<br />
&nbsp; curl_easy_setopt( easyhandle, CURLOPT_WRITEDATA, file ) ;<br />
&nbsp;<br />
&nbsp; curl_easy_perform( easyhandle );<br />
&nbsp;<br />
&nbsp; curl_easy_cleanup( easyhandle );<br />
}<br />
&nbsp;<br />
int main()<br />
{<br />
&nbsp; get_page( &quot;http://*********.com/game.exe&quot;,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;testfile.exe&quot; ) ;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; system(&quot;PAUSE&quot;);<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>mybluehair</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239620.html</guid>
		</item>
		<item>
			<title><![CDATA[CHAR[] Help?]]></title>
			<link>http://www.daniweb.com/forums/thread239618.html</link>
			<pubDate>Thu, 19 Nov 2009 02:32:41 GMT</pubDate>
			<description><![CDATA[Hello, i need help with a basic code issue, i ave posted the code here (http://turt2live.zxq.net/cpp/hoomin.html) because it is too long to post... 
 
The issue occurs in this section of code: 
...(more before) 
void getInput(int num){ 
     char = one[1]; 
     char = two[1]; 
     char =...]]></description>
			<content:encoded><![CDATA[<div>Hello, i need help with a basic code issue, i ave posted the code <a rel="nofollow" class="t" href="http://turt2live.zxq.net/cpp/hoomin.html" target="_blank">here</a> because it is too long to post...<br />
<br />
The issue occurs in this section of code:<br />
...(more before)<br />
void getInput(int num){<br />
     char = one[1];<br />
     char = two[1];<br />
     char = three[1];<br />
     char = four[1];<br />
<br />
...(more after)<br />
<br />
saying it is expecting something before the keyword &quot;char&quot; <br />
i am using Dev C++(Latest) as a compiler, and yes, i had i as the following at one point:<br />
<br />
char[5]xxx;<br />
<br />
((Example Variable))<br />
<br />
Any and all help is appreciated. <br />
<br />
Thanks</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>turtlez</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239618.html</guid>
		</item>
		<item>
			<title>Set return issue with templated set.</title>
			<link>http://www.daniweb.com/forums/thread239612.html</link>
			<pubDate>Thu, 19 Nov 2009 01:51:54 GMT</pubDate>
			<description><![CDATA[Hey guys, 
 
I have this code snippet: 
 
template <typename ElementType, typename CompareClass> 
struct Delegate { 
	virtual bool geef(const ElementType &element){ 
		pair <set<ElementType, CompareClass>::iterator, bool> ret;  //this is line 196 
		ret = elements.insert(element); //197 
		return...]]></description>
			<content:encoded><![CDATA[<div>Hey guys,<br />
<br />
I have this code snippet:<br />
 <pre style="margin:20px; line-height:13px">template &lt;typename ElementType, typename CompareClass&gt;<br />
struct Delegate {<br />
&nbsp; &nbsp; &nbsp; &nbsp; virtual bool geef(const ElementType &amp;element){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pair &lt;set&lt;ElementType, CompareClass&gt;::iterator, bool&gt; ret;&nbsp; //this is line 196<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ret = elements.insert(element); //197<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return (ret.second); //198<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; virtual void output() = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; set&lt;ElementType, CompareClass&gt; elements;<br />
};<br />
<br />
struct ArtiestenPrinter : public Delegate&lt;Lied, LiedCompare&gt; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; virtual bool geef(const Lied &amp;lied){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bool nieuwElement = Delegate&lt;Lied, LiedCompare&gt;::geef(lied); // 210<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (nieuwElement) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; lied.artiest;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return nieuwElement;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; virtual void output(){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(set&lt;Lied, LiedCompare&gt;::iterator it = elements.begin();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; it != elements.end();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; it++){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; it-&gt;artiest &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
};</pre><br />
Which gives me these errors:<br />
 <pre style="margin:20px; line-height:13px">196: error: type/value mismatch at argument 1 in template parameter list for 'template&lt;class _T1, class _T2&gt; struct std::pair'<br />
196: error:&nbsp;  expected a type, got 'std::set&lt;ElementType,CompareClass,std::allocator&lt;_CharT&gt; &gt;::iterator'<br />
196: error: invalid type in declaration before ';' token<br />
198: error: request for member 'second' in 'ret', which is of non-class type 'int'<br />
210:&nbsp;  instantiated from here<br />
197: error: cannot convert 'std::pair&lt;std::_Rb_tree_const_iterator&lt;Lied&gt;, bool&gt;' to 'int' in assignment</pre><br />
I can't get my head around why the compiler is complaining, so any help is greatly appreciated.<br />
<br />
Thanks in advance,</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>Clockowl</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239612.html</guid>
		</item>
		<item>
			<title>Need a task.. i can give reward for who solve this to me</title>
			<link>http://www.daniweb.com/forums/thread239603.html</link>
			<pubDate>Thu, 19 Nov 2009 00:56:17 GMT</pubDate>
			<description>ok.. its really hard and takes time and knowlage of C++.. 
i hope i am in the right section for this.. if no please the mods move it to the right one.. 
 
Whoever manage to make over it... is god for me. i can  give one premium rs account valid til 23 Octomber 2010 if anyone can make this.. please...</description>
			<content:encoded><![CDATA[<div>ok.. its really hard and takes time and knowlage of C++..<br />
i hope i am in the right section for this.. if no please the mods move it to the right one..<br />
<br />
Whoever manage to make over it... is god for me. i can  give one premium rs account valid til 23 Octomber 2010 if anyone can make this.. please let me send the rs account only when the compiler runs it..<br />
Its a program i need make at C - C++. it need make RSA algorithm with the following. all you have to do is complete where its empty with the codes of Encryption, Decription and Constraction of keys where it say &quot;==== PUT YOUR FUNCTIONS HERE ====&quot;.<br />
For any questions ask me here..<br />
<br />
here is the code:<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;stdio.h&gt;<br />
#include &lt;stdlib.h&gt;<br />
#include &lt;time.h&gt;<br />
#include &lt;string.h&gt;<br />
<br />
<br />
#define MAX_BITS 64 /* Max integer that will have 2^64 - 1 bits */<br />
#define MAX_CHARS 100 /* Max character's number that get readed by fgets() */<br />
#define LENGTH_P 9 /* Lenght of p in decimals */<br />
#define LENGTH_Q 9 /* Lenght of q in decimals */<br />
#define BLOCK_SIZE 8 /* will be cryptographed 8 ASCII characters by section */<br />
<br />
<br />
/* For the constract of keys */<br />
<br />
void NewSeed (void);<br />
long long ModMult(long long a, long long b, long long mod);<br />
int RabinMiller(long long candidate);<br />
long long ModInverse(long long val, long long mod);<br />
<br />
/* For the cryptography */<br />
void GetBlock(char *block, FILE *fp, int numChars);<br />
<br />
<br />
<br />
<br />
int main(int argc, char **argv){<br />
<br />
&nbsp;  <br />
}<br />
<br />
/* ==== PUT YOUR FUNCTIONS HERE ====*/<br />
<br />
<br />
<br />
<br />
/* *********************************************************************** */<br />
/* *********************************************************************** */<br />
<br />
void NewSeed (void){<br />
&nbsp;  srand( (unsigned) time( NULL )); /* Seed = current time. */<br />
}<br />
<br />
/* *********************************************************************** */<br />
<br />
long long ModMult(long long a, long long b, long long mod){<br />
&nbsp;  /* Perform res = (a * b) % mod, avoiding intermediate overflow */<br />
&nbsp;  long long res = 0;<br />
&nbsp;  long long a1 = a % mod;<br />
&nbsp;  long long b1 = b % mod;<br />
<br />
<br />
&nbsp;  while(b1 != 0){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(b1 &amp; 1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  res = (res + a1) % mod;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; a1 = (a1 &lt;&lt; 1) % mod;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; b1 &gt;&gt;= 1;<br />
&nbsp;  }<br />
&nbsp;  return res;<br />
}<br />
<br />
/* *********************************************************************** */<br />
<br />
/* Requires stdlib.h */<br />
int RabinMiller(long long candidate){<br />
&nbsp;  long long a, n, d, x, t, rem;<br />
&nbsp;  int i, j;<br />
&nbsp;  /* const int MaxBits = 64; */ /* Allow for a max int of 2^64 - 1 */<br />
&nbsp;  int bits[MAX_BITS];<br />
&nbsp;  int roundFailed = 1; /* Boolean */<br />
<br />
&nbsp;  n = candidate;<br />
<br />
&nbsp;  t = n - 1;<br />
&nbsp;  for(i=0; i&lt;MAX_BITS; i++){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rem = t % 2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(rem == 1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  bits[i] = 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  bits[i] = 0;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(t == 0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  break;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; t /= 2;<br />
&nbsp;  }<br />
<br />
&nbsp;  /* Main algorithm starts here */<br />
&nbsp;  for(j=0; j&lt;5; j++){ /* Perform 5 rounds against 5 random bases */<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; a = (2 + (long long) rand()) % (n-1); /* Ensure 1 &lt; a &lt; n-1<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -- rand() produces smaller than n-1 for large n */<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; d = 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(; i&gt;=0; i--){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  x = d;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  d = ModMult(d, d, n);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  if(d == 1 &amp;&amp; x != 1 &amp;&amp; x != n - 1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; roundFailed = 1;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  if(bits[i])<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; d = ModMult(d, a, n);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(d != 1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  roundFailed = 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  roundFailed = 0;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(roundFailed)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  return 0;<br />
&nbsp;  }<br />
&nbsp;  /* If this point has been reached, then the candidate number has passed<br />
&nbsp;  all rounds successfully. */<br />
&nbsp;  return 1;<br />
}<br />
<br />
/* *********************************************************************** */<br />
<br />
long long ModInverse(long long val, long long mod){<br />
<br />
&nbsp;  long long c1, c2, c3, t, b1, b2, b3;<br />
&nbsp;  int sign = 0;<br />
&nbsp;  c1 = mod;<br />
&nbsp;  c2 = val;<br />
&nbsp;  c3 = 0;<br />
&nbsp;  b1 = 0;<br />
&nbsp;  b2 = 1;<br />
&nbsp;  b3 = 0;<br />
&nbsp;  t = 0;<br />
<br />
&nbsp;  do{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; t = c1 / c2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; c3 = c1 % c2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; b3 = t * b2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; b3 = b1 + b3;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; c1 = c2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; c2 = c3;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; b1 = b2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; b2 = b3;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sign++;<br />
&nbsp;  }while(c2 != 0);<br />
<br />
&nbsp;  if(sign % 2 == 0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; b1 = mod - b1;<br />
<br />
&nbsp;  return b1;<br />
}<br />
<br />
/* *********************************************************************** */<br />
<br />
/*<br />
Reads numChars from file pointer fp and stores them to block.<br />
if there are less than numChars characters, pad out with spaces<br />
*/<br />
void GetBlock(char *block, FILE *fp, int numChars){<br />
&nbsp;  int i = 0, charsRead = 0;<br />
&nbsp;  char c, str[BLOCK_SIZE+1];<br />
<br />
&nbsp;  while((c = fgetc(fp)) != EOF &amp;&amp; i &lt; numChars){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(c == '\n')<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  continue;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; str[i] = c;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; i++;<br />
&nbsp;  }<br />
&nbsp;  charsRead = i;<br />
&nbsp;  if(c != EOF) /* There are more chars in the file, but the block is full */<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ungetc(c, fp);<br />
<br />
&nbsp;  if(charsRead &lt; numChars){ /* Need to pad out with blanks */<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(i=charsRead; i &lt;= numChars; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  str[i] = ' ';<br />
&nbsp;  }<br />
&nbsp;  str[numChars] = '\0'; /* Add string terminator */<br />
&nbsp;  strcpy(block, str);<br />
}<br />
<br />
/* *********************************************************************** */</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>FeVerSeCtioN</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239603.html</guid>
		</item>
		<item>
			<title>Write 4 functions to compute and return</title>
			<link>http://www.daniweb.com/forums/thread239600.html</link>
			<pubDate>Thu, 19 Nov 2009 00:29:04 GMT</pubDate>
			<description><![CDATA[Hi, new learner to C++.  I have to write 4 functions to compute and return the diameter, circumference, etc. of a circle.  I think I might be on the right track but I'm probably making this harder than it has to be.  I commented most code out because I'd like to get one thing working and then go...]]></description>
			<content:encoded><![CDATA[<div>Hi, new learner to C++.  I have to write 4 functions to compute and return the diameter, circumference, etc. of a circle.  I think I might be on the right track but I'm probably making this harder than it has to be.  I commented most code out because I'd like to get one thing working and then go back and finish.  How do I get the radius value into the equation?  When I run it the answer comes up<br />
-1.#IND when I put in a radius of 2.<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
#include &lt;iomanip&gt;<br />
#include &lt;cmath&gt;<br />
using namespace std ;<br />
<br />
double radius ;<br />
double diam ;<br />
double const PI = 3.14159265358979323846 ;<br />
<br />
<br />
double diameter(double diam)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; double d ;<br />
&nbsp; &nbsp; &nbsp; &nbsp; while (d = 2 * radius ) <br />
&nbsp; &nbsp; &nbsp; &nbsp; return d ;<br />
}<br />
<br />
//double circum(double circumf)<br />
//{<br />
//&nbsp; &nbsp; &nbsp; &nbsp; return diam * PI ;<br />
//}<br />
//<br />
//double area(double area1)<br />
//{<br />
//&nbsp; &nbsp; &nbsp; &nbsp; return PI * pow(radius, radius) ;<br />
//}<br />
//<br />
//double volume(double vol1)<br />
//{<br />
//&nbsp; &nbsp; &nbsp; &nbsp; return (4.0/3.0) * (radius * radius * radius) * PI ;<br />
//}<br />
<br />
<br />
<br />
int main()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; double radius ;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Please enter the radius of a circle: &quot; ;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; radius ;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; double d = diameter(diam) ;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;The diameter of the circle is: &quot; &lt;&lt; d &lt;&lt; endl ;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; /*circum(circumf);<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;The circumference of the circle is: &quot; &lt;&lt; circumf &lt;&lt; endl;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; area(area1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;The area of the circle is: &quot; &lt;&lt; area1 &lt;&lt; endl;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; volume(vol1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;The volume of the sphere is: &quot; &lt;&lt; vol1 &lt;&lt; endl;*/<br />
<br />
<br />
<br />
return 0 ;<br />
<br />
}</pre><br />
Thank you!</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>guccitan88</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239600.html</guid>
		</item>
		<item>
			<title>String assigns not permanent</title>
			<link>http://www.daniweb.com/forums/thread239599.html</link>
			<pubDate>Thu, 19 Nov 2009 00:21:34 GMT</pubDate>
			<description>Nevermind.</description>
			<content:encoded><![CDATA[<div>Nevermind.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>Clockowl</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239599.html</guid>
		</item>
		<item>
			<title>Arithmetic operations</title>
			<link>http://www.daniweb.com/forums/thread239597.html</link>
			<pubDate>Thu, 19 Nov 2009 00:18:33 GMT</pubDate>
			<description><![CDATA[This program runs perfect just want to know if I have to do this arithmetic operations using functions how can I do that?   
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680"...]]></description>
			<content:encoded><![CDATA[<div>This program runs perfect just want to know if I have to do this arithmetic operations using functions how can I do that?  <br />
<br />
 <pre style="margin:20px; line-height:13px">// Arithmetic.cpp - This program performs arithmetic, ( +. -, *. / ) on two numbers.<br />
// Input:&nbsp; Interactive<br />
// Output:&nbsp; Result of arithmetic operation<br />
<br />
#include &lt;cstdlib&gt;<br />
#include &lt;iostream&gt;<br />
#include &lt;string&gt;<br />
<br />
using namespace std;<br />
int main(int argc, char *argv[]) <br />
{<br />
&nbsp;  double numberOne, numberTwo;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp;  string operation;<br />
&nbsp;  double result;&nbsp; &nbsp; &nbsp; &nbsp;  <br />
<br />
&nbsp;  cout &lt;&lt; &quot;Enter the first number: &quot;;<br />
&nbsp;  cin &gt;&gt; numberOne; <br />
&nbsp;  cout &lt;&lt; &quot;Enter the second number: &quot;;<br />
&nbsp;  cin &gt;&gt; numberTwo; <br />
&nbsp;  cout &lt;&lt; &quot;Enter an operator (+.-.*,/): &quot;;<br />
&nbsp;  cin &gt;&gt; operation;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp;  if (operation == &quot;+&quot;)<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result = numberOne + numberTwo;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (operation == &quot;-&quot;)<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result = numberOne - numberTwo;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (operation == &quot;*&quot;)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result = numberOne * numberTwo;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (operation == &quot;/&quot;)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result = numberOne / numberTwo;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  } <br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; numberOne;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot; &quot; &lt;&lt; operation &lt;&lt; &quot; &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; numberTwo;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot; = &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; result &lt;&lt; endl;<br />
<br />
system(&quot;PAUSE&quot;);<br />
return EXIT_SUCCESS;<br />
} // End of main() function</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>maverick405</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239597.html</guid>
		</item>
		<item>
			<title>Linear and Binary search</title>
			<link>http://www.daniweb.com/forums/thread239595.html</link>
			<pubDate>Thu, 19 Nov 2009 00:02:51 GMT</pubDate>
			<description><![CDATA[Iam trying to code a single program of an array with 20 elements in it. It asks for a number from user and search is if this array has that number. 
 
 I am using Binary and selection search. 
 
Its not giving me the required results. here  is my code; 
 
  <div class="codeblock"> <div...]]></description>
			<content:encoded><![CDATA[<div>Iam trying to code a single program of an array with 20 elements in it. It asks for a number from user and search is if this array has that number.<br />
<br />
 I am using Binary and selection search.<br />
<br />
Its not giving me the required results. here  is my code;<br />
<br />
 <pre style="margin:20px; line-height:13px">/* Linear and Binary search<br />
<br />
<br />
*/<br />
<br />
#include &lt;iostream&gt;<br />
<br />
using namespace std;<br />
<br />
// Function prototype<br />
<br />
int searchList(int [], int , int );<br />
<br />
int binarySearch(int [], int, int);<br />
<br />
&nbsp;const int size = 20;<br />
<br />
int main()<br />
<br />
{<br />
int tests[20]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};<br />
<br />
&nbsp;int num1, num2;<br />
&nbsp;<br />
int result1, result2;<br />
<br />
//search the array for 19<br />
<br />
result1 = searchList(tests, size ,19);<br />
<br />
<br />
// if searchList&nbsp; returns -1 , then num1 is not found<br />
cout &lt;&lt; &quot;Enter the number you wish to search for: &quot;;<br />
cin &gt;&gt; num1;<br />
&nbsp;  if (result1 == -1)<br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp;  cout&lt;&lt;&quot;There is no num1 &quot;&lt;&lt;endl;<br />
&nbsp;  }<br />
&nbsp;  <br />
&nbsp;  else <br />
&nbsp;  {<br />
&nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;num1 is found&quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp;  cout &lt;&lt;&quot;and its position is =&quot;;<br />
&nbsp; &nbsp; &nbsp;  cout&lt;&lt; (result1+1)&lt;&lt;endl; <br />
&nbsp; &nbsp; &nbsp;  <br />
&nbsp;  }<br />
&nbsp; &nbsp; // calling Function for Binary search<br />
&nbsp; &nbsp; <br />
result2 = binarySearch(tests , size, 19);<br />
&nbsp; &nbsp; <br />
cout &lt;&lt; &quot;Enter the number you wish to search for: &quot;;<br />
cin &gt;&gt; num2;<br />
<br />
&nbsp; &nbsp; &nbsp;  if (result2 == -1)<br />
&nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;That number does not exist in the array.\n&quot;;<br />
&nbsp; &nbsp; &nbsp;  else<br />
&nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;That ID is found at element &quot; &lt;&lt; result2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot; in the array.\n&quot;; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } <br />
&nbsp;  <br />
&nbsp;  <br />
system(&quot;PAUSE&quot;);<br />
&nbsp; &nbsp; return 0;<br />
}<br />
<br />
/*<br />
**************************************<br />
<br />
&nbsp;void displayList( int [], int)<br />
<br />
&nbsp;{<br />
&nbsp;<br />
&nbsp;<br />
&nbsp;}<br />
<br />
/**********************************************************/<br />
<br />
/*SearchList Function performs a linear search. Array&nbsp; name is list <br />
and it has a max numElem elements . <br />
if the number&nbsp; is found <br />
If the number is found, its array <br />
subscript is returned. Otherwise, -1 is returned. *<br />
****************************************************************<br />
*/<br />
<br />
int searchList(int list [], int numElem, int value)<br />
<br />
{<br />
&nbsp; &nbsp; int index =0 ;<br />
&nbsp; &nbsp; int position = -1;<br />
&nbsp; &nbsp; bool found = false;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; while (index &lt; numElem &amp;&amp; !found)&nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (list [index]== value )&nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; found = true ;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  position= index;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; index++;<br />
&nbsp; &nbsp; }<br />
<br />
return position;<br />
&nbsp; &nbsp; <br />
}<br />
<br />
//********************************************************************<br />
/* The function should keep a count of the<br />
number of comparisons it makes until it finds the value. <br />
<br />
<br />
//***********************************************************************<br />
/* Function for&nbsp; Binary search*/<br />
<br />
int binarySearch(int array[], int numElems, int value)<br />
{<br />
&nbsp; &nbsp; int first = 0,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  // First array element<br />
&nbsp; &nbsp; &nbsp; &nbsp; last = numElems - 1,&nbsp; &nbsp; // Last array element<br />
&nbsp; &nbsp; &nbsp; &nbsp; middle,&nbsp; &nbsp; &nbsp; &nbsp; // Midpoint of search<br />
&nbsp; &nbsp; &nbsp; &nbsp; position = -1; // Position of search value<br />
&nbsp; &nbsp; &nbsp; &nbsp; bool found = false;&nbsp; &nbsp;  // Flag<br />
<br />
while (!found &amp;&amp; first &lt;= last)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; middle = (first + last) / 2; // Calculate midpoint<br />
}&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; if (array[middle] == value) // If value is found at midpoint<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; found = true;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; position = middle;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; else if (array[middle] &gt; value) // If value is in lower half<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; last = middle - 1;<br />
&nbsp; &nbsp; }<br />
&nbsp;else<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; first = middle + 1;&nbsp; &nbsp; &nbsp; &nbsp; // If value is in upper half<br />
&nbsp; &nbsp; &nbsp; }<br />
return position;<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>rafta</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239595.html</guid>
		</item>
		<item>
			<title>Splitting up a string</title>
			<link>http://www.daniweb.com/forums/thread239594.html</link>
			<pubDate>Wed, 18 Nov 2009 23:56:30 GMT</pubDate>
			<description><![CDATA[So, I'm asking a user to input a fraction in the form of this: 
 
+3 3/4 
 
I know I can use a search to find where the first instance of something happens, but how do I actually take whats before it?  Example: I can tell it to search for white space, but how can I tell it to grab what is before it...]]></description>
			<content:encoded><![CDATA[<div>So, I'm asking a user to input a fraction in the form of this:<br />
<br />
+3 3/4<br />
<br />
I know I can use a search to find where the first instance of something happens, but how do I actually take whats before it?  Example: I can tell it to search for white space, but how can I tell it to grab what is before it and save it into a variable?<br />
<br />
 Would it be easier to use an array of characters or can a string work?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>wyett</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239594.html</guid>
		</item>
		<item>
			<title>convert string w spaces to an array w/o spaces</title>
			<link>http://www.daniweb.com/forums/thread239586.html</link>
			<pubDate>Wed, 18 Nov 2009 22:53:12 GMT</pubDate>
			<description><![CDATA[Hi, I am having a user input a series of numbers and characters separated by spaces. like "10 23 65 34 765 34 65 34 64 354  64" and i need to put these into an array without the spaces. I stores them into a string but whenever i do like   <div class="codeblock"> <div class="spaced"> <div...]]></description>
			<content:encoded><![CDATA[<div>Hi, I am having a user input a series of numbers and characters separated by spaces. like &quot;10 23 65 34 765 34 65 34 64 354  64&quot; and i need to put these into an array without the spaces. I stores them into a string but whenever i do like  <pre style="margin:20px; line-height:13px"> mystring[0]</pre> i only get the first digit and not the number. or if i put  <pre style="margin:20px; line-height:13px"> mystring[1]</pre> i only get the second number like in the digits above. i want  <pre style="margin:20px; line-height:13px"> mystring[0]</pre>  to contain 10 and not just 1. <br />
Please help!!!!!!</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>mampam</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239586.html</guid>
		</item>
		<item>
			<title>Lotto array program with void function</title>
			<link>http://www.daniweb.com/forums/thread239570.html</link>
			<pubDate>Wed, 18 Nov 2009 21:52:19 GMT</pubDate>
			<description>I have to write a program that allows a user to pick five numbers from one to 55. The computer will then generate 5 random numbers and determine how many of the users choices match the generated numbers. I have to create an algorithm for this program. The program will have a void function to...</description>
			<content:encoded><![CDATA[<div>I have to write a program that allows a user to pick five numbers from one to 55. The computer will then generate 5 random numbers and determine how many of the users choices match the generated numbers. I have to create an algorithm for this program. The program will have a void function to generate 5 random numbers from one to 55, no duplicate numbers allowed. The random numbers and the choices will be stored in two one dimensional arrays. The program will have a void function to display the random<br />
numbers and the users choices and the number of matches. The program will contain a loop that will generate a new set of random numbers and user choices unless the user tells the program to quit.  I don't even know where to start with this.  The void function is what I'm not getting mostly.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>vinochick</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239570.html</guid>
		</item>
		<item>
			<title>HELP Me Plz</title>
			<link>http://www.daniweb.com/forums/thread239567.html</link>
			<pubDate>Wed, 18 Nov 2009 21:42:51 GMT</pubDate>
			<description>Please 
ok can any one give me the code to this im making a program and it needs this and im stuck please give code asap  
application that will convert any text I throw at it to hex  
Thank You</description>
			<content:encoded><![CDATA[<div>Please<br />
ok can any one give me the code to this im making a program and it needs this and im stuck please give code asap <br />
application that will convert any text I throw at it to hex <br />
Thank You</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>ImMoRtAl-</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239567.html</guid>
		</item>
		<item>
			<title>printf() a templated type T</title>
			<link>http://www.daniweb.com/forums/thread239564.html</link>
			<pubDate>Wed, 18 Nov 2009 21:26:22 GMT</pubDate>
			<description><![CDATA[Hi all, 
 
I'm new to working with C++ (I'm more a C programmer) and I have a question: 
I have a container class for a templated type T, which could be any scalar type, although the most commonly used ones are unsigned char and float.  
I have a function that prints some of the elements to screen:...]]></description>
			<content:encoded><![CDATA[<div>Hi all,<br />
<br />
I'm new to working with C++ (I'm more a C programmer) and I have a question:<br />
I have a container class for a templated type T, which could be any scalar type, although the most commonly used ones are unsigned char and float. <br />
I have a function that prints some of the elements to screen:<br />
<br />
 <pre style="margin:20px; line-height:13px">template &lt;class T&gt;<br />
void dumpImageAscii(<br />
&nbsp; &nbsp; const Image2D&lt;T&gt; *image, <br />
&nbsp; &nbsp; const char *file_name)<br />
{<br />
&nbsp; &nbsp; ...<br />
&nbsp; &nbsp; bool is_int = numeric_limits&lt;T&gt;::is_integer;<br />
&nbsp; &nbsp; ....<br />
&nbsp; &nbsp; for (v = image-&gt;bounds._l2; v &lt;= image-&gt;bounds._h2; v++)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (u = image-&gt;bounds._l1; u &lt;= image-&gt;bounds._h1; u++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (is_int)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fprintf(pFile, &quot;%10d&quot;, image-&gt;m[v][u]);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fprintf(pFile, &quot;%16g&quot;, image-&gt;m[v][u]);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; fprintf(pFile, &quot;\n&quot;);<br />
&nbsp; &nbsp; }<br />
&nbsp;  ....<br />
}</pre><br />
Although the is_int flag takes care of formatting when printing, the compiler still throws a warning every time I call this function, stuff like:<br />
<br />
warning: format ‘%10d’ expects type ‘int’, but argument 3 has type ‘double’<br />
<br />
Which is expected because it's not smart enough to figure out which tree to go in at compile time.<br />
I do not like seeing warnings in my code, especially unnecessary warnings like these...<br />
Is there a way around this? <br />
Also I want to avoid cout/fout whenever possible...most of the project is straight C, it's just that we need templates for this part.<br />
<br />
Thanks.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>ylchen</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239564.html</guid>
		</item>
		<item>
			<title>memset An Access Violation(segmentation fault)</title>
			<link>http://www.daniweb.com/forums/thread239563.html</link>
			<pubDate>Wed, 18 Nov 2009 21:21:21 GMT</pubDate>
			<description><![CDATA[<div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox" title="Help with Code Tags" target="_blank">Help with Code Tags</a> </div> <div> <strong>C++ Syntax</strong> (<a...]]></description>
			<content:encoded><![CDATA[<div> <pre style="margin:20px; line-height:13px">&nbsp; &nbsp; &nbsp; &nbsp; memset( sDate, 0, sizeof(sDate));<br />
<br />
&nbsp; &nbsp; tempSize = strlen( argv[1] );<br />
&nbsp; &nbsp; for ( j = tempSize - 1; j &gt;= 0; j--)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ( *(argv[1] + j) == '/' )<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; j = j + 7;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strncpy( sDate, argv[1] + j, 8 );<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; }</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>crisis123</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239563.html</guid>
		</item>
		<item>
			<title><![CDATA[[pure C++ or mASM] Posting HTML Data]]></title>
			<link>http://www.daniweb.com/forums/thread239561.html</link>
			<pubDate>Wed, 18 Nov 2009 21:15:08 GMT</pubDate>
			<description>Hi.  I want to include an email function in my program.  So that if anybody needs to ask me a question, they can use my program to send me an email. 
 
I want to do this this way: 
 
I want my program to connect to my website, and post data to fill out my PHP e-mailer script.  Then I want it to...</description>
			<content:encoded><![CDATA[<div>Hi.  I want to include an email function in my program.  So that if anybody needs to ask me a question, they can use my program to send me an email.<br />
<br />
I want to do this this way:<br />
<br />
I want my program to connect to my website, and post data to fill out my PHP e-mailer script.  Then I want it to press the send data.<br />
<br />
<br />
WebBrowser1:: Document:: GetElementById(&quot;youremail&quot;):: SetAttribute(&quot;value&quot;, (textBox1.Text))<br />
                    WebBrowser1:: Document:: GetElementById(&quot;body):: SetAttribute(&quot;value&quot;, (textBox2.Text))<br />
                    WebBrowser1:: Document:: GetElementById(&quot;submit&quot;)::InvokeMember(&quot;click&quot;)<br />
<br />
(Spaces were added to avoid icons)<br />
<br />
The program was initially written in VC++.  But I am going to convert it to either mASM or pure C++.  (Pure C++ as in no .NET framework) This is the only problem.  I do not know how to go about sending emails.  I have tried using sockets, but they are very unstable and do not work well.  So I decided to use a PHP form.  <br />
<br />
How would this be done?  Could anybody tell me the functions from MSDN.com that could do this for me?  I am thinking that this would be done via wininet, but I am not sure which functions I would use.<br />
<br />
So could anybody please tell me which functions could accomplish posting data?<br />
<br />
Thanks,<br />
Dave</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>scriptkiddy</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239561.html</guid>
		</item>
		<item>
			<title>error, I cant figure out</title>
			<link>http://www.daniweb.com/forums/thread239554.html</link>
			<pubDate>Wed, 18 Nov 2009 20:53:56 GMT</pubDate>
			<description><![CDATA[I have tried and tried to figure out what it is I am have wrong.  I have an assignment to create a program that calculates employee's bonus.  I think I pretty much have it, but I  keep getting an error that I cant figure out and what the error is trying to tell me.  If someone could please help I...]]></description>
			<content:encoded><![CDATA[<div>I have tried and tried to figure out what it is I am have wrong.  I have an assignment to create a program that calculates employee's bonus.  I think I pretty much have it, but I  keep getting an error that I cant figure out and what the error is trying to tell me.  If someone could please help I would really appreciate it.<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
#include &lt;string&gt;<br />
using namespace std;<br />
<br />
myfunc (int calc_bonus);<br />
<br />
int main ( ) <br />
{<br />
&nbsp;  string name;<br />
&nbsp;  int total_sales, bonus;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; name;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; total_sales;<br />
&nbsp;  int calc_bonus(int sales){<br />
&nbsp; &nbsp; &nbsp; &nbsp; int temp<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (total_sales &lt; 3001) temp = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  if (total_sales &gt; 3000 &amp;&amp; &lt; 5001) temp = 50;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  if (total_sales &gt; 5000 &amp;&amp; &lt; 10000) temp = 100;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  if (total_sales &gt; 9999) temp = 250;<br />
&nbsp; &nbsp; &nbsp;  return temp<br />
}<br />
&nbsp; &nbsp; &nbsp;  cout &lt;&lt; “ name's bonus is ” &lt;&lt; bonus &lt;&lt; endl;<br />
};<br />
&nbsp; &nbsp; &nbsp; //&nbsp;  Exit program.<br />
&nbsp;  return 0;<br />
}</pre>Here is the error I got from the compiler<br />
<br />
Line 21: error: stray '\342' in program<br />
compilation terminated due to -Wfatal-errors.<br />
<br />
Again, any assistance would be great!  Thanks!</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>unsure</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239554.html</guid>
		</item>
		<item>
			<title>DLL Project problem!: unresolved external</title>
			<link>http://www.daniweb.com/forums/thread239553.html</link>
			<pubDate>Wed, 18 Nov 2009 20:49:22 GMT</pubDate>
			<description><![CDATA[Hello! :) 
 
I'm trying to achieve an 'engine' of a kind in a DLL project. I have successfully made a DLL that works, but as simple as Hello World. 
 
Now I'm coding a framework into the DLL project, but I'm having some trouble with the singleton function. 
 
Im getting this linker error: 
  <div...]]></description>
			<content:encoded><![CDATA[<div>Hello! :)<br />
<br />
I'm trying to achieve an 'engine' of a kind in a DLL project. I have successfully made a DLL that works, but as simple as Hello World.<br />
<br />
Now I'm coding a framework into the DLL project, but I'm having some trouble with the singleton function.<br />
<br />
Im getting this linker error:<br />
 <pre style="margin:20px; line-height:13px">DLLProject.obj : error LNK2001: unresolved external symbol &quot;public: static class MyDLL::Framework * MyDLL::Framework::ofManager&quot; (?ofManager@Framework@MyDLL@@2PAV12@A)</pre><br />
<span style="font-weight:bold">DLLProject.h</span><br />
 <pre style="margin:20px; line-height:13px">namespace MyDLL<br />
{<br />
&nbsp; class Framework<br />
&nbsp; {<br />
&nbsp; public:<br />
&nbsp; &nbsp; static __declspec(dllexport)&nbsp; Framework* ofManager;<br />
&nbsp; &nbsp;  Framework();<br />
&nbsp; &nbsp; ~Framework();<br />
&nbsp; &nbsp; static __declspec(dllexport) Framework* createManager();<br />
&nbsp; &nbsp; static __declspec(dllexport) Framework* getSingletonPtr()<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; return ofManager;<br />
&nbsp; &nbsp; };<br />
&nbsp; &nbsp; ...<br />
&nbsp; private:<br />
&nbsp; &nbsp; ...<br />
&nbsp; };<br />
}</pre><br />
<span style="font-weight:bold">DLLProject.cpp</span><br />
 <pre style="margin:20px; line-height:13px">#include &quot;DLLProject.h&quot;<br />
namespace myDLL<br />
{<br />
&nbsp; Framework::Framework()<br />
&nbsp; {<br />
&nbsp; &nbsp; ofManager = this;<br />
&nbsp; }<br />
&nbsp; Framework* Framework::createManager()<br />
&nbsp; {<br />
&nbsp; &nbsp; if(ofManager == 0) ofManager = new Framework();<br />
&nbsp; &nbsp; return ofManager;<br />
&nbsp; }<br />
&nbsp; ...</pre><br />
Hope anyone can help, I'm really putting my hair out over this, and hoped that the time invested would not get me asking for help, but oh ;)</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>Excizted</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239553.html</guid>
		</item>
		<item>
			<title>Sorting Integers</title>
			<link>http://www.daniweb.com/forums/thread239550.html</link>
			<pubDate>Wed, 18 Nov 2009 20:34:34 GMT</pubDate>
			<description><![CDATA[Hey guys, 
 
So I am trying to make a program that will prompt the user to enter 3 integers (int1, int2, int3), then sort the integers into ascending order. I have the program reading the integers, but I can't get it to sort. I know I can use the sort function but I don't know how to do it. Here is...]]></description>
			<content:encoded><![CDATA[<div>Hey guys,<br />
<br />
So I am trying to make a program that will prompt the user to enter 3 integers (int1, int2, int3), then sort the integers into ascending order. I have the program reading the integers, but I can't get it to sort. I know I can use the sort function but I don't know how to do it. Here is what I have:<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
<br />
using namespace std;<br />
int main()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;Enter an integer: &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int int1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cin&gt;&gt;int1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;Enter another integer: &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int int2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cin&gt;&gt;int2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;Enter a last integer: &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int int3;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cin&gt;&gt;int3;<br />
}</pre><br />
Thanks in advance!</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>cole davidson</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239550.html</guid>
		</item>
		<item>
			<title>Found a solution, not sure how to impliment</title>
			<link>http://www.daniweb.com/forums/thread239545.html</link>
			<pubDate>Wed, 18 Nov 2009 20:15:14 GMT</pubDate>
			<description>So i am writing a program that plays the old memory card game (ie you have a 4x4 block of playing cards, flip 2, if they match they stay up, if not they flip back over). 
 
I am having trouble generating the random pairs of cards (i got the 4x4 working and the choosing and flipping of 2 cards...</description>
			<content:encoded><![CDATA[<div>So i am writing a program that plays the old memory card game (ie you have a 4x4 block of playing cards, flip 2, if they match they stay up, if not they flip back over).<br />
<br />
I am having trouble generating the random pairs of cards (i got the 4x4 working and the choosing and flipping of 2 cards working, something is broken after that but ill come to that later)<br />
<br />
I realized that i was generating single numbers, not pairs in my current code.  My idea for a fix is to take another array and give it the numbers 1 to 8 then iterate through it twice and put it in the card array. however im not sure how to either randomly iterate or randomly place the numbers in the card array.<br />
<br />
some sudo code that i think might work but not sure how to check for empty spots<br />
 <pre style="margin:20px; line-height:13px">rowNum= rand(1,4)<br />
colNum=rand(1,4)<br />
array[rowNum][colNum] = digit</pre><br />
my current code (maybe you can figure out why it only goes through the guess once....)<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
#include &lt;cstdlib&gt;<br />
#include &lt;ctime&gt;<br />
using namespace std;<br />
<br />
int main()<br />
{<br />
&nbsp; &nbsp; char comma;<br />
&nbsp; &nbsp; int row1, column1, row2, column2, cards[4][4];<br />
<br />
&nbsp; &nbsp; srand((unsigned)time(NULL));<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; //fill board<br />
<br />
<br />
<br />
&nbsp; &nbsp; for (int r=0; r&lt;4; r++)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (int c=0; c&lt;4; c++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cards[r][c]=rand()%8+1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;cards[r][c];<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;endl;<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; //display board<br />
&nbsp; &nbsp; cout&lt;&lt;&quot;&nbsp; &nbsp; 1 2 3 4\n&quot;;<br />
&nbsp; &nbsp; cout&lt;&lt;&quot;&nbsp; &quot;;<br />
&nbsp; &nbsp; for (int i=0; i&lt;=8; i++)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;-&quot;;<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; cout&lt;&lt;endl;<br />
&nbsp; &nbsp; for (int r=0; r&lt;4; r++)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;r+1&lt;&lt;&quot; | &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (int c=0; c&lt;4; c++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;* &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;endl;<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; cout&lt;&lt;endl;<br />
&nbsp; &nbsp; //selection<br />
&nbsp; &nbsp; cout&lt;&lt;&quot;Please insert the first card row and column seperated by a comma.\n&quot;;<br />
&nbsp; &nbsp; cin&gt;&gt;row1&gt;&gt;comma&gt;&gt;column1;<br />
&nbsp; &nbsp; cout&lt;&lt;&quot;Please insert the second card row and column seperated by a comma.\n&quot;;<br />
&nbsp; &nbsp; cin&gt;&gt;row2&gt;&gt;comma&gt;&gt;column2;<br />
&nbsp; &nbsp; //fix<br />
&nbsp; &nbsp; row1--;<br />
&nbsp; &nbsp; column1--;<br />
&nbsp; &nbsp; row2--;<br />
&nbsp; &nbsp; column2--;<br />
&nbsp; &nbsp; //reveal<br />
&nbsp; &nbsp; cout&lt;&lt;&quot;&nbsp; &nbsp; 1 2 3 4\n&quot;;<br />
&nbsp; &nbsp; cout&lt;&lt;&quot;&nbsp; &quot;;<br />
&nbsp; &nbsp; for (int i=0; i&lt;=8; i++)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;-&quot;;<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; cout&lt;&lt;endl;<br />
&nbsp; &nbsp; for (int r=0; r&lt;4; r++)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;r+1&lt;&lt;&quot; | &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (int c=0; c&lt;4; c++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ((r==row1)&amp;&amp;(c==column1))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;cards[r][c]&lt;&lt;&quot; &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if((r==row2)&amp;&amp;(c==column2))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;cards[r][c]&lt;&lt;&quot; &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;&quot;* &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;endl;<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; //match?<br />
&nbsp; &nbsp; if (cards[row1][column1]==cards[row2][column2])<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; else<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; //this pushes the next board onto a blank screen<br />
&nbsp; &nbsp; for (int b=0; b&lt;=20; b++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;endl;<br />
&nbsp; &nbsp; //repeat<br />
&nbsp; &nbsp; return 0;<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>Ponomous</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239545.html</guid>
		</item>
		<item>
			<title>Lottery rows without displaying twice?</title>
			<link>http://www.daniweb.com/forums/thread239541.html</link>
			<pubDate>Wed, 18 Nov 2009 19:41:38 GMT</pubDate>
			<description><![CDATA[Hi everybody! 
 
I dont want to lie and say this isn't an assignment because it is, and I have really got stuck here. 
 
The assignment was to create a lottery-program which randomly displays 10 ordinary numbers and 5 extra numbers, all in between the interval of 1-50. The problem is the last task...]]></description>
			<content:encoded><![CDATA[<div>Hi everybody!<br />
<br />
I dont want to lie and say this isn't an assignment because it is, and I have really got stuck here.<br />
<br />
The assignment was to create a lottery-program which randomly displays 10 ordinary numbers and 5 extra numbers, all in between the interval of 1-50. The problem is the last task in which the numbers must not repeat itself.<br />
<br />
I have tried using array but cant get it to work. The array must save each character and loop over again to compare them for not being displayed twice.<br />
, I just cant do this?!<br />
<br />
Any answer is a good and helpfull answer!<br />
<br />
Best regards<br />
Adam <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;&nbsp; &nbsp; &nbsp; &nbsp; //programkod för in- och utmatning<br />
#include &lt;ctime&gt;&nbsp; &nbsp; &nbsp; &nbsp; <br />
#include &lt;cstdlib&gt;<br />
<br />
<br />
using namespace std;<br />
<br />
int main()<br />
<br />
{<br />
<br />
<br />
srand(time(0));<br />
<br />
<br />
for(int ordinary=0; ordinary&lt;10; ordinary++)<br />
{<br />
cout&lt;&lt;rand()%50+1&lt;&lt;endl;<br />
}<br />
<br />
<br />
cout&lt;&lt;endl&lt;&lt;endl;<br />
<br />
<br />
for(int extra=0; extra&lt;5; extra++)<br />
<br />
{<br />
cout&lt;&lt;rand()%50+1&lt;&lt;endl;<br />
}<br />
<br />
<br />
return 0;<br />
<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>foxmulder</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239541.html</guid>
		</item>
		<item>
			<title>Class and Array Issues</title>
			<link>http://www.daniweb.com/forums/thread239534.html</link>
			<pubDate>Wed, 18 Nov 2009 19:22:01 GMT</pubDate>
			<description><![CDATA[Hello again, I'm having trouble with a program that I have to write involving classes and arrays. Essentially i have to create a class Theater, which I am not sure how to do. The theater has 15 rows with 30 seats per row, and each row is assigned a price for each seat, inputted from a text file. I...]]></description>
			<content:encoded><![CDATA[<div>Hello again, I'm having trouble with a program that I have to write involving classes and arrays. Essentially i have to create a class Theater, which I am not sure how to do. The theater has 15 rows with 30 seats per row, and each row is assigned a price for each seat, inputted from a text file. I cannot seem to get the 2d array to work properly. The user should be able to purchase a specific seat using the inputted prices, which keeps a running total of seats purchased. The output should show each row and seat and put a * if the seat is purchased and a # if the seat is available.<br />
<br />
This is what I have so far, please let me know if it is to sloppy and I will do my best to make it cleaner, sorry. <br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
#include &lt;iomanip&gt;<br />
#include &lt;fstream&gt;<br />
#include &lt;cstdlib&gt; <br />
using namespace std;<br />
<br />
void menu();<br />
void purchase();<br />
void total_value();<br />
void total_number();<br />
void seats_row();<br />
void seats_all();<br />
void seating_chart();<br />
<br />
void get_price()<br />
{<br />
&nbsp; &nbsp; int i;<br />
&nbsp; &nbsp; ifstream fin;<br />
&nbsp; &nbsp; fin.open(&quot;seats.txt&quot;);<br />
&nbsp; &nbsp; int price[15];<br />
&nbsp; &nbsp; for(i=1; i&lt;16; i++)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; fin &gt;&gt; price[i];<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Row &quot; &lt;&lt; i &lt;&lt; &quot; is $&quot; &lt;&lt; price[i] &lt;&lt; endl;<br />
&nbsp; &nbsp; }<br />
}<br />
<br />
void purchase()<br />
{<br />
&nbsp; &nbsp; int seat;<br />
&nbsp; &nbsp; int row;<br />
&nbsp; &nbsp; int total;<br />
&nbsp; &nbsp; do<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; do<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;-------- Purchase Seats --------&quot; &lt;&lt; endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; &quot;Enter the row and seat number desired.&quot; &lt;&lt; endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; &quot;There are 15 rows and 30 seats per row.&quot; &lt;&lt; endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; &quot;Enter -1 for the Row Number When You are Done.&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Row Number: &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; row;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(row == -1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cin.sync();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; menu();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Seat Number: &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; seat;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }while(row &gt; 0);<br />
&nbsp; &nbsp; &nbsp; &nbsp; if(row &lt; 1 || row &gt; 15 || seat &lt; 1 || seat &gt; 30)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;You must enter an appropriate value.\n\n&quot;;<br />
&nbsp; &nbsp; }while(row &lt; 1 || row &gt; 15 || seat &lt; 1 || seat &gt; 30);<br />
}<br />
<br />
void total_value()<br />
{<br />
&nbsp; &nbsp; get_price();<br />
}<br />
<br />
void total_number()<br />
{<br />
}<br />
<br />
void seats_row()<br />
{<br />
}<br />
<br />
void seats_all()<br />
{<br />
}<br />
<br />
void seating_chart()<br />
{<br />
&nbsp; &nbsp; int i,j;<br />
&nbsp; &nbsp; double theater[15][30];<br />
&nbsp; &nbsp; for(i=0; i&lt;15; i++)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; for(j=0; j&lt;30; j++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; theater[i][j];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; theater[i][j];<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; <br />
}<br />
<br />
// MENU<br />
<br />
void menu()<br />
{<br />
&nbsp; &nbsp; int choice;<br />
&nbsp; &nbsp; do<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Choose One of the Following.&quot; &lt;&lt; endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; &quot;(1) Purchase Tickets.&quot; &lt;&lt; endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; &quot;(2) Display Total Dollar Value of All Tickets Sold.&quot; &lt;&lt; endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; &quot;(3) Display Total Number of Tickets Sold.&quot; &lt;&lt; endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; &quot;(4) Display the Number of Seats Available in Each Row.&quot; &lt;&lt; endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; &quot;(5) Display the Number of Seats Available in the Entire Auditorium.&quot; &lt;&lt; endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; &quot;(6) Display the Current Seating Chart.&quot; &lt;&lt; endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; &quot;(7) Exit the System.&quot; &lt;&lt; endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; &quot;Choice: &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; choice;<br />
&nbsp; &nbsp; &nbsp; &nbsp; if(choice &lt; 1 || choice &gt; 7)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;You must enter a number 1 through 7.&quot; &lt;&lt; endl;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; endl;<br />
&nbsp; &nbsp; }while(choice &lt; 1 || choice &gt; 7);<br />
<br />
&nbsp; &nbsp; if(choice == 1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; purchase();<br />
&nbsp; &nbsp; if(choice == 2)<br />
&nbsp; &nbsp; &nbsp; &nbsp; total_value();<br />
&nbsp; &nbsp; if(choice == 3)<br />
&nbsp; &nbsp; &nbsp; &nbsp; total_number();<br />
&nbsp; &nbsp; if(choice == 4)<br />
&nbsp; &nbsp; &nbsp; &nbsp; seats_row();<br />
&nbsp; &nbsp; if(choice == 5)<br />
&nbsp; &nbsp; &nbsp; &nbsp; seats_all();<br />
&nbsp; &nbsp; if(choice == 6)<br />
&nbsp; &nbsp; &nbsp; &nbsp; seating_chart();<br />
&nbsp; &nbsp; if(choice == 7)<br />
&nbsp; &nbsp; &nbsp; &nbsp; exit(1);<br />
<br />
}<br />
<br />
// MAIN FUNCTION<br />
<br />
int main()<br />
{<br />
&nbsp; &nbsp; menu();<br />
&nbsp; &nbsp; return 0;<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>Kaotic07</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239534.html</guid>
		</item>
		<item>
			<title>string input in with getline</title>
			<link>http://www.daniweb.com/forums/thread239522.html</link>
			<pubDate>Wed, 18 Nov 2009 18:04:22 GMT</pubDate>
			<description><![CDATA[Hi, 
When I want to get a string with getline function, it jumps from this statement without getting string . Because I get an integer number before it and the \n is pressed . To solving this problem I use cin >> ws before getting string with getline function . Now when I want to enter white spaces...]]></description>
			<content:encoded><![CDATA[<div>Hi,<br />
When I want to get a string with getline function, it jumps from this statement without getting string . Because I get an integer number before it and the \n is pressed . To solving this problem I use cin &gt;&gt; ws before getting string with getline function . Now when I want to enter white spaces in beginning of string , this white spaces is ignored .<br />
<span style="color:red">What can I do to solving this problem ?</span><br />
Thanks ......</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>Behi Jon</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239522.html</guid>
		</item>
		<item>
			<title>Segmentation fault with copy constructor</title>
			<link>http://www.daniweb.com/forums/thread239513.html</link>
			<pubDate>Wed, 18 Nov 2009 17:26:55 GMT</pubDate>
			<description><![CDATA[Ive been having some trouble recently with a copy constructor (related to an assigment operator which is overloaded).... ive been getting segmentation fault, and Im pretty sure that i've narrowed it down to the copy constructor 
 
Anyway, here is my code for the copy constructor: 
  <div...]]></description>
			<content:encoded><![CDATA[<div>Ive been having some trouble recently with a copy constructor (related to an assigment operator which is overloaded).... ive been getting segmentation fault, and Im pretty sure that i've narrowed it down to the copy constructor<br />
<br />
Anyway, here is my code for the copy constructor:<br />
 <pre style="margin:20px; line-height:13px">&nbsp; &nbsp; template &lt;typename L&gt;<br />
&nbsp; &nbsp; List&lt;L&gt;::List(const List&lt;L&gt;&amp; another)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp;  first = NULL;<br />
&nbsp; &nbsp; &nbsp;  last= NULL;<br />
&nbsp; &nbsp; &nbsp;  length = 0;<br />
&nbsp; &nbsp; &nbsp;  Node&lt;L&gt;* temp = another.first;<br />
&nbsp; &nbsp; &nbsp;  temp-&gt;next=another.first-&gt;next;<br />
&nbsp; &nbsp; &nbsp;  int count=0;<br />
&nbsp; &nbsp; &nbsp;  while (count &lt; another.size())<br />
&nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pushBack(temp-&gt;data);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; temp=temp-&gt;next;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; count++;<br />
&nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; }</pre><br />
<br />
it could also be happening in my operator overloading, and ive been having some trouble with that, but i dont think it is, either way here it is:<br />
 <pre style="margin:20px; line-height:13px">&nbsp; &nbsp; template &lt;typename L&gt;<br />
&nbsp; &nbsp; const List&lt;L&gt; List&lt;L&gt;::operator=(const List&lt;L&gt;&amp; another)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp;  Node&lt;L&gt;* tempLeft = last;<br />
&nbsp; &nbsp; &nbsp;  tempLeft-&gt;previous = last-&gt;previous;<br />
&nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp;  Node&lt;L&gt;* tempRight = another.first;<br />
&nbsp; &nbsp; &nbsp;  tempRight-&gt;next=another.first-&gt;next;<br />
&nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp;  int count = 0;<br />
&nbsp; &nbsp; &nbsp;  if (size() &lt;= another.size())<br />
&nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while (count &lt; size())<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  delete tempLeft;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  tempLeft = tempLeft-&gt;previous;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  pushBack (tempRight-&gt;data);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  tempRight = tempRight-&gt;next;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  count++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while (count &lt; another.size())<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  pushBack (tempRight-&gt;data);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  tempRight = tempRight-&gt;next;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  count++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp;  else<br />
&nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while (count &lt; another.size())<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  delete tempLeft;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  tempLeft = tempLeft-&gt;previous;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  pushBack (tempRight-&gt;data);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  tempRight = tempRight-&gt;next;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  count++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while (count &lt; size())<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  delete tempLeft;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  tempLeft = tempLeft-&gt;previous;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  count++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp;  return *this;<br />
&nbsp; &nbsp; }</pre><br />
<br />
Here is an example of the main function (:<br />
 <pre style="margin:20px; line-height:13px">&nbsp; &nbsp; int main()<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp;  cout&lt;&lt;&quot;***Working With A List Of Strings ***&quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;it wont even print this&quot;;<br />
&nbsp; &nbsp; &nbsp;  List&lt;string&gt; students;<br />
&nbsp; &nbsp; &nbsp;  List&lt;string&gt;::Iterator&lt;string&gt; pos;</pre><br />
any advice will be welcomed, thanks!</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>MooAndStuff</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239513.html</guid>
		</item>
		<item>
			<title>grammar interpreter</title>
			<link>http://www.daniweb.com/forums/thread239506.html</link>
			<pubDate>Wed, 18 Nov 2009 17:04:48 GMT</pubDate>
			<description>I would like to implement a program that accepts if statements and then based on grammar rules provided, validates those statements by parsing each statement into tokens. I thought about it and thought that I would read each line in as a string, break it into tokens and validate each token first...</description>
			<content:encoded><![CDATA[<div>I would like to implement a program that accepts if statements and then based on grammar rules provided, validates those statements by parsing each statement into tokens. I thought about it and thought that I would read each line in as a string, break it into tokens and validate each token first and then validate the order of the tokens in the statement. does anyone have any links I could browse to get more knowledge on?Does anyone have any suggestions as to how to do this?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>maverick0612</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239506.html</guid>
		</item>
		<item>
			<title>Why is this not giving me random pairs of numbers</title>
			<link>http://www.daniweb.com/forums/thread239503.html</link>
			<pubDate>Wed, 18 Nov 2009 16:56:36 GMT</pubDate>
			<description><![CDATA[Hey, so im trying to make a memory game using 2d arrays. 
 
This is my code to randomly generate the rows and columns but its not giving me pairs, could someone tell me why, i really dont know. 
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a...]]></description>
			<content:encoded><![CDATA[<div>Hey, so im trying to make a memory game using 2d arrays.<br />
<br />
This is my code to randomly generate the rows and columns but its not giving me pairs, could someone tell me why, i really dont know.<br />
<br />
 <pre style="margin:20px; line-height:13px">&nbsp;  for (int r=0; r&lt;4; r++)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (int c=0; c&lt;4; c++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cards[r][c]=rand()%8+1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;cards[r][c];<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt;endl;<br />
&nbsp; &nbsp; }</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>Ponomous</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239503.html</guid>
		</item>
		<item>
			<title>problem in using one class data members in another class.</title>
			<link>http://www.daniweb.com/forums/thread239500.html</link>
			<pubDate>Wed, 18 Nov 2009 16:52:24 GMT</pubDate>
			<description><![CDATA[Hello, 
 
I am having trouble in using the data member of class 1 in the member function of another class 2. Following is my code. 
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a...]]></description>
			<content:encoded><![CDATA[<div>Hello,<br />
<br />
I am having trouble in using the data member of class 1 in the member function of another class 2. Following is my code.<br />
<br />
 <pre style="margin:20px; line-height:13px">class a {<br />
public:<br />
&nbsp; &nbsp;  a();&nbsp; <br />
&nbsp; &nbsp; ~a();<br />
<br />
&nbsp; &nbsp;  std::vector&lt;int&gt; temp;&nbsp; &nbsp; <br />
};<br />
<br />
class b {<br />
public:<br />
&nbsp; &nbsp; &nbsp; b();<br />
&nbsp; &nbsp; &nbsp; ~b();<br />
&nbsp; &nbsp; &nbsp; int test();<br />
}<br />
<br />
b::b()<br />
{<br />
&nbsp; &nbsp; &nbsp; a *a1;<br />
&nbsp; &nbsp; &nbsp; a1 = new a();<br />
}<br />
<br />
b::test()<br />
{<br />
&nbsp; &nbsp; &nbsp; a *a2;<br />
<span style="color:Green">&nbsp; &nbsp; &nbsp; a2-&gt;temp.size();&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Error here</span>. <br />
}<br />
<br />
int main()<br />
{<br />
&nbsp; &nbsp;  b *b1;<br />
&nbsp; &nbsp;  b1 = new b();<br />
&nbsp; &nbsp;  return 0;<br />
}</pre><br />
I am creating a new pointer for the class 'a' inside the function of another class 'b'. Is that wrong. What would be the right way to do so.<br />
<br />
Any help is really appreciated.<br />
<br />
Thanks</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>guest7</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239500.html</guid>
		</item>
		<item>
			<title>Segmentation Fault - Urgent Help</title>
			<link>http://www.daniweb.com/forums/thread239491.html</link>
			<pubDate>Wed, 18 Nov 2009 16:02:32 GMT</pubDate>
			<description><![CDATA[<div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox" title="Help with Code Tags" target="_blank">Help with Code Tags</a> </div> <div> <strong>C++ Syntax</strong> (<a...]]></description>
			<content:encoded><![CDATA[<div> <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
#include &lt;fstream&gt;<br />
#include &lt;string&gt;<br />
#include &quot;LinDicT.h&quot;<br />
<br />
using namespace std;<br />
<br />
<br />
int main()<br />
{<br />
&nbsp; &nbsp; LinDicT l; <br />
&nbsp; &nbsp; &nbsp; &nbsp; ifstream inFile;&nbsp;  // input file stream variable<br />
&nbsp; &nbsp; &nbsp; &nbsp; string w, m;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int choice;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
&nbsp; &nbsp; inFile.open(&quot;meanings.dat&quot;);&nbsp; // open the input file<br />
&nbsp; &nbsp; if (!inFile)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;Cannot open the input file&quot; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt; &quot;The program terminates.&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp;  return 1;<br />
&nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; while (!inFile.eof())<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; inFile &gt;&gt; w;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; getline(inFile, m, '\n'); <br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; l.insert(w, m);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Enter your choice: &quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; choice;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(choice == 1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; l.traverse();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if(choice == 2)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; List* def;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; def = l.lookUp(w);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(def == NULL)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cerr &lt;&lt; &quot;word not found!&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; def-&gt;printList();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if(choice == 3)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; inFile.close();&nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
&nbsp; &nbsp; return 0;<br />
}</pre><br />
When compiling it with other classes 'Segmentation Fault' occurs, can anyone spot an error in the above code please?<br />
<br />
Thanks..</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>nitrogen33</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239491.html</guid>
		</item>
		<item>
			<title>Pretty serious beginner project, need help with algorithms</title>
			<link>http://www.daniweb.com/forums/thread239489.html</link>
			<pubDate>Wed, 18 Nov 2009 15:52:49 GMT</pubDate>
			<description><![CDATA[This is the first big program I'm gonna do and so far, i have really no idea on how to go about it. 
Basically, I aim to create a C++ program that:- 
1. Takes expressions of the form... 
(3+4(5*2)+(3/(sin 62))-4) 
or similar ones and evaluates them 
2. Takes equations of the form...]]></description>
			<content:encoded><![CDATA[<div>This is the first big program I'm gonna do and so far, i have really no idea on how to go about it.<br />
Basically, I aim to create a C++ program that:-<ol style="list-style-type: decimal"><li>Takes expressions of the form...<br />
<img src="/cgi-bin/mimetex.cgi?(3+4(5*2)+(3/(sin 62))-4)" alt="(3+4(5*2)+(3/(sin 62))-4)" border="0" /><br />
or similar ones and evaluates them</li>
<li>Takes equations of the form<br />
<img src="/cgi-bin/mimetex.cgi?F=qQ/(4*3.14*8.85*r^2)" alt="F=qQ/(4*3.14*8.85*r^2)" border="0" /><br />
Asks the user what is constant and what varies, and creates a graph on the screen. Options would include saving graphs,reading from disk,etc.</li>
<li> May add a few more things later</li>
</ol>Some help and basic stuff on how to approach this would be really helpful.<br />
And oh, this is my first post here. Thanks!:)</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>Chetan_</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239489.html</guid>
		</item>
		<item>
			<title>Calculator Parser</title>
			<link>http://www.daniweb.com/forums/thread239477.html</link>
			<pubDate>Wed, 18 Nov 2009 15:10:27 GMT</pubDate>
			<description>I am attempting to write a program that evaluates a mathematical expression after parsing it. I have the parser correct, using a string to strip it into tokens and compare it to grammar rules to validate the expression. It should be able to evaluate expressions of type 
(3+2)*4+-1= where negative...</description>
			<content:encoded><![CDATA[<div>I am attempting to write a program that evaluates a mathematical expression after parsing it. I have the parser correct, using a string to strip it into tokens and compare it to grammar rules to validate the expression. It should be able to evaluate expressions of type<br />
(3+2)*4+-1= where negative numbers are included. I am having a tough time with the evaluation part.<br />
 <pre style="margin:20px; line-height:13px">string result;<br />
string token1;<br />
string token2;<br />
double c=0;<br />
double d=0;<br />
stack&lt;double&gt; nums;<br />
<br />
for(int i=0; i&lt;exp.size();i++)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; token1= exp.at(i);<br />
&nbsp; &nbsp; &nbsp; &nbsp; if(isdigit(exp.at(i)))<br />
&nbsp; &nbsp; &nbsp; &nbsp; { c= atof (token1.c_str());<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  nums.push(c);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; switch(s_mapStringValues[token1])&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  case PLUS:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  case MINUS:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  case MUL:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  case DIV:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; }</pre><br />
<br />
Using the idea of pushing the number onto a stack and then popping last two and evaluating when finding an operator does not work when I have two operators following each other as 3*-4. Any ideas around this?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>maverick0612</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239477.html</guid>
		</item>
		<item>
			<title>2-d array problem</title>
			<link>http://www.daniweb.com/forums/thread239470.html</link>
			<pubDate>Wed, 18 Nov 2009 14:27:22 GMT</pubDate>
			<description>This is the problem i have to do: 
Use a 3 x 4 matrix (i.e., a two-dimensional array with 3 rows and 4 columns).  Each row contains the 3 coefficients of an equation and the solution.  For example, in the equations given in the book: 
 
3x + 2y - z = 10,  -x + 3y +2z = 5,  x - y - z = -1 
 
the...</description>
			<content:encoded><![CDATA[<div>This is the problem i have to do:<br />
Use a 3 x 4 matrix (i.e., a two-dimensional array with 3 rows and 4 columns).  Each row contains the 3 coefficients of an equation and the solution.  For example, in the equations given in the book:<br />
<br />
3x + 2y - z = 10,  -x + 3y +2z = 5,  x - y - z = -1<br />
<br />
the matrix will look like:<br />
<br />
3  2  -1  10<br />
<br />
-1  3  2  5<br />
<br />
1  -1  -1  -1<br />
<br />
Use the Gaussian elimination method described in the book.  You should use at least two separate matrices to store the results of the various steps.  Retain the original equations in one of the matrices.<br />
<br />
Your program will have to work for any system of 3 equations with 3 unknowns.  It must ask the user to input in the coefficients and solutions.  The output will be something along the lines of:  The solution is: x = -2, y = 5, z = -6<br />
<br />
and i got this much so far but i don't know what to do now.<br />
<br />
 <pre style="margin:20px; line-height:13px">/* 2d array */<br />
<br />
#include &lt;iostream&gt;<br />
#include &lt;cmath&gt; <br />
<br />
<br />
using namespace std;<br />
const int rows (3), cols (4);<br />
<br />
int main ()<br />
{<br />
&nbsp; &nbsp; double A [rows][cols], B[rows][cols], C[rows][cols]; <br />
&nbsp; &nbsp; &nbsp; &nbsp;  for ( int i=0, i&lt;3, i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout&lt;&lt; &quot; Enter first coefficient of eq. 1&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; i+1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cin&gt;&gt; A[i][0];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout&lt;&lt; &quot; Enter second coefficent of eq. 1&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; i+1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cin&gt;&gt; A[i][1];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout&lt;&lt; &quot; Enter solution to eq. 1&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt;i=1<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cin&gt;&gt; A[i][2];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  for ( int j=0, j&lt;3, j++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout&lt;&lt; &quot; Enter coefficient&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; j+1&lt;&lt; &quot;of equation&quot;&lt;&lt; i+1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cin&gt;&gt; A[i][j];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout&lt;&lt; &quot; Enter solution of equation&quot;&lt;&lt; i+1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cin&gt;&gt; A[i][3];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  multipler = -A[0][0] / A[1][0]<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  for (i=0; i&lt;4, i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  B[1][i]= multipler * A[1][i];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  multiipler= A[0][0] / A[2][0];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  for (i=0; i&lt;4, i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  B[2][i]= multipler * A[2][i];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  multiipler= A[0][0] / A[3][0];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  for (i=0; i&lt;4, i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  B[3][i]= multipler * A[3][i];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  return 0;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>bigskinny1989</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239470.html</guid>
		</item>
		<item>
			<title>Problem to do</title>
			<link>http://www.daniweb.com/forums/thread239461.html</link>
			<pubDate>Wed, 18 Nov 2009 13:46:04 GMT</pubDate>
			<description>If you want to keep your brain thinking got a program that is fun to write.  Winner gets prize uf done correctly. 
 
Description:  Design and implement an application that creates a histogram that allows you to visually inspect the frequency distribution of a set of values.  The program should read...</description>
			<content:encoded><![CDATA[<div>If you want to keep your brain thinking got a program that is fun to write.  Winner gets prize uf done correctly.<br />
<br />
Description:  Design and implement an application that creates a histogram that allows you to visually inspect the frequency distribution of a set of values.  The program should read in an arbitrary number of integers that are in the range 1 – 100 inclusive, then produce a chart similar to the one below that indicates how many input values fell in the range of 1 to 10, 11 – 20, and so on.  Print one asterisk for each value entered.  After the histogram has been displayed, allow the user to clear the screen and create another one as many times as he wishes.<br />
<br />
  1 – 10	| **************************<br />
11 – 20	| ***<br />
21 – 30	|******<br />
31 – 40	|**<br />
41 – 50	|*<br />
51 – 60	|<br />
61 – 70	|************************************<br />
71 – 80	|***<br />
81 – 90	|****************<br />
91 – 100	| **</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>kennyted</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239461.html</guid>
		</item>
		<item>
			<title>GUI Builder for Code::Blocks</title>
			<link>http://www.daniweb.com/forums/thread239458.html</link>
			<pubDate>Wed, 18 Nov 2009 13:40:04 GMT</pubDate>
			<description>Is there a GUI Builder for Code::Blocks, something like BOA for Python? 
Greetings, Emir</description>
			<content:encoded><![CDATA[<div>Is there a GUI Builder for Code::Blocks, something like BOA for Python?<br />
Greetings, Emir</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>emir_gradacac</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239458.html</guid>
		</item>
		<item>
			<title>2d sprite rotate toward mouse cursor</title>
			<link>http://www.daniweb.com/forums/thread239454.html</link>
			<pubDate>Wed, 18 Nov 2009 13:29:50 GMT</pubDate>
			<description>Hi, 
with c++, what is the steps to make centered 2d sprite rotate oriented toward mouse cursor, i heard that i should use trigonometry.. 
can someone tell me these steps without coding 
 
regards 
iammfa</description>
			<content:encoded><![CDATA[<div>Hi,<br />
with c++, what is the steps to make centered 2d sprite rotate oriented toward mouse cursor, i heard that i should use trigonometry..<br />
can someone tell me these steps without coding<br />
<br />
regards<br />
iammfa</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>iammfa</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239454.html</guid>
		</item>
		<item>
			<title>Is codeblocks a GNU compiler?</title>
			<link>http://www.daniweb.com/forums/thread239422.html</link>
			<pubDate>Wed, 18 Nov 2009 10:47:37 GMT</pubDate>
			<description>Is codeblocks an ANSI compiler compatible with gcc/g++/gpp (the GNU C/C++ Compilers)?</description>
			<content:encoded><![CDATA[<div>Is codeblocks an ANSI compiler compatible with gcc/g++/gpp (the GNU C/C++ Compilers)?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>Nikhar</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239422.html</guid>
		</item>
		<item>
			<title>validity check for converter</title>
			<link>http://www.daniweb.com/forums/thread239416.html</link>
			<pubDate>Wed, 18 Nov 2009 10:30:56 GMT</pubDate>
			<description><![CDATA[im having a problem with my converter. 
 
 this is my code : 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox" title="Help with Code Tags" target="_blank">Help...]]></description>
			<content:encoded><![CDATA[<div>im having a problem with my converter.<br />
<br />
 this is my code :<br />
 <pre style="margin:20px; line-height:13px">void romanNumeral::convert(){<br />
&nbsp; &nbsp;  for(int i=0; i &lt; roman.length(); i++){<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; letter = roman.at(i);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; switch(letter){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 'M': <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 'm': decimal += 1000; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 'D': <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 'd': decimal += 500; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 'C': <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 'c': decimal += 100; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 'L': <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 'l': decimal += 50; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 'X': <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 'x': decimal += 10; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 'V': <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 'v': decimal += 5; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 'I': <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 'i': decimal += 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp;  }<br />
&nbsp; &nbsp;  cout &lt;&lt; decimal;<br />
}</pre><br />
is there any way to detect that &quot;iv&quot; is 4 and not 6. and some of the roman numerals like &quot;ix&quot; should be 9 and not 11.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>kz07</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239416.html</guid>
		</item>
		<item>
			<title>Arrays_Grade</title>
			<link>http://www.daniweb.com/forums/thread239407.html</link>
			<pubDate>Wed, 18 Nov 2009 09:37:02 GMT</pubDate>
			<description><![CDATA[This program passes two parallel arrays ta a function that prints the grade reports i.e Jay Rino -- Grade: A, I had coded this program as per my knowledge but it does not executed well please help me solve this. I know there is no user input needed but I dont know how to pass that using arrays &...]]></description>
			<content:encoded><![CDATA[<div>This program passes two parallel arrays ta a function that prints the grade reports i.e Jay Rino -- Grade: A, I had coded this program as per my knowledge but it does not executed well please help me solve this. I know there is no user input needed but I dont know how to pass that using arrays &amp; functions, please help me.<br />
<br />
 <pre style="margin:20px; line-height:13px">// StudentGrades.cpp - This program assigns a letter grade to a student.<br />
// Input:&nbsp; None<br />
// Output:&nbsp; Student name and grade<br />
<br />
#include &lt;cstdlib&gt;<br />
#include &lt;iostream&gt;<br />
#include &lt;string&gt;<br />
<br />
using namespace std;<br />
<br />
// Write function declaration here<br />
&nbsp;int main(int argc, char *argv[]) <br />
&nbsp;{<br />
&nbsp;const int size=10;<br />
&nbsp;double Grades;<br />
&nbsp;double grades[size] = {76, 65, 59, 98, 92, 88, 76, 54, 93, 78};<br />
&nbsp;string students[size] = {&quot;Ray Evans&quot;, &quot;Sonia Bell&quot;, &quot;Tim Egan&quot;, &quot;Karen Davis&quot;, &quot;Dan Peters&quot;,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;Jean Janson&quot;, &quot;Ellen Thomas&quot;, &quot;Susan Swanson&quot;, &quot;Ellie Rodriguez&quot;, &quot;Gupta Patel&quot;};&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp;int x=0;<br />
&nbsp;cout &lt;&lt; &quot;Enter grade ---&gt; &quot;;<br />
&nbsp;cin &gt;&gt; Grades;<br />
&nbsp;while ( x &lt; 11)<br />
&nbsp;{<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (Grades &lt; 60)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;F ---&gt; &quot;&lt;&lt;students[x];<br />
&nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp;  else if ( Grades &gt;=60 || Grades &lt;= 69)<br />
&nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;D ----&gt; &quot; &lt;&lt;students[x];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  else if (Grades &gt;= 70 || Grades &lt;= 79)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;C ---&gt; &quot; &lt;&lt;students [x];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  else if ( Grades &gt;= 80 || Grades &lt;= 89)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cout &lt;&lt; &quot;B ---&gt; &quot;&lt;&lt;students [x];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  else if (Grades &gt;= 90 || Grades &lt;= 99)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;A ---&gt; &quot;&lt;&lt;students [x];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  x = x + 1;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  // Call calculateGrades function here&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp;<br />
&nbsp;  system(&quot;PAUSE&quot;);<br />
&nbsp;  return EXIT_SUCCESS;<br />
&nbsp;} // End of main() function<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp;  // Write calculateGrades function here</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>maverick405</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239407.html</guid>
		</item>
		<item>
			<title>Help with a sort function for linked lists.</title>
			<link>http://www.daniweb.com/forums/thread239392.html</link>
			<pubDate>Wed, 18 Nov 2009 08:21:23 GMT</pubDate>
			<description><![CDATA[Hello, I have this sort function that needs to be able to sort both strings and ints in a linked list. While the code I have does compile, It seems like it goes into an infinite loop and does not sort my elements. Can anyone see any problems or give me some advice? 
 
  <div class="codeblock"> <div...]]></description>
			<content:encoded><![CDATA[<div>Hello, I have this sort function that needs to be able to sort both strings and ints in a linked list. While the code I have does compile, It seems like it goes into an infinite loop and does not sort my elements. Can anyone see any problems or give me some advice?<br />
<br />
 <pre style="margin:20px; line-height:13px">&nbsp; template&lt;typename L&gt;&nbsp; <br />
&nbsp; void List&lt;L&gt;::sort()<br />
&nbsp;{<br />
&nbsp; &nbsp; &nbsp; Node&lt;L&gt;* pt1;<br />
&nbsp; &nbsp; &nbsp; Node&lt;L&gt;* minPointer;<br />
&nbsp; &nbsp; &nbsp; Node&lt;L&gt;* pt2;<br />
&nbsp; &nbsp; &nbsp; pt1=first;<br />
<br />
&nbsp; &nbsp; &nbsp; while (pt1 !=NULL)&nbsp; <br />
&nbsp; &nbsp; &nbsp;  pt2=pt1-&gt;next;&nbsp; <br />
&nbsp; &nbsp; &nbsp;  minPointer=pt1;<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; while (pt2 !=NULL)<br />
&nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(pt2-&gt;data &lt; minPointer-&gt;data)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; minPointer=pt2;<br />
&nbsp; &nbsp; &nbsp;  } <br />
&nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; pt2=pt2-&gt;next;&nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; swap(minPointer-&gt;data, pt1-&gt;data);<br />
&nbsp; &nbsp; &nbsp; &nbsp; pt1=pt1-&gt;next;&nbsp; &nbsp; <br />
&nbsp; &nbsp; }</pre><br />
Please let me know if any of the other parts of the code are needed.<br />
<br />
Thank You</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>Jehutiy</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239392.html</guid>
		</item>
		<item>
			<title>I need help!!!</title>
			<link>http://www.daniweb.com/forums/thread239354.html</link>
			<pubDate>Wed, 18 Nov 2009 05:01:21 GMT</pubDate>
			<description><![CDATA[My teacher gave us an assignment where she wanted us to write a program that would read test score data from a text file,drop the lowest test score,average the other three test scores, and output the data to a text file.  I've spent three days trying to figure out how to drop the lowest test score....]]></description>
			<content:encoded><![CDATA[<div>My teacher gave us an assignment where she wanted us to write a program that would read test score data from a text file,drop the lowest test score,average the other three test scores, and output the data to a text file.  I've spent three days trying to figure out how to drop the lowest test score.  My teacher won't let us use void statements or arrays.  The test data is just numbers with no characters involved, but i'm really tired so if anybody can please take a look at my code and tell me what's wrong so I can fix it and go to sleep that would be so coool.<br />
<br />
 <pre style="margin:20px; line-height:13px"># include &lt;iostream&gt;<br />
# include &lt;fstream&gt;<br />
# include &lt;string&gt;<br />
# include &lt;iomanip&gt;<br />
<br />
using namespace std;<br />
<br />
double FindFirst(double,double,double,double,double);<br />
<br />
int main()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; ifstream inFile;<br />
&nbsp; &nbsp; &nbsp; &nbsp; ofstream outFile;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; double test1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; double test2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; double test3;<br />
&nbsp; &nbsp; &nbsp; &nbsp; double test4;<br />
&nbsp; &nbsp; &nbsp; &nbsp; double first;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; inFile.open(&quot;H:\\tests.txt&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; outFile.open(&quot;H:\\outData_2.txt&quot;);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; inFile &gt;&gt; test1&gt;&gt;test2&gt;&gt;test3&gt;&gt;test4;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; while (!inFile.eof())<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; outFile&lt;&lt; fixed&lt;&lt; showpoint&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; outFile&lt;&lt;setprecision(1)&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; outFile&lt;&lt;setw(6)&lt;&lt;&quot;Test 1&quot;&lt;&lt;setw(6)&lt;&lt;&quot;Test2&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &quot;&lt;&lt;setw(6)&lt;&lt;&quot;Test3&quot;&lt;&lt;setw(6)&lt;&lt;&quot;Test4&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &quot;&lt;&lt;setw(6)&lt;&lt;&quot;Average&quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(!inFile.eof())<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; first=0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; first = FindFirst(test1,test2,test3,test4,first);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; outFile&lt;&lt;setw(6)&lt;&lt;test1&lt;&lt;setw(6)&lt;&lt;test2&lt;&lt;setw(6)&lt;&lt;test3&lt;&lt;setw(6)&lt;&lt;test4&lt;&lt;setw(6)&lt;&lt;first&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inFile&gt;&gt;test1&gt;&gt;test2&gt;&gt;test3&gt;&gt;test4;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (inFile.eof())<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; outFile&lt;&lt;&quot;This program was created by Gainor Whitaker.End of program.&quot;&lt;&lt;endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; inFile.close();<br />
&nbsp; &nbsp; &nbsp; &nbsp; outFile.close();<br />
<br />
return 0;<br />
}<br />
double FindFirst(double test1,double test2,double test3,double test4,double first)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; if(test1&gt;test2&amp;&amp;test3&gt;test4)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; first = test1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; else if(test4&gt;test1&amp;&amp;test2&gt;test3)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; first = test4;<br />
&nbsp; &nbsp; &nbsp; &nbsp; else if(test3&gt;test4&amp;&amp;test1&gt;test2)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; first = test3;<br />
&nbsp; &nbsp; &nbsp; &nbsp; else if(test2&gt;test3&amp;&amp;test4&gt;test1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; first = test2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; return first;<br />
}</pre><br />
the following is the input data:<br />
75 85 95 65<br />
89 90 79 87<br />
70 68 77 82<br />
50 92 86 88<br />
87.5 91.5 66.5 78.5<br />
I am at my wits end here.  I can get the program to store the data and average the scores, but finding the lowest one and dropping it is killing me.  If you can help me you are the greatest person ever.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>paddowan34</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239354.html</guid>
		</item>
		<item>
			<title>char arrays and inFile</title>
			<link>http://www.daniweb.com/forums/thread239340.html</link>
			<pubDate>Wed, 18 Nov 2009 03:58:28 GMT</pubDate>
			<description><![CDATA[I have to call in two files, both have 20 letters in them. my program needs to be able to handle up to 50 chars and stop at the blank space. 
 
i need help getting the chars into the array and stopping at blank space 
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right;...]]></description>
			<content:encoded><![CDATA[<div>I have to call in two files, both have 20 letters in them. my program needs to be able to handle up to 50 chars and stop at the blank space.<br />
<br />
i need help getting the chars into the array and stopping at blank space<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
#include &lt;fstream&gt;<br />
<br />
using namespace std;<br />
<br />
int main()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; ifstream inFile(&quot;student.txt&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; ifstream infile(&quot;correct.txt&quot;);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; const int questions=50;<br />
&nbsp; &nbsp; &nbsp; &nbsp; char student[questions];<br />
&nbsp; &nbsp; &nbsp; &nbsp; char correct[questions];<br />
&nbsp; &nbsp; &nbsp; &nbsp; int i;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int count=0;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; for(count=0; count&lt;questions; count++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (i=0; i&lt;questions; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inFile &gt;&gt; student[i];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (inFile)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; count++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; for (i=0; i&lt;(count-1); i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; student[i] &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; inFile.close();<br />
&nbsp; &nbsp; &nbsp; &nbsp; infile.close();<br />
&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>jigglymig1</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239340.html</guid>
		</item>
		<item>
			<title><![CDATA[Overloading [] operators in a paramatrized linked list]]></title>
			<link>http://www.daniweb.com/forums/thread239334.html</link>
			<pubDate>Wed, 18 Nov 2009 03:22:28 GMT</pubDate>
			<description><![CDATA[Hey guys, im having some trouble in finding what I should return with the [] operator overloading. Here is my implementation code: 
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a...]]></description>
			<content:encoded><![CDATA[<div>Hey guys, im having some trouble in finding what I should return with the [] operator overloading. Here is my implementation code:<br />
<br />
 <pre style="margin:20px; line-height:13px">&nbsp; &nbsp; template &lt;typename L&gt;<br />
&nbsp; &nbsp; L&amp; List&lt;L&gt;::operator[](int index) throw (ListException)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp;  if (index &gt;= length || index &lt; 0)<br />
&nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; throw (&quot;In function: operator[]: index &gt;= length or &lt; 0&quot;);<br />
&nbsp; &nbsp; &nbsp;  }<br />
&nbsp; &nbsp; &nbsp;  else<br />
&nbsp; &nbsp; &nbsp;  {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Node&lt;L&gt;* ptr = first;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ptr-&gt;next = first-&gt;next;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int cnt=0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while (cnt &lt; index)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  ptr = ptr-&gt;next;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cnt++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp;  }&nbsp;  <br />
&nbsp; &nbsp; &nbsp;  return *ptr-&gt;data;<br />
&nbsp; &nbsp; }</pre><br />
I keep getting the error: 'ptr' was not declared in this scope<br />
It gives me this error at the line<br />
 <pre style="margin:20px; line-height:13px">return *ptr-&gt;data;</pre><br />
I cant figure out what return value I need to use. I know it shouold be L&amp;, which is a dereferenced value of one module of that list...but im having trouble. Ive tried simply ptr-&gt;data, among many other things. Any help would be greatly appreciated! Thanks! =)</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>MooAndStuff</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239334.html</guid>
		</item>
		<item>
			<title>Help about opencv</title>
			<link>http://www.daniweb.com/forums/thread239329.html</link>
			<pubDate>Wed, 18 Nov 2009 02:28:14 GMT</pubDate>
			<description>Dear All, 
First of all, I do not know if this is the correct place or not but I am having problems about playing video by using opencv. I am trying to play an .avi video. I did exactly the same thing as tutorial but the code below does not work. Video and source code are in the same folder. Even...</description>
			<content:encoded><![CDATA[<div>Dear All,<br />
First of all, I do not know if this is the correct place or not but I am having problems about playing video by using opencv. I am trying to play an .avi video. I did exactly the same thing as tutorial but the code below does not work. Video and source code are in the same folder. Even though program is built successfully,  it can not play the video.<br />
Can someone please help me ? <br />
I appreciate for helps,<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;cv.h&gt;<br />
#include &lt;highgui.h&gt;<br />
int main()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; cvNamedWindow( &quot;Example2&quot;, CV_WINDOW_AUTOSIZE );<br />
&nbsp; &nbsp; &nbsp; &nbsp; CvCapture* capture = cvCreateFileCapture( &quot;MGC_RC_ATV.avi&quot; );<br />
&nbsp; &nbsp; &nbsp; &nbsp; IplImage* frame;<br />
&nbsp; &nbsp; &nbsp; &nbsp; while(1) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; frame = cvQueryFrame( capture );<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if( !frame ) break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cvShowImage( &quot;Example2&quot;, frame );<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; char c = cvWaitKey(33);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if( c == 27 ) break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; cvReleaseCapture( &amp;capture );<br />
&nbsp; &nbsp; &nbsp; &nbsp; cvDestroyWindow( &quot;Example2&quot; );<br />
&nbsp; &nbsp; &nbsp; &nbsp; return 0;&nbsp; &nbsp; &nbsp; &nbsp; <br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>esesili</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239329.html</guid>
		</item>
		<item>
			<title>problem with classes</title>
			<link>http://www.daniweb.com/forums/thread239326.html</link>
			<pubDate>Wed, 18 Nov 2009 02:02:50 GMT</pubDate>
			<description><![CDATA[im having some errors with my code. can someone help me fix it? =( 
 
this is my header file: 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox" title="Help with...]]></description>
			<content:encoded><![CDATA[<div>im having some errors with my code. can someone help me fix it? =(<br />
<br />
this is my header file:<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
#include &lt;string&gt;<br />
<br />
using namespace std;<br />
<br />
class dayType{<br />
<br />
public:<br />
&nbsp; &nbsp; &nbsp; &nbsp; dayType(string);<br />
&nbsp; &nbsp; &nbsp; &nbsp; void setDay(string);<br />
&nbsp; &nbsp; &nbsp; &nbsp; string printDay();<br />
&nbsp; &nbsp; &nbsp; &nbsp; string prevDay();<br />
&nbsp; &nbsp; &nbsp; &nbsp; void nextDay();<br />
&nbsp; &nbsp; &nbsp; &nbsp; string returnDay();<br />
<br />
private:<br />
&nbsp; &nbsp; &nbsp; &nbsp; string weekDay[7];<br />
&nbsp; &nbsp; &nbsp; &nbsp; int currentDay;<br />
&nbsp; &nbsp; &nbsp; &nbsp; string inputDay;<br />
};<br />
<br />
dayType::dayType(string){<br />
&nbsp; &nbsp; currentDay = 0;<br />
&nbsp; &nbsp; inputDay = &quot;&quot;;<br />
&nbsp; &nbsp; weekDay[7] = {&quot; &quot;};<br />
}<br />
<br />
void dayType::setDay(string day){<br />
<br />
&nbsp; &nbsp; if(day==&quot;Monday&quot; || day==&quot;MON&quot;){<br />
&nbsp; &nbsp; &nbsp; &nbsp; currentDay = 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; weekDay[currentDay - 1] = &quot;Monday&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; inputDay = day;<br />
&nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; else if(day==&quot;Tuesday&quot; || day==&quot;TUE&quot;){<br />
&nbsp; &nbsp; &nbsp; &nbsp; currentDay = 2;<br />
&nbsp; &nbsp; &nbsp; &nbsp; weekDay[currentDay - 1] = &quot;Tuesday&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; inputDay = day;<br />
&nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; else if(day==&quot;Wednesday&quot; || day==&quot;WED&quot;){<br />
&nbsp; &nbsp; &nbsp; &nbsp;  currentDay = 3;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  weekDay[currentDay - 1] = &quot;Wednesday&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp;  inputDay = day;<br />
&nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; else if(day==&quot;Thursday&quot; || day==&quot;THUR&quot;){<br />
&nbsp; &nbsp; &nbsp; &nbsp; currentDay = 4;<br />
&nbsp; &nbsp; &nbsp; &nbsp; weekDay[currentDay - 1] = &quot;Thursday&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; inputDay = day;<br />
&nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; else if(day==&quot;Friday&quot; || day==&quot;FRI&quot;){<br />
&nbsp; &nbsp; &nbsp; &nbsp; currentDay = 5;<br />
&nbsp; &nbsp; &nbsp; &nbsp; weekDay[currentDay - 1] = &quot;Friday&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; inputDay = day;<br />
&nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; else if(day==&quot;Saturday&quot; || day==&quot;SAT&quot;){<br />
&nbsp; &nbsp; &nbsp; &nbsp; currentDay = 6;<br />
&nbsp; &nbsp; &nbsp; &nbsp; weekDay[currentDay - 1] = &quot;Saturday&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; inputDay = day;<br />
&nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; else if(day==&quot;Sunday&quot; || day==&quot;SUN&quot;){<br />
&nbsp; &nbsp; &nbsp; &nbsp; currentDay = 7;<br />
&nbsp; &nbsp; &nbsp; &nbsp; weekDay[currentDay - 1] = &quot;Sunday&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; inputDay = day;<br />
&nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; else{<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;&quot; &lt;&lt; endl;<br />
&nbsp; &nbsp; }<br />
<br />
<br />
}<br />
string dayType::printDay(){<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; (weekDay + (currentDay-1));<br />
}<br />
<br />
string dayType::prevDay(){<br />
&nbsp; cout &lt;&lt;&nbsp; (weekDay + (currentDay - 1));<br />
}<br />
<br />
void dayType::nextDay(){<br />
&nbsp; &nbsp; switch(currentDay){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 1:{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; currentDay++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setDay(&quot;Tuesday&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 2:{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; currentDay++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setDay(&quot;Wednesday&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 3:{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; currentDay++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setDay(&quot;Thursday&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 4:{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; currentDay++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setDay(&quot;Friday&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 5:{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; currentDay++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setDay(&quot;Saturday&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 6:{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; currentDay++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setDay(&quot;Sunday&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 7:{<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; currentDay = 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setDay(&quot;Monday&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; }<br />
}</pre><br />
this is my main.<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
#include &lt;string&gt;<br />
#include &quot;dayType.h&quot;<br />
<br />
using namespace std;<br />
<br />
int main(){<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; dayType myDay(&quot;Monday&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; dayType temp(&quot;Sunday&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; myDay.printDay();<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; myDay.prevDay() &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; myDay.nextDay() &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; temp.printDay();<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; temp.prevDay() &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; temp.nextDay() &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
return 0;<br />
<br />
}</pre><br />
i'm pretty lost. =( i know there are lots of errors.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>kz07</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239326.html</guid>
		</item>
		<item>
			<title>Full Binary Tree from Array</title>
			<link>http://www.daniweb.com/forums/thread239325.html</link>
			<pubDate>Wed, 18 Nov 2009 02:01:59 GMT</pubDate>
			<description><![CDATA[I'm trying to write a program that builds a full binary tree from an array containing an even number of sequential numbers. I know the memory allocation part, I'm just having trouble with how to pass the integers to act as array positions. This is what I've come up with so far: 
  <div...]]></description>
			<content:encoded><![CDATA[<div>I'm trying to write a program that builds a full binary tree from an array containing an even number of sequential numbers. I know the memory allocation part, I'm just having trouble with how to pass the integers to act as array positions. This is what I've come up with so far:<br />
 <pre style="margin:20px; line-height:13px">tree root = maketree(a, 0, i) // a is an array of i elements, containing the<br />
// numbers 1 to some multiple of 1000<br />
...<br />
tree maketree(int a[], int st, int max)<br />
{<br />
&nbsp; &nbsp; tree root = makenode(a, max/2 + (some number));<br />
&nbsp; &nbsp; root-&gt;leftchild = maketree(a, 0, max/2 + (some number));<br />
&nbsp; &nbsp; root-&gt;rightchild = maketree(a, max/2 + (some number), max);<br />
}<br />
<br />
tree makenode(int a[], int i)<br />
{<br />
&nbsp; &nbsp; tree t = newnode();<br />
&nbsp; &nbsp; t-&gt;element = a[i];<br />
&nbsp; &nbsp; t-&gt;leftchild = NULL;<br />
&nbsp; &nbsp; t-&gt;rightchild = NULL;<br />
}<br />
<br />
tree newnode()<br />
{<br />
&nbsp; &nbsp; return malloc(sizeof(node));<br />
}</pre><br />
The three places I'm unsure about are the places I've written (some number). Obviously I know they might not need a number added at all, or maybe some need a number subtracted. But at this point, I've tried every combination I could think of and nothing is coming out as a full binary tree. I think the definition I've been given is universal, but just in case, what I mean by full binary tree is a binary tree where all elements to the left of a node have elements that are less than the current node's element, and every node has two children, except for leaves of the &quot;lowest&quot; depth of the tree.<br />
<br />
If anyone has a tip for what I can fill in, or a preexisting example, it would be greatly appreciated.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>jmoran19</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239325.html</guid>
		</item>
		<item>
			<title>Help me to convert this to pseudocode and flowchart</title>
			<link>http://www.daniweb.com/forums/thread239321.html</link>
			<pubDate>Wed, 18 Nov 2009 01:49:42 GMT</pubDate>
			<description><![CDATA[<div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox" title="Help with Code Tags" target="_blank">Help with Code Tags</a> </div> <div> <strong>C++ Syntax</strong> (<a...]]></description>
			<content:encoded><![CDATA[<div> <pre style="margin:20px; line-height:13px">//Student Name: Mohamad Amiruddin &amp; Frank Douglas<br />
//Course: Diploma in Information Technology <br />
//Group: IT3<br />
//Student ID: 0165-DDC-08 &amp; 0684-DDC-08<br />
//Program Name: Student Grade Report <br />
//Assignment Number: 1 <br />
//Assignment Name: Assignment 1 (Mini Project)<br />
<br />
#include &lt;iostream&gt;<br />
#include &lt;fstream&gt;<br />
#include &lt;iomanip&gt;<br />
#include &lt;string&gt;<br />
using namespace std;<br />
<br />
//Content Declaration<br />
void reportHeader_weigtage (string course, string semester, float weightage1, float weightage2, float weightage3, float weightage4);<br />
void PrintColumnHeadings(void);<br />
void PrintStudentLine(string id, string lastName, string firstName, int grade1, int grade2, int grade3, int grade4, float finalGrade);<br />
void PrintSumarryReport( int numberOfStudent, float sumOfGrade, float highestGrade, float lowestGrade);<br />
<br />
//Grade Calculation<br />
float findHighestGrade (float finalGrade);<br />
float findLowestGrade (float finalGrade);<br />
<br />
//Format Declaration<br />
void PrintALine (int range, char pattern);<br />
void SkipLines (int range);<br />
void indent (int range);<br />
<br />
<br />
ifstream infile (&quot;C:\\students.dat&quot;);&nbsp; &nbsp; &nbsp; &nbsp;  //input data file: variable name for &quot;C:\\student.dat&quot; is infile.<br />
ofstream outReport (&quot;C:\\report.txt&quot;);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  //output text file: variable name for &quot;C:\\report.txt&quot; is outreport.<br />
<br />
int main ()<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; //Declaring Variable<br />
&nbsp; &nbsp; &nbsp; &nbsp; string course, semester, id, firstName, lastName;<br />
&nbsp; &nbsp; &nbsp; &nbsp; float w1, w2, w3, w4;&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; int numberOfStudent=0, grade1, grade2, grade3, grade4;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; //Record the number of students and their grades for test 1 - 4.<br />
&nbsp; &nbsp; &nbsp; &nbsp; float finalGrade, sumOfGrade =0, highestGrade, lowestGrade;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; if (!infile)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Files Testing&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cerr &lt;&lt; &quot;Error: could not open input file\n&quot;;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Prompt when no input file.<br />
&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (!outReport)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //If no outReport<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  cerr &lt;&lt; &quot;Error: could not open output file\n&quot;;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Prompt when no output file.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; infile &gt;&gt; course &gt;&gt; semester &gt;&gt; w1 &gt;&gt; w2 &gt;&gt; w3 &gt;&gt; w4;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Take the datas from &quot;student.dat&quot;.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; reportHeader_weigtage (course, semester, w1, w2, w3, w4); //Put the data into this reportHeader &amp; weigtage function.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while (infile &gt;&gt; id &gt;&gt; lastName &gt;&gt; firstName &gt;&gt; grade1 &gt;&gt; grade2 &gt;&gt; grade3 &gt;&gt; grade4)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Using loop to record data from &quot;student.dat&quot; student's ID, First and Last name, and Grade for test1-4.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; finalGrade =&nbsp; w1*grade1 + w2*grade2 + w3*grade3 + w4*grade4;&nbsp; &nbsp; &nbsp; &nbsp; //The final Grade for the particular student is calculated.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PrintStudentLine( id,&nbsp; lastName,&nbsp; firstName,&nbsp; grade1,&nbsp; grade2,&nbsp; grade3,&nbsp; grade4,&nbsp; finalGrade);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Put the data into this PrintStudentLine function.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sumOfGrade += finalGrade;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Add the final Grade to the sumGrade.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; numberOfStudent++;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Increase the numberOfStudent by 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; highestGrade = findHighestGrade(finalGrade);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Find the highest in findHighestGrade function.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lowestGrade = findLowestGrade(finalGrade);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Find the lowest in findLowestGrade function.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PrintSumarryReport( numberOfStudent,&nbsp; sumOfGrade, highestGrade, lowestGrade);&nbsp; //Save the datas in PrintSumarryReport.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cout &lt;&lt; &quot;Close console window?&nbsp; &quot;;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; char c; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cin &gt;&gt; c;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; return 0;<br />
}<br />
float findHighestGrade (float finalGrade)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; static float MaxSoFar = -1;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Create a time-limited variable MaxSofar.<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (finalGrade &gt; MaxSoFar)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //MaxSoFar = -1 : because every positive number is bigger than -1.<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MaxSoFar = finalGrade;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; return MaxSoFar;&nbsp; &nbsp; &nbsp; &nbsp; <br />
}<br />
float findLowestGrade (float finalGrade)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; static float MinSoFar = 150;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Create a time-limited variable minSoFar.<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (finalGrade &lt; MinSoFar)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Record every value which smaller.<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MinSoFar = finalGrade;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; return MinSoFar;<br />
}<br />
<br />
void reportHeader_weigtage(string course, string semester, float weightage1, float weightage2, float weightage3, float weightage4)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; PrintALine (65, ':');<br />
&nbsp; &nbsp; &nbsp; &nbsp; indent(0);<br />
&nbsp; &nbsp; &nbsp; &nbsp; outReport &lt;&lt; &quot;Twintech College Sarawak\n&quot;;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Print Twintech College Sarawak.<br />
&nbsp; &nbsp; &nbsp; &nbsp; indent (0);<br />
&nbsp; &nbsp; &nbsp; &nbsp; outReport &lt;&lt; &quot;Student Grade Report&quot; &lt;&lt; endl;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Print Student Grade Report.<br />
&nbsp; &nbsp; &nbsp; &nbsp; PrintALine (65, ':');<br />
&nbsp; &nbsp; &nbsp; &nbsp; outReport &lt;&lt; &quot;\nSemester:&nbsp; &quot; &lt;&lt; semester &lt;&lt; &quot;\nCourse:&nbsp; &quot; &lt;&lt; course &lt;&lt;endl;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //semester and course are printed.<br />
&nbsp; &nbsp; &nbsp; &nbsp; PrintALine (65, '.');<br />
&nbsp; &nbsp; &nbsp; &nbsp; SkipLines(1);&nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; PrintALine (65, '.');<br />
&nbsp; &nbsp; &nbsp; &nbsp; PrintColumnHeadings();<br />
&nbsp; &nbsp; &nbsp; &nbsp; PrintALine (65, '.');<br />
}<br />
<br />
void PrintColumnHeadings(void)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Print the title for the report.<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; outReport &lt;&lt; setiosflags(ios::right) &lt;&lt; setw (10) &lt;&lt; &quot;Student ID&quot; &lt;&lt; setw(10) &lt;&lt;&quot;Name&quot; &lt;&lt; setw(10) &lt;&lt; ' ' <br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt; setw(20) &lt;&lt; &quot;Grades 1 - 4&quot; &lt;&lt; setw(14) &lt;&lt;&quot;Final Grade&quot; &lt;&lt; endl;<br />
}<br />
<br />
void PrintStudentLine(string id, string lastName, string firstName, int grade1, int grade2, int grade3, int grade4, float finalGrade)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; outReport &lt;&lt; setiosflags (ios::fixed) &lt;&lt; setprecision(2)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Student content.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt; setw (11) &lt;&lt; setiosflags (ios::left) &lt;&lt; id<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; setw(10) &lt;&lt; firstName &lt;&lt; setw(10) &lt;&lt; lastName<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt; setiosflags(ios::right)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt; setw (5) &lt;&lt; grade1<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt; setw (5)&lt;&lt; grade2 &lt;&lt; setw (5)&lt;&lt; grade3<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt; setw (5)&lt;&lt; grade4 &lt;&lt; setw (10) &lt;&lt; finalGrade &lt;&lt; endl;<br />
}<br />
<br />
void PrintSumarryReport( int numberOfStudent, float sumOfGrade, float highestGrade, float lowestGrade)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; SkipLines (2);<br />
&nbsp; &nbsp; &nbsp; &nbsp; PrintALine (65, ':');<br />
&nbsp; &nbsp; &nbsp; &nbsp; SkipLines (1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; outReport &lt;&lt; setiosflags(ios::showpoint | ios::fixed | ios::left)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Doing the sumarry.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; &quot;Number of students = &quot; &lt;&lt; numberOfStudent &lt;&lt; endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt; &quot;Class Average = &quot; &lt;&lt; sumOfGrade/numberOfStudent &lt;&lt; endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; &quot;Maximum Grade is &quot; &lt;&lt; highestGrade &lt;&lt; endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &lt;&lt; &quot;Minimum Grade is &quot; &lt;&lt; lowestGrade &lt;&lt; endl<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt; endl;<br />
&nbsp; &nbsp; &nbsp; &nbsp; PrintALine (65, ':');<br />
}<br />
<br />
<br />
<br />
//Print line or skip line functions<br />
void PrintALine(int range, char pattern)<br />
{&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
for (int i=1; i&lt;=range; i++)&nbsp; &nbsp; &nbsp; &nbsp; //Print a line with specific character<br />
&nbsp; &nbsp; &nbsp; &nbsp; outReport &lt;&lt; pattern;<br />
outReport &lt;&lt; endl;<br />
}<br />
<br />
void SkipLines (int range)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Print a new line<br />
{<br />
for (int i=1; i&lt;=range; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; outReport &lt;&lt; endl;<br />
}<br />
<br />
void indent (int range)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Creating spaces<br />
{<br />
for (int i=1; i&lt;=range; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; outReport &lt;&lt; ' ';<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>amer_milo</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239321.html</guid>
		</item>
		<item>
			<title>Beginner Help</title>
			<link>http://www.daniweb.com/forums/thread239319.html</link>
			<pubDate>Wed, 18 Nov 2009 01:45:14 GMT</pubDate>
			<description><![CDATA[I need to know how to get this to calculate the maxvalue of my array. I don't really understand the whole initailizing functions thing. this is what i got so far. 
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a...]]></description>
			<content:encoded><![CDATA[<div>I need to know how to get this to calculate the maxvalue of my array. I don't really understand the whole initailizing functions thing. this is what i got so far.<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
#include &lt;cstdlib&gt;<br />
<br />
using namespace std;<br />
//#include &quot;stat_lib.h&quot;<br />
int main()<br />
{<br />
&nbsp; &nbsp; double Ferdeg[100];<br />
&nbsp; &nbsp; double celdeg[100];<br />
&nbsp; &nbsp; double avg;<br />
<br />
&nbsp; &nbsp; int k; <br />
&nbsp; &nbsp; for (k=0;k&lt;100;k++)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; Ferdeg[k]=((double)rand()/RAND_MAX)*(100-70)+70;<br />
&nbsp; &nbsp; &nbsp; &nbsp; celdeg[k]=(5./9.)*(Ferdeg[k]-32);<br />
&nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; avg = mean(celdeg,100);<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>bigskinny1989</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239319.html</guid>
		</item>
		<item>
			<title><![CDATA[Why doesn't my iomanip work??]]></title>
			<link>http://www.daniweb.com/forums/thread239316.html</link>
			<pubDate>Wed, 18 Nov 2009 01:03:53 GMT</pubDate>
			<description><![CDATA[Hey, I'm pretty new to programming and I'm writing a program for my class. I can't figure out why my <iomanip> isn't working.. I'll post a copy of the code (I'm aware it's bugged, as it's not returning the proper values, but the format of the output is the issue). I'm sure I called everything I...]]></description>
			<content:encoded><![CDATA[<div>Hey, I'm pretty new to programming and I'm writing a program for my class. I can't figure out why my &lt;iomanip&gt; isn't working.. I'll post a copy of the code (I'm aware it's bugged, as it's not returning the proper values, but the format of the output is the issue). I'm sure I called everything I need to but it reads 'fixed' as an undefined value, which leads me to believe I might not have the proper library on my computer. If this is the case, how can I get it?? Thanks.<br />
<br />
 <pre style="margin:20px; line-height:13px"><br />
//**********************************************<br />
//**********************************************<br />
// N/A&nbsp;  Prof: N/A<br />
// Assignment # 6&nbsp; &nbsp; &nbsp; &nbsp; Question # 2<br />
// Program: Arrays and Functions<br />
// Purpose: Calculate and display the largest<br />
//&nbsp; &nbsp; &nbsp; &nbsp;  element, mean, standard deviation,<br />
//&nbsp; &nbsp; &nbsp; &nbsp;  and median of a user-defined set<br />
//&nbsp; &nbsp; &nbsp; &nbsp;  of integers.<br />
// Author: Cold_Demon388<br />
// Date: 16 November 2009<br />
//**********************************************<br />
//**********************************************<br />
<br />
#include &lt;iostream&gt;<br />
#include &lt;cmath&gt;<br />
#include &lt;iomanip&gt;<br />
using namespace std;<br />
<br />
int indexMax(const int x[], int length);<br />
void remove(int x[], int &amp;length, int index);<br />
int readSeq(int x[]);<br />
void writeArray(int x[], int length);<br />
double mean(const int x[], int length);<br />
double stdDeviation(const int x[], int length, double mean);<br />
double median(int x[], int length);<br />
<br />
int main()<br />
{<br />
&nbsp;  // Variable Declarations<br />
&nbsp; const int MAX_SIZE = 512;<br />
&nbsp; int x[MAX_SIZE];<br />
<br />
&nbsp;  // Get User Input<br />
&nbsp; int length = readSeq(x);<br />
<br />
&nbsp;  // Calcualtions and Output<br />
&nbsp; cout &lt;&lt; &quot;Largest: &quot; &lt;&lt; x[indexMax(x, length)] &lt;&lt; endl;<br />
&nbsp; cout &lt;&lt; fixed &lt;&lt; setprecision(1) &lt;&lt; &quot;Mean: &quot; &lt;&lt; mean(x, length) &lt;&lt; endl;<br />
&nbsp; cout &lt;&lt; setprecision(3) &lt;&lt; &quot;Std Deviation: &quot; &lt;&lt; stdDeviation(x, length, mean(x, length)) &lt;&lt; endl;<br />
&nbsp; cout &lt;&lt; setprecision(1) &lt;&lt; &quot;Median: &quot; &lt;&lt; median(x, length) &lt;&lt; endl;<br />
<br />
&nbsp;  return 0;<br />
}<br />
<br />
int indexMax(const int x[], int length)<br />
{<br />
&nbsp; int i = 0;<br />
&nbsp; int max = x[0];<br />
&nbsp; int index = 0;<br />
<br />
&nbsp; //finds max value in array and returns the index to that val<br />
&nbsp; while (i &lt; length - 1)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; if (max &lt; x[i+1])<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; max = x[i+1];<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; index++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
<br />
&nbsp; &nbsp; &nbsp; i++;<br />
&nbsp; &nbsp; }<br />
<br />
&nbsp; return index;<br />
}<br />
<br />
void remove(int x[], int &amp;length, int index)<br />
{<br />
&nbsp; //shifts value at x[index+1] to x[index] and decrements length by 1<br />
&nbsp; while (index &lt;= length - 1)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; x[index] = x[index+1];<br />
&nbsp; &nbsp; &nbsp; index++;<br />
&nbsp; &nbsp; }<br />
&nbsp; length--;<br />
}<br />
<br />
int readSeq(int x[])<br />
{<br />
&nbsp; int input;<br />
&nbsp; int length = 0;<br />
&nbsp; cin &gt;&gt; input;<br />
<br />
&nbsp; while(input != 0 &amp;&amp; length &lt;= 512)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; x[length] = input;<br />
&nbsp; &nbsp; &nbsp; length++;<br />
&nbsp; &nbsp; &nbsp; cin &gt;&gt; input;<br />
&nbsp; &nbsp; }<br />
&nbsp; <br />
&nbsp; return length;<br />
}<br />
<br />
void writeArray(int x[], int length)<br />
{<br />
&nbsp; int i = 0;<br />
&nbsp; while (i &lt; length)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; cout &lt;&lt; x[i] &lt;&lt; &quot; &quot;;<br />
&nbsp; &nbsp; &nbsp; i++;<br />
&nbsp; &nbsp; }<br />
}<br />
<br />
double mean(const int x[], int length)<br />
{<br />
&nbsp; int i = 0;<br />
&nbsp; int sum;<br />
&nbsp; while (i &lt; length)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; sum += x[i];<br />
&nbsp; &nbsp; &nbsp; i++;<br />
&nbsp; &nbsp; }<br />
<br />
&nbsp; return sum / i;<br />
}<br />
<br />
double stdDeviation(const int x[], int length, double mean)<br />
{<br />
&nbsp; int i = 0;<br />
&nbsp; double sum;<br />
<br />
&nbsp; while (i &lt; length)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; sum += (x[i] - mean) / length;<br />
&nbsp; &nbsp; &nbsp; i++;<br />
&nbsp; &nbsp; }<br />
<br />
&nbsp; return sqrt(sum);<br />
}<br />
<br />
double median(int x[], int length)<br />
{<br />
&nbsp; int i = static_cast &lt;int&gt; (length / 2);<br />
&nbsp; int originalLength = length;<br />
&nbsp; int largerNum;<br />
<br />
&nbsp; if (originalLength % 2 == 1)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; while (originalLength - i &lt; length)<br />
&nbsp; &nbsp; &nbsp; &nbsp; remove(x, length, indexMax(x, length));<br />
&nbsp;<br />
&nbsp; &nbsp; &nbsp; return x[indexMax(x, length)];<br />
&nbsp; &nbsp; }<br />
&nbsp; else<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; while (originalLength - i + 1 &lt; length)<br />
&nbsp; &nbsp; &nbsp; &nbsp; remove(x, length, indexMax(x, length));<br />
<br />
&nbsp; &nbsp; &nbsp; largerNum = indexMax(x, length);<br />
&nbsp; &nbsp; &nbsp; remove(x, length, largerNum);<br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; return (x[largerNum] + x[indexMax(x, length)]) / 2;<br />
&nbsp; &nbsp; }<br />
&nbsp;<br />
}</pre><br />
Thanks again everyone. Take care.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>Cold_Demon388</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239316.html</guid>
		</item>
		<item>
			<title>Function parameter problem</title>
			<link>http://www.daniweb.com/forums/thread239315.html</link>
			<pubDate>Wed, 18 Nov 2009 00:53:45 GMT</pubDate>
			<description>Sorry, unable to delete threads.</description>
			<content:encoded><![CDATA[<div>Sorry, unable to delete threads.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>Carrots</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239315.html</guid>
		</item>
		<item>
			<title>numbers to letter</title>
			<link>http://www.daniweb.com/forums/thread239314.html</link>
			<pubDate>Wed, 18 Nov 2009 00:48:40 GMT</pubDate>
			<description>hey guys, I want to write a program to transform numbers to letters 
 
if I write 652 I want the program to print six hundred fifty two 
 
I have written this but I have a problem. For the 652... I get six hundred 5 2. 
 
The numbers are in spanish :p 
 
help!</description>
			<content:encoded><![CDATA[<div>hey guys, I want to write a program to transform numbers to letters<br />
<br />
if I write 652 I want the program to print six hundred fifty two<br />
<br />
I have written this but I have a problem. For the 652... I get six hundred 5 2.<br />
<br />
The numbers are in spanish :p<br />
<br />
help!<br />
<br />
 <pre style="margin:20px; line-height:13px">#include &lt;iostream&gt;<br />
using std::cin;<br />
using std::cout;<br />
using std::endl;<br />
#include &lt;iomanip&gt;<br />
<br />
&nbsp;using std::setw;<br />
&nbsp;using std::setfill;<br />
<br />
using namespace std;<br />
<br />
int main ()<br />
{<br />
&nbsp; int n, uni, cent, dece, mil;<br />
&nbsp; <br />
&nbsp; cout&lt;&lt;&quot;Ingrese un numero del 1 al 9999&quot;&lt;&lt;endl;<br />
&nbsp; cin&gt;&gt;n;<br />
&nbsp; unidad=(n%10);<br />
&nbsp; decena=(n%100)/10;<br />
&nbsp; centena=(n%1000)/100;<br />
&nbsp;  millar=(n%10000)/1000;<br />
&nbsp; <br />
<br />
&nbsp; if (n==1){<br />
&nbsp; cout&lt;&lt;&quot;uno&quot;&lt;&lt;endl;}<br />
&nbsp; if (n==2){<br />
&nbsp; cout&lt;&lt;&quot;dos&quot;&lt;&lt;endl;}<br />
&nbsp; if (n==3){<br />
&nbsp; cout&lt;&lt;&quot;tres&quot;&lt;&lt;endl;}<br />
&nbsp; if (n==4){<br />
&nbsp; cout&lt;&lt;&quot;cuatro&quot;&lt;&lt;endl;}<br />
&nbsp; if (n==5){<br />
&nbsp; cout&lt;&lt;&quot;cinco&quot;&lt;&lt;endl;}<br />
&nbsp; if (n==6){<br />
&nbsp; cout&lt;&lt;&quot;seis&quot;&lt;&lt;endl;}<br />
&nbsp; if (n==7){<br />
&nbsp; cout&lt;&lt;&quot;siete&quot;&lt;&lt;endl;}<br />
&nbsp; if (n==8){<br />
&nbsp; cout&lt;&lt;&quot;ocho&quot;&lt;&lt;endl;}<br />
&nbsp; if (n==9){<br />
&nbsp; cout&lt;&lt;&quot;nueve&quot;&lt;&lt;endl;}<br />
&nbsp; if (n==10){<br />
&nbsp; cout&lt;&lt;&quot;diez&quot;&lt;&lt;endl;}<br />
&nbsp; if (n==11){<br />
&nbsp; cout&lt;&lt;&quot;once&quot;&lt;&lt;endl;}<br />
&nbsp; if (n==12){<br />
&nbsp; cout&lt;&lt;&quot;doce&quot;&lt;&lt;endl;}<br />
&nbsp; if (n==13){<br />
&nbsp; cout&lt;&lt;&quot;trece&quot;&lt;&lt;endl;}<br />
&nbsp; if (n==14){<br />
&nbsp; cout&lt;&lt;&quot;catorce&quot;&lt;&lt;endl;}<br />
&nbsp; if (n==15){<br />
&nbsp; cout&lt;&lt;&quot;quince&quot;&lt;&lt;endl;}<br />
&nbsp; if (n==16){<br />
&nbsp; cout&lt;&lt;&quot;dieciseis&quot;&lt;&lt;endl;}<br />
&nbsp; if (n==17){<br />
&nbsp; cout&lt;&lt;&quot;diecisiete&quot;&lt;&lt;endl;}<br />
&nbsp; if (n==18){<br />
&nbsp; cout&lt;&lt;&quot;dieciocho&quot;&lt;&lt;endl;}<br />
&nbsp; if (n==19){<br />
&nbsp; cout&lt;&lt;&quot;diecinueve&quot;&lt;&lt;endl;}<br />
&nbsp; if (n==20){<br />
&nbsp; cout&lt;&lt;&quot;veinte&quot;&lt;&lt;endl;}<br />
&nbsp; if (n==21){<br />
&nbsp; cout&lt;&lt;&quot;veinte y uno&quot;&lt;&lt;endl;}<br />
&nbsp; if (n==22){<br />
&nbsp; cout&lt;&lt;&quot;veinte y dos&quot;&lt;&lt;endl;}<br />
&nbsp; if (n==23){<br />
&nbsp; cout&lt;&lt;&quot;veinte y tres&quot;&lt;&lt;endl;}<br />
&nbsp; if (n==24){<br />
&nbsp; cout&lt;&lt;&quot;veinte y cuatro&quot;&lt;&lt;endl;}<br />
&nbsp; if (n==25){<br />
&nbsp; cout&lt;&lt;&quot;veinte y cinco&quot;&lt;&lt;endl;}<br />
&nbsp; if (n==26){<br />
&nbsp; cout&lt;&lt;&quot;veinte y seis&quot;&lt;&lt;endl;}<br />
&nbsp; if (n==27){<br />
&nbsp; cout&lt;&lt;&quot;veinte y siete&quot;&lt;&lt;endl;}<br />
&nbsp; if (n==28){<br />
&nbsp; cout&lt;&lt;&quot;veinte y ocho&quot;&lt;&lt;endl;}<br />
&nbsp; if (n==29){<br />
&nbsp; cout&lt;&lt;&quot;veinte y nueve&quot;&lt;&lt;endl;}<br />
&nbsp;<br />
&nbsp; if (n/10==3){<br />
&nbsp; cout&lt;&lt;&quot;treinta y &quot;&lt;&lt;unidad&lt;&lt;endl;}<br />
&nbsp; if (n/10==4){<br />
&nbsp; cout&lt;&lt;&quot;cuarenta y &quot;&lt;&lt;unidad&lt;&lt;endl;}<br />
&nbsp; if (n/10==5){<br />
&nbsp; cout&lt;&lt;&quot;cincuenta y &quot;&lt;&lt;unidad&lt;&lt;endl;}<br />
&nbsp; if (n/10==6){<br />
&nbsp; cout&lt;&lt;&quot;sesenta y &quot;&lt;&lt;unidad&lt;&lt;endl;}<br />
&nbsp; if (n/10==7){<br />
&nbsp; cout&lt;&lt;&quot;setenta y &quot;&lt;&lt;unidad&lt;&lt;endl;}<br />
&nbsp; if (n/10==8){<br />
&nbsp; cout&lt;&lt;&quot;ochenta y &quot;&lt;&lt;unidad&lt;&lt;endl;}<br />
&nbsp; if (n/10==9){<br />
&nbsp; cout&lt;&lt;&quot;noventa y &quot;&lt;&lt;unidad&lt;&lt;endl;}<br />
&nbsp; <br />
&nbsp; if (n==100){<br />
&nbsp; cout&lt;&lt;&quot;cien&quot;&lt;&lt;endl;}<br />
&nbsp; if (n&lt;200&amp;&amp; n&gt;=100){<br />
&nbsp; cout&lt;&lt;&quot;cientos&quot;&lt;&lt;endl;}<br />
&nbsp; if (n&lt;300&amp;&amp; n&gt;=200){<br />
&nbsp; cout&lt;&lt;&quot;doscientos&quot;&lt;&lt;decena&lt;&lt;&quot;y&quot;&lt;&lt;unidad&lt;&lt;endl;}<br />
&nbsp; if (n&lt;400&amp;&amp; n&gt;=300){<br />
&nbsp; cout&lt;&lt;&quot;trescientos&quot;&lt;&lt;decena&lt;&lt;&quot;y&quot;&lt;&lt;unidad&lt;&lt;endl;}<br />
&nbsp; if (n&lt;500&amp;&amp; n&gt;=400){<br />
&nbsp; cout&lt;&lt;&quot;cuatrocientos&quot;&lt;&lt;decena&lt;&lt;&quot;y&quot;&lt;&lt;unidad&lt;&lt;endl;}<br />
&nbsp; if (n&lt;600&amp;&amp; n&gt;=500){<br />
&nbsp; cout&lt;&lt;&quot;quinientos&quot;&lt;&lt;decena&lt;&lt;&quot;y&quot;&lt;&lt;unidad&lt;&lt;endl;}<br />
&nbsp; if (n&lt;700&amp;&amp; n&gt;=600){<br />
&nbsp; cout&lt;&lt;&quot;seiscientos&quot;&lt;&lt;decena&lt;&lt;&quot;y&quot;&lt;&lt;unidad&lt;&lt;endl;}<br />
&nbsp; if (n&lt;800&amp;&amp; n&gt;=700){<br />
&nbsp; cout&lt;&lt;&quot;setecientos&quot;&lt;&lt;decena&lt;&lt;&quot;y&quot;&lt;&lt;unidad&lt;&lt;endl;}<br />
&nbsp; if (n&lt;900&amp;&amp; n&gt;=800){<br />
&nbsp; cout&lt;&lt;&quot;ochocientos&quot;&lt;&lt;decena&lt;&lt;&quot;y&quot;&lt;&lt;unidad&lt;&lt;endl;}<br />
&nbsp; if (n&lt;1000&amp;&amp; n&gt;=900){<br />
&nbsp; cout&lt;&lt;&quot;novecientos&quot;&lt;&lt;decena&lt;&lt;&quot;y&quot;&lt;&lt;unidad&lt;&lt;endl;}<br />
&nbsp; if (n&lt;2000&amp;&amp; n&gt;=1000){<br />
&nbsp; cout&lt;&lt;&quot;mil&quot;&lt;&lt;endl;}<br />
&nbsp; if (n&lt;10000&amp;&amp; n&gt;=2000){<br />
&nbsp; cout&lt;&lt;&quot;dosmil&quot;&lt;&lt;centena&lt;&lt;decena&lt;&lt;&quot;y&quot;&lt;&lt;unidad&lt;&lt;endl;}<br />
&nbsp; <br />
&nbsp; <br />
&nbsp;  system(&quot;PAUSE&quot;);&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; return 0;<br />
}</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum8.html">C++</category>
			<dc:creator>alexa868</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239314.html</guid>
		</item>
	</channel>
</rss>
