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

why i get wrong in test case 2?
Posted by Sakib Ahamed Khan 29 Feb 2020 17:26
#include <bits/stdc++.h>

int main()
{
    int n,i,j,k;

    scanf("%d",&n);

    for(i=1; i<=n; i++){
            if(i==1 && n!=1){
                printf("(");
            }
        for(j=1; j<=i; j++){
            if(i==1 && n==i){
                printf("(sin(1))+%d",n);
            }
            else if(i==1){
                printf("(sin(1)+%d)",n);
            }
            else {
                if(j%2==0){
                    printf("-sin(%d",j);
                }
                else if(j==1){
                    printf("sin(%d",j);
                }
                else {
                    printf("+sin(%d",j);
                }
                if(j==i){
                    //printf(")");
                    for(k=1; k<=i; k++){
                        printf(")");
                    }
                }
            }
        }
        //if(i==n){
          //  printf(")");
       // }
       if(i!=1 && i!=n){
        printf("+%d)",n+1-i);
       }
       else if(i!=1 && i==n){
        printf("+%d",n+1-i);
       }

    }
    return 0;
}