pages:
  • 1
Rooholah Abolhasani SAYS

I wrote the code and it doesn't have "\n" at the end of the output. But it seems my code still has presentation error. any help?

WhiteRose SAYS

Rooholah Abolhasani said:

I wrote the code and it doesn't have "\n" at the end of the output. But it seems my code still has presentation error. any help?

you just should print new line between the outputs, not after each other!

Rooholah Abolhasani SAYS

solved! There was a "\n" after last line of output.

sadrodin1376 SAYS

hello how is the type of input? the judge runs the code rapidly and gives it input or runs it once and give it a text file containing input? and how can i know when the last input comes,to not to print \n ,last of it?

WhiteRose SAYS

sadrodin1376 said:

hello how is the type of input? the judge runs the code rapidly and gives it input or runs it once and give it a text file containing input? and how can i know when the last input comes,to not to print \n ,last of it?

you can use this trick: (in java)

top of your code:

int n = in.nextInt();
  int c = 0;
  while (n != 0) {
     c++;

. . . . . .

end of your code:

    if (c > 1) {
        System.out.println();
     }
        System.out.println(result);
     n = in.nextInt();
  }
sadrodin1376 SAYS

please hint me in c++ !

WhiteRose SAYS

sadrodin1376 said:

please hint me in c++ !

approximately those are same!

top of your code:

  int n;

  cin>>n;

  int c = 0;

  while (n != 0) {

 c++;

. . . . . .

end of your code:

if (c > 1) {
    cout>>"\n";
 }
    cout>>result;
 cin>>n;

}

i think!!!