Yazı mı Tura mı

 

</p>
<p>#include &lt;cstdlib&gt;<br />
#include &lt;iostream&gt;</p>
<p>using namespace std;</p>
<p>int main(void)<br />
{<br />
int count, i, heads = 0, tails = 0;<br />
float number;</p>
<p>cout &lt;&lt; &quot;Parayi Kac Kere Atacaksiniz: &quot;;<br />
cin &gt;&gt; count;<br />
srand(time(NULL));<br />
for (i = 1 ; i &lt;= count ; i++) {<br />
number = (float)rand () / RAND_MAX;<br />
if (number &lt; 0.5) {<br />
cout &lt;&lt; &quot;Tura&quot; &lt;&lt; &quot;     &quot; &lt;&lt; i &lt;&lt; &quot;. Atis&quot;&lt;&lt; endl;<br />
heads++;}<br />
else {<br />
cout &lt;&lt; &quot;Yazi&quot; &lt;&lt; &quot;     &quot; &lt;&lt; i &lt;&lt; &quot;. Atis&quot;&lt;&lt; endl;<br />
tails ++;<br />
}<br />
}<br />
cout &lt;&lt; &quot;Yazi Sayisi: &quot; &lt;&lt; tails &lt;&lt; &quot;, Yuzdesi &quot; &lt;&lt; (float)tails / (float)count * 100.0 &lt;&lt; endl;<br />
cout &lt;&lt; &quot;Tura Sayisi: &quot; &lt;&lt; heads &lt;&lt; &quot;, Yuzdesi &quot; &lt;&lt; (float)heads / (float)count * 100.0 &lt;&lt; endl;</p>
<p>system(&quot;PAUSE&quot;);<br />
return EXIT_SUCCESS;<br />
}</p>
<p>

Yorum Yapın

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Proudly powered by WordPress | Theme: Baskerville 2 by Anders Noren.

Up ↑

%d blogcu bunu beğendi: