490 - Rotating Sentences

All about problems in Volume IV. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Re: 490 - Rotating Sentences

Postby brianfry713 » Wed Jun 27, 2012 11:10 pm

Don't print an extra blank line at the end. The last line should be quotes, space, newline.
brianfry713
Guru
 
Posts: 1771
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 490 - Rotating Sentences

Postby shikhar.atri » Mon Mar 18, 2013 10:18 am

GETTING WRONG ANSWER.....SOMEBODY PLZ TELL ME WATS WRNG WID DA CODE

Code: Select all
  #include<iostream>
  #include<cstdio>
  #include<cmath>
  #include<cstdlib>
  #include<cstring>
  #include<algorithm>
  #include<vector>
  #include<stack>
  #include<deque>
  #include<queue>
  #include<utility>
  # define U unsigned long long int
  # define L long long int
  # define INF 2147483648
  using namespace std;
  int main()
  {
      string s[100];
      int size[100];
      //getchar();
      int i=0,k=0;
      while(getline(cin,s[i]))
      {
          size[i]=s[i].size();
          if(k<size[i])k=size[i];
          i++;               
      }
      int n=i;
      /*for(int i=0;i<n;i++)
      {
              cout<<s[i];       
      }*/
      int j=0;
      //cout<<k<<endl;
      while(1)
      {
              for(int i=n;i>=0;i--)
              {
                 if(j<s[i].size())
                 {
                     cout<<s[i].at(j);                               
                 }         
              }
              cout<<endl;
              j++;
              if(j==k)break;
             
      }
      //system("pause");
  }
shikhar.atri
New poster
 
Posts: 1
Joined: Wed Jan 09, 2013 3:25 pm

Re: 490 - Rotating Sentences

Postby brianfry713 » Mon Mar 18, 2013 10:20 pm

For the sample input, there should be a space at the end of the last two lines of the output.
brianfry713
Guru
 
Posts: 1771
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 490 - Rotating Sentences

Postby mfjuzar » Thu Mar 28, 2013 7:20 am

Im having the same problem, but its in pascal language, the output seems to match exactly as written in the problem, whats wrong?

Code: Select all
var
txt1,txt2: string;
i,l:integer;

begin
readln(txt1);
readln(txt2);

if length(txt1)> length(txt2) then
   l:=length(txt1)
   else
   l:=length(txt2);

for i:= 1 to l do begin
write(txt2[i]);
write(txt1[i]);
if i=l then else writeln;
end;

end.
mfjuzar
New poster
 
Posts: 3
Joined: Thu Mar 28, 2013 6:37 am

Re: 490 - Rotating Sentences

Postby brianfry713 » Thu Mar 28, 2013 9:26 pm

brianfry713 wrote:For the sample input, there should be a space at the end of the last two lines of the output.
brianfry713
Guru
 
Posts: 1771
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Previous

Return to Volume IV

Who is online

Users browsing this forum: No registered users and 1 guest