最近要期末考了,真的很忙
发这个文主要是来炫耀的
唯一一个全对的
代码如下:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int cmp(const void * a, const void * b)
{
return * ((int *) a) - * ((int *) b);
}
struct Ticket{
int l[6];
int n;
}ticket[1000000];
int t[10][10][10][10][10][10], count;
struct Ticket * p[1000000];
int main(void)
{
int N;
scanf("%d", &N);
for(int i = 0; i < N; i++)
{
int tmp[6];
for(int j = 0; j < 6; j++)
scanf("%d", &tmp[j]);
qsort(tmp, 6, sizeof(int), cmp);
t[tmp[0]][tmp[1]][tmp[2]][tmp[3]][tmp[4]][tmp[5]]++;
}
for(int x1 = 0; x1 < 10; x1++)
for(int x2 = x1; x2 < 10; x2++)
for(int x3 = x2; x3 < 10; x3++)
for(int x4 = x3; x4 < 10; x4++)
for(int x5 = x4; x5 < 10; x5++)
for(int x6 = x5; x6 < 10; x6++)
if(t[x1][x2][x3][x4][x5][x6])
{
ticket[count].l[0] = x1, ticket[count].l[1] = x2, ticket[count].l[2] = x3;
ticket[count].l[3] = x4, ticket[count].l[4] = x5, ticket[count].l[5] = x6;
ticket[count++].n = t[x1][x2][x3][x4][x5][x6];
}
for(int i = 0; i < count; i++)
p[i] = &ticket[i];
for(int i = 0; i < count - 1; i++)
for(int j = i + 1; j < count; j++)
{
if(p[i]->n < p[j]->n)
{
struct Ticket * tmp = p[i];
p[i] = p[j];
p[j] = tmp;
}
else if(p[i]->n == p[j]->n)
{
for(int k = 0; k < 6; k++)
{
if((p[i]->l)[k] > (p[j]->l)[k])
{
struct Ticket * tmp = p[i];
p[i] = p[j];
p[j] = tmp;
break;
}
else if((p[i]->l)[k] < (p[j]->l)[k])
break;
}
}
}
for(int i = 0; i < count; i++)
{
for(int j = 0; j < 6; j++)
printf("%d ", (p[i]->l)[j]);
printf("%d\n", p[i]->n);
}
return 0;
}