Girilen İki Tarih Arasındaki Gün Sayısını Veren Program

</p>
<p>#include &lt;cstdlib&gt;<br />
#include &lt;iostream&gt;<br />
#include &lt;stdlib.h&gt;<br />
using namespace std;</p>
<p>int main(void)<br />
{<br />
 int ds , df, dr, ms, mf, mr, ys, yf, yr, total_days, dsc, msc, ysc;<br />
 char ans;<br />
 cout &lt;&lt; “Iki Tarih Arasinda Kalan Gun Sayisini Hesapliyoruz” &lt;&lt; endl;<br />
 new_date:<br />
 cout &lt;&lt; “Baslama Tarihini Giriniz: GG AA YYYY” &lt;&lt; endl;<br />
 cin &gt;&gt; ds &gt;&gt; ms &gt;&gt; ys ;<br />
 while (!(( ds &lt;= 31 &amp;&amp; ms == 1 )||( ds &lt;= 28 &amp;&amp; ms == 2 )||( ds &lt;= 31 &amp;&amp; ms == 3 )||( ds &lt;= 30 &amp;&amp; ms == 4 )|| // Ay-Gun<br />
 ( ds &lt;= 31 &amp;&amp; ms == 5 )||( ds &lt;= 30 &amp;&amp; ms == 6 )||( ds &lt;= 31 &amp;&amp; ms == 7 )||( ds &lt;= 31 &amp;&amp; ms == 8 )|| // tutarlýlýðýný<br />
 ( ds &lt;= 30 &amp;&amp; ms == 9 )||( ds &lt;= 31 &amp;&amp; ms == 10 )||( ds &lt;= 30 &amp;&amp; ms == 11 )||( ds &lt;= 31 &amp;&amp; ms == 12 ) // sorgulama satýrlarý<br />
 ||(ds &lt;= 29 &amp;&amp; ms == 2 &amp;&amp; ys % 4 ==0))) // Þubat ayý Özel Durumu<br />
 {cout &lt;&lt; “Baslama Tarihini Gecersiz Girdiniz. Lutfen Tekrar Giriniz: GG AA YYYY” &lt;&lt; endl;<br />
 cin &gt;&gt; ds &gt;&gt; ms &gt;&gt; ys ;<br />
 }<br />
 cout &lt;&lt; “Bitis Tarihini Giriniz: GG AA YYYY” &lt;&lt; endl;<br />
 cin &gt;&gt; df &gt;&gt; mf &gt;&gt; yf;<br />
 while (!(( df &lt;= 31 &amp;&amp; mf == 1 )||( df &lt;= 28 &amp;&amp; mf == 2 )||( df &lt;= 31 &amp;&amp; mf == 3 )||( df &lt;= 30 &amp;&amp; mf == 4 )|| // Ay-Gun<br />
 ( df &lt;= 31 &amp;&amp; mf == 5 )||( df &lt;= 30 &amp;&amp; mf == 6 )||( df &lt;= 31 &amp;&amp; mf == 7 )||( df &lt;= 31 &amp;&amp; mf == 8 )|| // tutarlýlýðýný<br />
 ( df &lt;= 30 &amp;&amp; mf == 9 )||( df &lt;= 31 &amp;&amp; mf == 10 )||( df &lt;= 30 &amp;&amp; mf == 11 )||( df &lt;= 31 &amp;&amp; mf == 12 ) // sorgulama satýrlarý<br />
 ||(df &lt;= 29 &amp;&amp; mf == 2 &amp;&amp; yf % 4 ==0))) // Þubat ayý Özel Durumu </p>
<p> {<br />
 cout &lt;&lt; “Bitis Tarihini Gecersiz Girdiniz. Lutfen Tekrar Giriniz: GG AA YYYY” &lt;&lt; endl;<br />
 cin &gt;&gt; df &gt;&gt; mf &gt;&gt; yf ;<br />
 }<br />
 dsc = df, msc = mf, ysc = yf;<br />
 if (df – ds &lt; 0) { // Tarih Çýkarma Ýþlemi Baþlangýcý<br />
 df = df + 30;<br />
 mf = mf – 1;<br />
 dr = df -ds; }<br />
 else { dr = df – ds ; }<br />
 if (mf – ms &lt; 0) {<br />
 mf = mf + 12;<br />
 yf = yf – 1;<br />
 mr = mf – ms; }<br />
 else { mr = mf – ms; }<br />
 yr = yf – ys;<br />
 total_days = 365*yr + 30*mr + dr;<br />
 cout &lt;&lt; ds &lt;&lt;“.” &lt;&lt; ms &lt;&lt; “.” &lt;&lt; ys &lt;&lt; ” Tarihi Ile ” &lt;&lt; dsc &lt;&lt; “.” &lt;&lt; msc &lt;&lt; “.” &lt;&lt; ysc &lt;&lt; ” Tarihi Arasinda ” &lt;&lt; total_days &lt;&lt; ” Gun Vardir.” &lt;&lt; endl;<br />
 cout &lt;&lt; “( ” &lt;&lt; yr &lt;&lt; ” YIL ” &lt;&lt; mr &lt;&lt; ” AY ” &lt;&lt; dr &lt;&lt; ” GUN)” &lt;&lt; endl;<br />
 system(“PAUSE”);<br />
 switch_ans:<br />
 cout &lt;&lt; “Yeni Sorgulama Yapmak Icin N’ye, Cikmak Icin E’ye Basin.”;<br />
 cin &gt;&gt; ans;<br />
 switch (ans) {<br />
 case ‘N||n’ : goto new_date;<br />
 break;<br />
 case ‘E||e’ : return EXIT_SUCCESS;<br />
 break;<br />
 default : cout &lt;&lt; “Yanlis Tusa Bastiniz. Tekrar Deneyiniz.” &lt;&lt; endl;<br />
 goto switch_ans;<br />
 }<br />
 system(“PAUSE”);<br />
 return EXIT_SUCCESS;<br />
}<br />

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: