ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1149. Sinus Dances

Who can help,Why I am always wrong
Posted by kkk 12 Apr 2002 10:40
#include<stdio.h>
void A(int i)
{ int n;

   for(n=1;n<i;n++)
   printf("sin(%d+",n);
   printf("sin(%d",i);
 for(n=1;n<=i;n++)
   printf(")");
 }
void S(int i)
{ int n;
  for(n=1;n<i;n++)
   printf("(");
  for(n=1;n<i;n++)
  { A(n);
    printf("+%d)",i-n+1);
    }
  A(i);
  printf("+1");
  }
main()
 { int n;
   scanf("%d",&n);
   S(n);
   }
You have made a very little mistake....
Posted by Vladimir Milenov Vasilev 13 Apr 2002 04:56
>Hei, it is OK your pogram, just have a look at the sample output -
you have to change the sign "+" and "-" - your program outputs just
sign "+" - you have to change the sign each time - that is it.
I think, you will get accepted - TRY IT!!!!!
Re: You have made a very little mistake....
Posted by kkk 13 Apr 2002 14:19
Thank you for your information.But I still misunderstand your meaning
Please explain more details
                    Thanks Again!!!
Hei, have a look at the semple output...
Posted by Vladimir Milenov Vasilev 13 Apr 2002 15:35
As I saw our program, you for n=3 your putput is:
((sin(1)+3)sin(1+sin(2))+2)sin(1+sin(2+sin(3)))+1
But have a look at the sample putput - it is:
((sin(1)+3)sin(1-sin(2))+2)sin(1-sin(2+sin(3)))+1
The signs "+" and "-" !!!
Your program outputs just "+"!!!!!!
TEst your program and the sample outout - you'l see!
If you haven't anderstood me,write me again...
Bye!
Re: Who can help,Why I am always wrong
Posted by Frankie 26 Nov 2011 09:41
> I am always wrong
Sounds like a logical fallacy, lol :D "i'm lying"
Re: Who can help,Why I am always wrong
Posted by Anatoly 30 Jan 2012 23:06
Just change 5th line from
printf("sin(%d+",n);
to
printf("sin(%d%c", n, n & 1 ? '-' : '+');