#include "stdio.h"
#define MaxRow 11
#define MaxCol 7
int main()
{
int i,j,c,q,k = 0;
int aa[MaxRow][MaxCol] = {{1,0,0,0,1,0},{1,1,1,0,0,0,},{0,0,0,0,1,1},{1,1,1,1,1,1},{0,0,1,1,1},{1,1,1,0,1,0},{1,0,0,0,1,1},{1,1,1,0,0,1},{0,0,0,0,1,1},{1,1,1,1,1,0}};
int p[MaxCol];
//Print the numbers of the array of aa
for(i = 0;i < MaxRow;i ++)
{
for(j = 0;j < MaxCol;j ++)
{
printf("%3d",aa[i][j]);
}
printf("/n");
}
//the sum of every row
for(i = 0;i < MaxRow-1;i ++)
{
for(j = 0;j < MaxCol-1;j ++)
{
aa[i][MaxCol-1] += aa[i][j];
}
}
printf("/n/n");
//print the numbefs of the array of aa
for(i = 0;i < MaxRow;i ++)
{
for(j = 0;j < MaxCol;j ++)
{
printf("%3d",aa[i][j]);
}
printf("/n");
}
//find the number of votes whose voters > 3 and put in the array of p
for(i = 0;i < MaxRow-1;i ++)
{
if(aa[i][MaxCol-1] > 3)
{
p[k++] = i;
}
}
//put the votes of the every element who the voters >3 to 0
//why ?,please consider carefully
for(i = 0;i < MaxRow;i ++)
{
for(j = 0;j < MaxCol;j ++)
{
for(q = 0;q < k;q ++)
{
if(i == p[q])
{
aa[i][j] = 0;
}
}
}
}
//the sum of every col
for(i = 0;i < MaxRow-1;i ++)
{
for(j = 0;j< MaxCol-1;j ++)
{
aa[MaxRow-1][j] += aa[i][j];
}
}
printf("/n/n");
//print the whole of the array of aa
for(i = 0;i < MaxRow;i ++)
{
for(j = 0;j < MaxCol;j ++)
{
printf("%3d",aa[i][j]);
}
printf("/n");
}
//choice who win
int max = aa[MaxRow-1][0];
for(i = 1;i < MaxCol - 1;i ++)
{
if(max < aa[MaxRow-1][i])
{
max = aa[MaxRow-1][i];
c = i;
}
}
printf("/n第 %d 位候选人获胜,他获得的票数为:%d/n/n",c+1,max);
return 0;
}