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

其实可以把每个字符串当成2个字符串输入然后用25减去它们的长度求出空格数。。。

Posted by et1239063237 at 2012-08-02 22:19:49 on Problem 1493
#include<iostream>
#include<string>

using namespace std;

int main()
{
	string str1,str2;

	int line;//每次计算的行数
	int min;//空格最少行所含空格数
	int space[100];//各行空格数
	int answer;//题目答案
	int i,j;//计数器

	while(cin>>line&&line!=0)
	{
		min=25;
		answer=0;

		for(i=0;i<line;i++)
		{
			cin>>str1;
			if(str1.length()<25)
			{
				cin>>str2;
			    space[i]=25-str1.length()
					       -str2.length();
			}
			else space[i]=25-str1.length();

			if(min>space[i])
				min=space[i];
		}

		for(j=0;j<line;j++)
			answer=answer+space[j]-min;

		cout<<answer<<endl;
	}

	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