Loser_'s blog

By Loser_, history, 4 years ago, In English

Hello I have been trying to solve this problem using basic star pattern logic. My approach is — first create the upper half of the pyramid and then add the next portion of the pyramid.For that I first initialize all the elements of the 2d array in null value**('\0')**.And my compiler shows the exact same result as in the description.But somehow codeforces compiler showing weird symbols for ('\0') .I have also tried char(0) which also give me weird symbols.My submissions here and here.How can I get ac from this submission?

  • Vote: I like it
  • -4
  • Vote: I do not like it

| Write comment?
»
4 years ago, # |
  Vote: I like it 0 Vote: I do not like it

When you initialize a char array always set all values to a known character which is not used in the problem (Like '#' or '@' etc.), and if this value is still the same is the initialized value then your implementation didn't change it so you do as required in the problem statement (here, set it to ' ') This will guarantee not to do such behavior.

Anyway, this is happening because you said I want this value to be char(0), the compiler on your PC didn't recognized it so it printed nothing.. that doesn't mean it is really a space and you don't have to get yourself into such troubles so i recommend you do as I said above.

  • »
    »
    4 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Actually,that was one of my wrong submissions.Yes here there is no weird characters but using ' ' I just created empty space which violates the problem statement.Here is the submission

    • »
      »
      »
      4 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      You need to remove the trailing spaces. You can add a '\0' right after where a char array ends (after the last 0 in each line)

    • »
      »
      »
      4 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Yes Here you did as I said but still got wrong answer because you printed extra spaces after the last character in each line. " 0 " is not " 0"