Why Do I get A Presentation Error PLZ HELP ASAP

Let's talk about algorithms!

Moderator: Board moderators

Post Reply
Axiom2277
New poster
Posts: 3
Joined: Mon May 04, 2015 9:02 am

Why Do I get A Presentation Error PLZ HELP ASAP

Post by Axiom2277 » Tue May 05, 2015 8:33 pm

#include <iostream>

using namespace std;

int main()
{
int casess,Lines,x=1; cin >> casess; cin.ignore();
string str;
bool flag3=0;

while(casess--)
{
cin >> Lines; cin.ignore();
string s1[Lines];
str.clear();
int a=0;
if(flag3) cout << endl; flag3=1;
cout << "Case " << x++ << ":" << endl;
while(Lines--)
{
bool flag=0,flag2=0;
getline(cin ,str);
if(str[str.size()-1]!=' ')
{ str.insert(str.size()," "); flag2=1; }
if(str.at(0)!=' ')
{ str.insert(0," "); flag=1; }
for(int j=0;j<str.size()-1;j++)
{
if(j<str.size()-1 && j>0 && str.at(j)==' ' && (str.at(j+1)==' ' || str.at(j-1)==' '))
{
str.erase(j,1); j=0;
}
}
if(flag2==1)
str.erase(str.size()-1,1);
if(flag==1)
str.erase(0,1);

cout << str << endl;
}
}
}

predicate
New poster
Posts: 18
Joined: Tue Jun 17, 2014 9:32 pm
Location: Hyderabad, India

Re: Why Do I get A Presentation Error PLZ HELP ASAP

Post by predicate » Tue May 26, 2015 6:02 am

You should at least tell the problem name and id before putting up your code.

Post Reply

Return to “Algorithms”