Etiketler

, ,

#include <iostream>
#include <conio.h>
#include <queue>
#include <stack>
#include <Windows.h>
#define geciktir 1000

using namespace std;

int main()
{
system("color 0A");

int n,is_teslim,is_bitis,is_sure_toplam=0,
is_teslim_toplam,gec_kalan_isler=0,toplam_gec_kalma_suresi=0;
int is_sure_toplam_stack=0,is_teslim_toplam_stack,
gec_kalan_isler_stack=0,toplam_gec_kalma_suresi_stack=0;
queue<int>is_sure;
stack<int>is_sure_stack;
cout<<"Kac tane is girisi yapacaksiniz :";
cin>>n;
Sleep(2000);
system("cls");

for(int i=0;i<n;i++)
{
	cout<<i+1<<". isin teslim tarihini giriniz :";
	cin>>is_teslim;
	is_sure.push(is_teslim);
	is_sure_stack.push(is_teslim);

	cout<<i+1<<". isin bitmesi gereken tarihi giriniz :";
	cin>>is_bitis;
	is_sure.push(is_bitis);
	is_sure_stack.push(is_bitis);
	cout<<endl;
}

Sleep(geciktir);
system("cls");
cout<<"-----FIFO ICIN-----";
Sleep(2000);
system("cls");
for(int i=0;i<n;i++)
{
cout<<endl;
cout<<endl;
is_sure_toplam+=is_sure.front();
cout<<i+1<<". isin bitis suresi :";
cout<<is_sure.front()<<endl;
is_sure.pop();
is_teslim_toplam=is_sure.front();
cout<<i+1<<". isin teslim suresi :";
cout<<is_sure.front()<<endl;
is_sure.pop();

cout<<endl;

if(is_sure_toplam>is_teslim_toplam)
{
gec_kalan_isler++;
cout<<i+1<<". isimiz "<<is_sure_toplam-is_teslim_toplam
<<" gun gec kalmistir";
toplam_gec_kalma_suresi+=is_sure_toplam-is_teslim_toplam;
cout<<endl;
cout<<"-------------------------------"<<endl;
}
cout<<endl;
cout<<"********************************************";
cout<<endl;
}

cout<<endl;
cout<<"Method                   :  FIFO (queue)"
<<endl;
cout<<"Toplam is sayimiz        :"<<"  "<<n
<<endl;
cout<<"Gec kalan is sayimiz     :"<<"  "<<gec_kalan_isler
<<endl;
cout<<"Toplam gec kalma suresi  :"<<"  "
<<toplam_gec_kalma_suresi<<endl;
cout<<endl;

Sleep(7000);
system("cls");

cout<<"-----LIFO ICIN-----";
Sleep(2000);
system("cls");

for(int i=0;i<n;i++)
{
cout<<endl;
cout<<endl;

is_teslim_toplam_stack=is_sure_stack.top();
cout<<i+1<<". isin teslim suresi :";
cout<<is_sure_stack.top()<<endl;
is_sure_stack.pop();

is_sure_toplam_stack+=is_sure_stack.top();
cout<<i+1<<". isin bitis suresi :";
cout<<is_sure_stack.top()<<endl;
is_sure_stack.pop();

cout<<endl;

if(is_sure_toplam_stack>is_teslim_toplam_stack)
{
gec_kalan_isler_stack++;
cout<<i+1<<". isimiz "
<<is_sure_toplam_stack-is_teslim_toplam_stack
<<" gun gec kalmistir";
toplam_gec_kalma_suresi_stack+=is_sure_toplam_stack-
is_teslim_toplam_stack;
cout<<endl;
cout<<"-------------------------------"<<endl;
}
cout<<endl;
cout<<"********************************************";
cout<<endl;
}

cout<<endl;
cout<<"Method                   :  LIFO (stack)"<<endl;
cout<<"Toplam is sayimiz        :"<<"  "<<n<<endl;
cout<<"Gec kalan is sayimiz     :"<<"  "
<<gec_kalan_isler_stack<<endl;
cout<<"Toplam gec kalma suresi  :"<<"  "
<<toplam_gec_kalma_suresi_stack<<endl;
cout<<endl;

Sleep(7000);
system("cls");

if(toplam_gec_kalma_suresi>toplam_gec_kalma_suresi_stack)
{
cout<<"Fifo icin gec kalma suresi :   "
<<toplam_gec_kalma_suresi<<endl;
cout<<"Lifo icin gec kalma suresi :   "
<<toplam_gec_kalma_suresi_stack<<endl;
cout<<endl;
cout<<"*************************************"<<endl;
cout<<endl;
cout<<"Bu problem icin LIFO yapisi daha uygundur!"
<<endl;
cout<<endl;
}

else if(toplam_gec_kalma_suresi<toplam_gec_kalma_suresi_stack)
{
cout<<"Fifo icin gec kalma suresi :   "
<<toplam_gec_kalma_suresi<<endl;
cout<<"Lifo icin gec kalma suresi :   "
<<toplam_gec_kalma_suresi_stack<<endl;
cout<<endl;
cout<<"*************************************"<<endl;
cout<<endl;
cout<<"Bu problem icin FIFO yapisi daha uygundur!"<<endl;
cout<<endl;
}

else
{
cout<<"Fifo icin gec kalma suresi :   "
<<toplam_gec_kalma_suresi<<endl;
cout<<"Lifo icin gec kalma suresi :   "
<<toplam_gec_kalma_suresi_stack<<endl;
cout<<endl;
cout<<"*************************************"<<endl;
cout<<endl;
cout<<"Bu problem icin FIFO ve LIFO ayni sonucu vermektedir!"
<<endl;
cout<<endl;
}

system("pause");
return 0;
}
Reklamlar