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

为什么会WA?

Posted by sunpy at 2008-08-05 23:15:56 on Problem 3094
#include<stdio.h>
#include<string.h>
#define N 256
char a[N];


int main()
{
	while(fgets(a,N,stdin)&&a[0]!='#')
	{
		int i,n,sum=0;
		n=strlen(a);
		//printf("%d ",n);
		for(i=0;i<n-1;i++)
			if(a[i]!=' ')
				sum+=(a[i]-'A'+1)*(i+1);
		printf("%d\n",sum);
	}
	return 0;
}

我把fgets换成gets就通过了
fgets为什么会不行呢?

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator