Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
其实可以把每个字符串当成2个字符串输入然后用25减去它们的长度求出空格数。。。#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator