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

为什么会Output Limit Exceededk,改了好几次还是这样。求各位帮忙看一下。(附代码)

Posted by Fredxiang at 2012-12-01 13:59:30 on Problem 3094
#include "stdio.h"
#include "string.h"
#include "ctype.h"

char s[1000];

int main(){

	int i,k=1,n,x=0;
	long sum=0;
	fgets(s,1000,stdin);
	
	while(s[0]!='#' || s[1]!='\0'){
		sum=0;
		k=1;
		n=strlen(s);
		for(i=0;i<n;i++){
			if(isalpha(s[i]))
				sum=sum+k*((int)(s[i]-'A')+1);
			k++;
		}

		printf("%ld\n",sum);
		fgets(s,1000,stdin);

	}
	return 0;
}



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