home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_11_02
/
1102108a
< prev
next >
Wrap
Text File
|
1992-12-04
|
1KB
|
68 lines
void build_basis(void)
{
int i,j;
strcpy (objective[0], "z");
i = 1;
/* create the labels for the orig tableau */
for (j=1; j<VARIABLES+1; j++) {
strcpy (var, "X");
itoa(i, num);
strcat (var,num);
strcpy (objective[j], var);
i++;
}
i = 1;
for (j=VARIABLES+1; j<EQUATIONS+VARIABLES+1;
j++) {
strcpy (var, "s");
itoa(i, num);
strcat (var,num);
strcpy (objective[j], var);
i++;
}
strcpy (objective[j], "sol");
strcpy (var, "z");
strcpy (basis[0], var);
for (i=1;i<=EQUATIONS;i++) {
strcpy (var, "s");
itoa(i, num);
strcat (var,num);
strcpy (basis[i], var);
}
}
void print_table(void)
{
int i,j;
printf ("\n");
printf ("%6s", " basis |");
for (j=0; j<=COLUMNS; j++) {
if ( (j==1) || (j==COLUMNS-1) )
printf (" |");
printf (" %6s", objective[j]);
}
printf ("\n");
for (j=0; j<COLUMNS+2; j++) {
printf ("-------");
}
printf ("\n");
for (i=0; i<ROWS;i++) {
printf (" %6s", basis[i]);
for (j=0; j<COLUMNS; j++) {
if ( (j==0) || (j==1) ||
(j==COLUMNS-1) )
printf (" |");
printf (" %6.2f",table[i][j]);
}
if (i==0) {
printf ("\n");
for (j=0; j<COLUMNS+2; j++) {
printf ("-------");
}
}
printf ("\n");
}
printf ("\n");
}