« first day (9 days earlier)    last day (27 days later) » 

05:05
@JohnRennie hi
@Tanuj hi :-)
i was solving a problem on codeforces
and i dont know why I'm getting the error that I'm getting
this is the question
and this is my attempt to solve it
and the error I get is : Runtime error: exit code is -1073741819
@JohnRennie oof nevermind
I figured it out
arrays are indexed from 0 and not 1
so my matrix mat[i][j]
should be mat[6][6] and not mat[5][5]
OK :-)
05:44
@JohnRennie hi
could you take a look at a question for me
i wanna know what I'm doing wrong
I need to work now for a bit. If you post the details I'll have a look when I'm free
alright
@JohnRennie
this is the question I'm talking about
and this is my attempt
 
3 hours later…
08:49
@Tanuj It's a typo. The line:
   for(int j=i+2;i<s.size();j+=2)
should be:
   for(int j=i+2;j<s.size();j+=2)
Although your code still isn't working in all cases e.g.
int main()
{
  string s = "6+5+4+3+2+1";
  char temp;
  for(int i=0; i<((s.size()+1)/2); i+=2)
  {
    for(int j=i+2; j<s.size(); j+=2)
    {
      if(s[i]>s[j])
      {
        temp=s[j];
        s[j]=s[i];
        s[i]=temp;
      }
    }
  }
  cout<<s;

  return 0;
}
prints:
1+2+3+6+5+4

« first day (9 days earlier)    last day (27 days later) »