Search This Blog

Monday 4 April 2016

Distance Vector Processing

Explained Logic here! You can set it with input from user and here is the problem
we have to set new routing table for j !




#include<stdio.h>

int main()
{
int A[12]={0,12,25,40,14,23,18,17,21,9,24,29};
int B[12]={24,36,18,27,7,20,31,20,0,11,22,33};
int C[12]={20,31,19,8,30,19,6,0,14,7,22,9};
int D[12]={21,28,36,24,22,40,31,19,22,10,0,9};

char str[12];
//void sum(,;
int q,t[4],z,s,zz=0;
int j[13];
int a=8,i=10,h=12,k=6;
int min;
for(z=0;z<12;z++)
{
j[9]=0;
t[0]=A[z]+a;
t[1]=B[z]+i;
t[2]=C[z]+h;
t[3]=D[z]+k;
min=t[0];
for(q=0;q<4;q++)
{
if(t[q]<min){
min=t[q];
s=q;
}
}
if(s==0)
{
str[zz]='A';
zz++;
}else if(s==1)
{
str[zz]='I';
zz++;
}else if(s==2)
{
str[zz]='H';
zz++;
}else if(s==3)
{
str[z]='K';
zz++;
}
str[9]='-';
j[z]=min;
}
for(q=0;q<12;q++)
{
printf("%d  %c\n",j[q],str[q]);
}
return 0;
}

No comments:

Post a Comment