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 194 at 2006-08-19 09:48:12 on Problem 2895
#include <iostream>
using namespace std;
#include <stdio.h>
typedef struct
{
	char word;
	int  times;
}LetterNode;

int main()
{
	LetterNode letter[91];
	char a[1000];
	int time,t,p,w,i;
    letter[' '].word='1';
	letter[' '].times=1;
	letter['A'].word='2';
	letter['A'].times=1;
	letter['B'].word='2';
	letter['B'].times=2;
	letter['C'].word='2';
	letter['C'].times=3;
	letter['D'].word='3';
	letter['D'].times=1;
	letter['E'].word='3';
	letter['E'].times=2;
	letter['F'].word='3';
	letter['F'].times=3;
	letter['G'].word='4';
	letter['G'].times=1;
	letter['H'].word='4';
	letter['H'].times=2;
	letter['I'].word='4';
	letter['I'].times=3;
	letter['J'].word='5';
	letter['J'].times=1;
	letter['K'].word='5';
	letter['K'].times=2;
	letter['L'].word='5';
	letter['L'].times=3;
	letter['M'].word='6';
	letter['M'].times=1;
	letter['N'].word='6';
	letter['N'].times=2;
	letter['O'].word='6';
	letter['O'].times=3;
	letter['P'].word='7';
	letter['P'].times=1;
	letter['Q'].word='7';
	letter['Q'].times=2;
	letter['R'].word='7';
	letter['R'].times=3;
	letter['S'].word='7';
	letter['S'].times=4;
	letter['T'].word='8';
	letter['T'].times=1;
	letter['U'].word='8';
	letter['U'].times=2;
	letter['V'].word='8';
	letter['V'].times=3;
	letter['W'].word='9';
	letter['W'].times=1;
	letter['X'].word='9';
	letter['X'].times=2;
	letter['Y'].word='9';
	letter['Y'].times=3;
	letter['Z'].word='9';
	letter['Z'].times=4;
	cin>>t;
	while(t--)
	{
		cin>>p>>w;
		flushall();
		gets(a);
		time=0;
		time=time+letter[a[0]].times*p;
		for(i=1;i<strlen(a);i++)
		{
			if(letter[a[i]].word==letter[a[i-1]].word&&letter[a[i]].word!='1')
			{
				time=time+letter[a[i]].times*p+w;
			}
			else
			{
				time=time+letter[a[i]].times*p;
			}
		}
		cout<<time<<endl;

	}
	return 1;
}

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