Sie sind auf Seite 1von 4

SUPERIOR UNIVERSITY LAHORE

Faculty of Computer Science & IT

DESIGN AND ANALYSIS OF ALGORITHMS

Student Detail

Student Name Roll # Program Email Address


Muaz Ahmed Butt BCSM-F17-054 BSCS – 5A BCSM-F17-054@superior.edu.pk
#include<iostream>
#include<stdio.h>
#include<conio.h>
using namespace std;
int l[2][100];
int nodes;
int e[2];
int x[2];
int a[2][100];
int t[2][100];
int f1[100], f2[100];
int fs,ls;

void PrintStation()
{
int i = ls;
cout<<"\n\n\t LINE "<<i<<", STATION "<<nodes<<"\n";
for(int j=nodes; j>=2; j--)
{
i = l[i][j];
cout<<"\t LINE "<<i<<", STATION "<<j-1<<"\n";
}

void FastestWay()
{
f1[1] = e[1] + a[1][1];
f2[1] = e[2] + a[2][1];

for(int j=2; j<=nodes; j++)


{
if( f1[j-1] + a[1][j] <= f2[j-1] + t[2][j-1] + a[1][j] )
{
f1[j] = f1[j-1] + a[1][j];
l[1][j] = 1;
}
else
{
f1[j] = f2[j-1] + t[2][j-1] + a[1][j];
l[1][j] = 2;
}
if( f2[j-1] + a[2][j] <= f1[j-1] + t[1][j-1] + a[2][j] )
{
f2[j] = f2[j-1] + a[2][j];
l[2][j] = 2;
}
else
{
f2[j] = f1[j-1] + t[1][j-1] + a[2][j];
l[2][j] = 1;
}
if( f1[nodes] + x[1] <= f2[nodes] + x[2] )
{
fs = f1[nodes] + x[1];
ls = 1;
}
else
{
fs = f2[nodes] + x[2];
ls = 2;
}
}
PrintStation();
}
int main()
{

cout<<"Enter No. of Stations Each Assembly Line: "; cin>>nodes;


for(int i=1; i<=2; i++){
cout<<"Enter ENTRY Time Line 1 : "; cin>>e[i];
}
for(int i=1; i<=2; i++){
cout<<"Enter ENTRY Time Line 2 : "; cin>>x[i];
}
cout<<"Enter Assembly Time for in Line 1 \n";
for(int i=1; i<=nodes; i++){
cin>>a[1][i];
}
cout<<"Enter Assembly Time for in Line 1 \n";
for(int i=1; i<=nodes; i++){
cin>>a[2][i];
}
cout<<"Enter Transfer Time for Line 1 \n";
for(int i=1; i<=nodes-1; i++){
cin>>t[1][i];
}
cout<<"Enter Transfer Time for Line 2 \n";
for(int i=1; i<=nodes-1; i++){
cin>>t[2][i];
}

FastestWay();
return 0;
}

Das könnte Ihnen auch gefallen