| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
哪儿错了啊,大家帮忙看一下啊!!!谢谢~~
#include <stdio.h>
#include <string.h>
int main()
{
int count[27][27], i, j, T, color[27], min_color_i_can, current_max, visit[27];
char rep[30];
while( scanf("%d", &T) && T )
{
getchar();
/*
* 初始化数组
*/
for ( i = 0; i < T; ++i )
{
for ( j = 0; j < T; ++j )
{
count[i][j] = 0;
}
}
/*
* 输入数据
*/
for ( i = 0; i < T; ++i )
{
gets( rep );
j = 2;
while( rep[j] )
{
count[rep[0]-'A'][rep[j++]-'A'] = 1;
}
}
/*
* 下面进行统计
*/
for ( i = 0; i < 27; ++i )
{
color[i] = 1;
}
for ( i = 1; i < T; ++i )
{
for ( j = 0; j < 27; ++j )
{
visit[j] = 0;
}
for ( j = 0; j < T; ++j )
{
if ( count[i][j] )
{
visit[color[j]] = 1;
}
}
for ( j = 1; j < 27; ++j )
{
if ( !visit[j] )
{
color[i] = j;
break;
}
}
}
current_max = color[0];
for ( i = 1; i < 27; ++i )
{
if ( current_max < color[i] )
{
current_max = color[i];
}
}
if ( current_max == 1 )
{
printf("1 channel needed.\n" );
}
else
{
printf("%d channels needed.\n", current_max );
}
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator