C PROGRAM FOR SALESPERSON PROBLEM
The travelling salesman problem (TSP) is an NP-hard problem in combinatorial optimization studied in operations research and theoretical computer science. Given a list of cities and their pairwise distances, the task is to find the shortest
possible route that visits each city exactly once and returns to the origin city. It is a special case of the travelling purchaser problem. The problem was first
formulated as a mathematical problem in 1930 and is one of the most intensively studied problems in optimization. It is used as a benchmark for many optimization methods. Even though the problem is computationally difficult, a large number of heuristics and exact methods are known, so that some instances with tens of thousands of cities can be solved.
CODE:
#include<stdio.h>
#include<conio.h>
void main()
{
int ss[50][50]={0};
int x,y,sale,i,a,b,t=0;
clrscr();
printf("\nEnter the How many sales man:");
scanf("%d",&sale);
printf("\nEnter the How many Items:");
scanf("%d",&i);
for(a=0;a<sale;a++)
{
for(b=0;b<i;b++)
{
printf("Sales man [%d] item [%d]:",a+1,b+1);
scanf("%d",&ss[a][b]);
}
}
clrscr();
printf("\n**********************************************************");
printf("\n*********************SALES REPORT*************************");
printf("\n**********************************************************\n");
printf("\n\t\t");
for(b=0;b<i;b++)
{
printf("item[%d] ",b+1);
}
printf(" Total");
for(a=0;a<sale;a++)
{
printf("\nSales man [%d]",a+1);
for(b=0;b<i;b++)
{
printf(" %d\t",ss[a][b]);
t+=ss[a][b];
}
printf(" %d",t);
t=0;
}
printf("\n********************************************************\n");
printf("TOTAL :");
printf("\t\t");
x=0,y=0;
for(a=0;a<i;a++)
{
for(b=0;b<sale;b++)
{
x=x+ss[b][a];
}
y=y+x;
printf(" %d\t",x);
x=0;
}
printf(" %d\t",y);
printf("\n********************************************************");
getch();
}

0 comments:
Post a Comment