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

C++ (用cin.ignore解决疑难问题)

Posted by wcfairytale at 2007-02-28 14:04:32 on Problem 1298
#include<iostream>
#include<string>

using namespace std;

int main()
{
	while(true)
	{
		string start;
		cin>>start;
			if(start=="ENDOFINPUT")break;
		string text;
		cin.ignore(1024,'\n');//关键步骤
		getline(cin,text);
		int K;
		for(K=0;K<text.size();++K)
		{
			if('A'<=text[K] && text[K]<='Z')
            {
            	if(text[K]<'A'+5)text[K]+=21;
            	else text[K]-=5;
			}
		}
		string end;
		cin>>end;
		cout<<text<<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