I
iamy
Unregistered / Unconfirmed
GUEST, unregistred user!
既然是这样,那我就再贴点
都是很早的时候写的
#include <stdio.h>
int a;
int hanglie[100][100];
int result=0;
main()
{
int t[100];
int c,i,j,m,l;
char cho;
printf(" iamy.2002.3.28/n/n"
printf("Input /"110/" for help ..."
start: printf("/nInput the num of the row (1~100) ..."
scanf("%d",&a);
if (a==110) {help();goto start;}
if (a>100) goto start;
for (i=1;i<=a;i++)
{printf("/nInput the row %d ...",i);
for (j=1;j<=a;j++)
{printf("/nInput the num %d,%d ...",i,j);
scanf("%d",&hanglie[j]);
}
printf("/n"
for (j=1;j<=a;j++)
printf("%d ",hanglie[j]);
printf("/n/nIs the row right? (y/n)"
for (;1
{cho=getchar();
if (cho=='y'||cho=='Y') break;
if (cho=='n'||cho=='N') {i--;break;}
}
}
printf("/nplease stand by ..."
for (i=1;i<=a;i++)
{t[1]=i;
m=1;
p(t,m);
}
printf("/n/n"
printf("The resule is ... "
printf(" %d",result);
printf("/n/nDo another one ? (y/n)"
for(;1
{cho=getchar();
if(cho=='y'||cho=='Y') goto start;
if(cho=='n'||cho=='N') goto end;
}
end: printf(" Thanks for using !"
}
p(int t[100],int m)
{int i,j,k,o;
if(m==a)
yunsuan(t);
for(i=1;i<=a;i++)
{o=0;
for(j=1;j<=m;j++)
{if(t[j]==i)
o++;
}
if(o>0);
else
{m++;
t[m]=i;
p(t,m);
t[m]=0;
m--;
}
}
}
yunsuan(int t[100])
{int i,j,k,x=0,ji=1;
j=1;
for(i=1;i<=a;i++)
{k=t[j];
ji=ji*hanglie[k];
j++;
}
for(i=1;i<=a;i++)
for(j=1;j<i;j++)
if(t<t[j]) x++;
if(x%2==0) x=1;
else x=-1;
ji=ji*x;
result=result+ji;
}
help()
{printf("/nThe program is used to workout a 'hang lie shi'such as.../n"
printf("1 2 3/n3 2 1/n2 1 3/n"
printf("First: input the num of the line&col/n"
printf("Second: input every num in the 'hang lie shi'/n"
printf("Third: do what the program tell you to do/n"
}
解行列试的
都是很早的时候写的
#include <stdio.h>
int a;
int hanglie[100][100];
int result=0;
main()
{
int t[100];
int c,i,j,m,l;
char cho;
printf(" iamy.2002.3.28/n/n"
printf("Input /"110/" for help ..."
start: printf("/nInput the num of the row (1~100) ..."
scanf("%d",&a);
if (a==110) {help();goto start;}
if (a>100) goto start;
for (i=1;i<=a;i++)
{printf("/nInput the row %d ...",i);
for (j=1;j<=a;j++)
{printf("/nInput the num %d,%d ...",i,j);
scanf("%d",&hanglie[j]);
}
printf("/n"
for (j=1;j<=a;j++)
printf("%d ",hanglie[j]);
printf("/n/nIs the row right? (y/n)"
for (;1
{cho=getchar();
if (cho=='y'||cho=='Y') break;
if (cho=='n'||cho=='N') {i--;break;}
}
}
printf("/nplease stand by ..."
for (i=1;i<=a;i++)
{t[1]=i;
m=1;
p(t,m);
}
printf("/n/n"
printf("The resule is ... "
printf(" %d",result);
printf("/n/nDo another one ? (y/n)"
for(;1
{cho=getchar();
if(cho=='y'||cho=='Y') goto start;
if(cho=='n'||cho=='N') goto end;
}
end: printf(" Thanks for using !"
}
p(int t[100],int m)
{int i,j,k,o;
if(m==a)
yunsuan(t);
for(i=1;i<=a;i++)
{o=0;
for(j=1;j<=m;j++)
{if(t[j]==i)
o++;
}
if(o>0);
else
{m++;
t[m]=i;
p(t,m);
t[m]=0;
m--;
}
}
}
yunsuan(int t[100])
{int i,j,k,x=0,ji=1;
j=1;
for(i=1;i<=a;i++)
{k=t[j];
ji=ji*hanglie[k];
j++;
}
for(i=1;i<=a;i++)
for(j=1;j<i;j++)
if(t<t[j]) x++;
if(x%2==0) x=1;
else x=-1;
ji=ji*x;
result=result+ji;
}
help()
{printf("/nThe program is used to workout a 'hang lie shi'such as.../n"
printf("1 2 3/n3 2 1/n2 1 3/n"
printf("First: input the num of the line&col/n"
printf("Second: input every num in the 'hang lie shi'/n"
printf("Third: do what the program tell you to do/n"
}
解行列试的