没明白你的意思,你的意思就是所有的组合概率都是你输入然后找最小值?
随便写了个,你参考下:
程序代码:
#include <stdio.h>
#include <stdlib.h>
void main()
{
int n, i = 0, j = 0, flag = 0;
int left, right, prob, *store, total;
printf("input a number: \n");
scanf("%d",&n);
total = n*(n-1)/2;
store = (int *)malloc(total*sizeof(int));
for (; i<n; i++)
{
for (j=i+1; j<n; j++)
{
printf("input %d and %d probability:\n",i+1,j+1);
scanf("%d",store+--total);
if (0 == flag)
{
prob = *(store+total);
left = i+1;
right = j+1;
flag = 1;
}
else
{
if (prob>*(store+total))
{
prob = *(store+total);
left = i+1;
right = j+1;
}
}
}
}
free(store);
printf("the minimum probability is %d\n",prob);
printf("the two number are %d and %d\n",left,right);
}