#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
int main()
{
int m,n,**a,i,j,k,*c,p=0;
printf("\nEnter the number of variable and number of constraints:");
scanf("%d%d",&n,&m);
a=(int**)malloc(m+1*sizeof(int *));
for(i=0;i<n;i++)
a[i]=(int *)malloc((n+1)*sizeof(int));
c=(int*)malloc(m+1*sizeof(int));
for(i=0;i<m;i++)
c[i]=0;
for(i=0;i<m+1;i++)
{
if(i==0)
{
printf("\nEnter the variables of objective function\n");
}
else
printf("\nEnter the variables of constraints\n");
for(j=0;j<n+1;j++)
{
if(i==0&&(j==n))
{
continue;
}
if(j==n)
printf("\nEnter the RHS variables \n");
scanf("%d",&a[i][j]);
}
}
printf("\n Entered values \n");
for(i=0;i<m+1;i++)
{
if(i==1)
{
k=1;
for(j=0;j<n+1;j++)
{
if(j==0)
printf("\tCb\tBasic\tXb");
else if(j<=n-m)
printf("\tX%d",j);
else
{
printf("\tS%d",k);
k++;
}
}
printf("\n");
}
if(i!=0)
{
printf("\t%d\tS%d\t%d",c[p++],i,a[i][n]);
}
else
printf(" \t\t\tCj");
for(j=0;j<n;j++)
{
printf(" \t%d",a[i][j]);
}
printf("\n");
}
getch();
}
#include<stdlib.h>
#include<conio.h>
int main()
{
int m,n,**a,i,j,k,*c,p=0;
printf("\nEnter the number of variable and number of constraints:");
scanf("%d%d",&n,&m);
a=(int**)malloc(m+1*sizeof(int *));
for(i=0;i<n;i++)
a[i]=(int *)malloc((n+1)*sizeof(int));
c=(int*)malloc(m+1*sizeof(int));
for(i=0;i<m;i++)
c[i]=0;
for(i=0;i<m+1;i++)
{
if(i==0)
{
printf("\nEnter the variables of objective function\n");
}
else
printf("\nEnter the variables of constraints\n");
for(j=0;j<n+1;j++)
{
if(i==0&&(j==n))
{
continue;
}
if(j==n)
printf("\nEnter the RHS variables \n");
scanf("%d",&a[i][j]);
}
}
printf("\n Entered values \n");
for(i=0;i<m+1;i++)
{
if(i==1)
{
k=1;
for(j=0;j<n+1;j++)
{
if(j==0)
printf("\tCb\tBasic\tXb");
else if(j<=n-m)
printf("\tX%d",j);
else
{
printf("\tS%d",k);
k++;
}
}
printf("\n");
}
if(i!=0)
{
printf("\t%d\tS%d\t%d",c[p++],i,a[i][n]);
}
else
printf(" \t\t\tCj");
for(j=0;j<n;j++)
{
printf(" \t%d",a[i][j]);
}
printf("\n");
}
getch();
}