Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register

为什么我的代码用G++交可以过用c++交不能过?

Posted by tq at 2005-07-10 19:41:47 on Problem 2471
```/*
author: TangQiao , Wind @ Beijing Normal University

problem name: Bullshit Bingo

source :  PKU Online Judge

problem type: 字符串处理题

problem description: 以BULLSHIT为界,找出每组中不重复的字符串的个数,最后输出
各组和 / 组数.要求约分.

problem solution: 模拟找就行了.

faults: 当前此题的代码只能在G++的编译器下提交通过.具体原因不明.

date : 2005.7.10 北大个人赛

*/

#include <stdio.h>
#include <string.h>

char ss[910][50];
int match[50000000];
int n_match=0;

void output(int a,int b)
{
int i;
int min;
min=a>b?b:a;

if (min==0)
printf("%d / %d\n",a,b);
else
{
for (i=min;i>=2;i--)
if (a%i==0 && b%i==0)
{
a/=i;
b/=i;
i++;
}
printf("%d / %d\n",a,b);
}
}

main()
{
int i,j;
char in[30], ch;
int num;
int over;
char bb[30];

//	freopen("bingo.in", "r", stdin);

num=0;
over=0;
//strcpy(in,kong);
memset(in,0,sizeof(in));
memset(bb,0,sizeof(bb));
strcpy(bb,"BULLSHIT");
while (scanf("%c", &ch)!=EOF)

{
//		if (ch>='a' && ch<='z')
//			ch+='A'-'a';
if ((ch>='A' && ch<='Z' ) || (ch>='a' && ch<='z'))
{
}
else
{
{
num++;
strcpy(ss[num],in);
if (strcmp(in,bb)==0) over=1;

//		strcpy(in,kong);
memset(in,0,sizeof(in));
}
}

if (over)
{
num--;
over=0;
n_match++;
match[n_match]=num;

for (i=1;i<=num;i++)
{
int len;
len=strlen(ss[i]);
for (j=0; j < len; j++)
if (ss[i][j]>='a' && ss[i][j]<='z')
ss[i][j]+=('A'-'a');
}
for (i=1;i<num;i++)
{
for (j=i+1;j<=num;j++)
if (strcmp(ss[i],ss[j])==0)
{
match[n_match]--;
break;
}
}
num=0;
}
} // end of while

{
num++;
strcpy(ss[num],in);
if (strcmp(in,bb)==0) over=1;

//	strcpy(in,kong);
memset(in,0,sizeof(in));
}
if (over)
{
num--;
over=0;
n_match++;
match[n_match]=num;
for (i=1;i<num;i++)
{
for (j=i+1;j<=num;j++)
if (strcmp(ss[i],ss[j])==0)
{
match[n_match]--;
break;
}
}
num=0;
}

for (i=1,j=0;i<=n_match;i++)
{
j+=match[i];
//		printf("num:%d tot=%d\n", i, match[i]);
}
output(j,n_match);

return 0;
}
```

Followed by: