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

Compilation error
Posted by Yuri 9 Feb 2002 02:48
What's going on?!
I've now any errors and warnings.
I'm using only <iostream.h>.
Re: Compilation error
Posted by Yuri 9 Feb 2002 02:50
> What's going on?!
> I've now any errors and warnings.
> I'm using only <iostream.h>.
 #include <iostream.h>

int main(void)
{
    unsigned int n;
    cin>>n;
   char *a,*val;
   unsigned int na;

   a=new char[2000];
   val=new char[4];

   if(n==0)
   {
       cout<<'0';
      return 0;
   }

   a[0]='s';
   a[1]='i';
   a[2]='n';
   a[3]='(';
   a[4]='1';
   a[5]=')';
   a[6]=0;
   na=6;

   unsigned int j;

   for(unsigned int i=0;i<n-1;i++)
       cout<<'(';

   for(unsigned int i=2;i<=n;i++){
      cout<<a;
      cout<<'+';

      cout<<(n-i+2);
      cout<<')';

      //&#1080;&#1079;&#1084;&#1077;&#1085;&#1077;&#1085;&#1080;&#1077; &#1072;
       na=na-i+1; //&#1080;&#1075;&#1085;&#1086;&#1088;&#1080;&#1088;&#1091;&#1077;&#1084; &#1089;&#1082;&#1086;&#1073;&#1082;&#1080; &#1089;&#1087;&#1088;&#1072;&#1074;&#1072;
      if((i % 2)==0)
          a[na]=(char)'-';
      else
          a[na]='+';
      a[na+1]='s';
      a[na+2]='i';
      a[na+3]='n';
      a[na+4]='(';
      na+=5;
      if(i<10){
          val[0]=(char)('0'+i);
         val[1]=0;
      }
      else if(i<100)
      {
          val[0]=(char)('0'+i/10);
         val[1]=(char)('0'+i-i/10*10);
         val[2]=(char)0;
      }
      else
      {
          val[0]=(char)('0'+i/100);
         val[1]=(char)('0'+(i-i/100*100)/10);
         val[2]=(char)('0'+i-i/10*10);
         val[3]=(char)0;
      }
      j=0;
      while(val[j]!=0){
          a[na]=val[j];
         j++;
         na++;
      }
      for(j=0;j<i;j++)
          a[na+j]=')';
      na+=j;

      a[na]=0;
   }

   cout<<a;
   cout<<"+1";

    return 0;
}

>
Re: Compilation error
Posted by afo 19 Mar 2002 17:32
> > What's going on?!
> > I've now any errors and warnings.
> > I'm using only <iostream.h>.
>  #include <iostream.h>
>
> int main(void)
> {
>     unsigned int n;
>     cin>>n;
>    char *a,*val;
>    unsigned int na;
>
>    a=new char[2000];
>    val=new char[4];
>
>    if(n==0)
>    {
>        cout<<'0';
>       return 0;
>    }
>
>    a[0]='s';
>    a[1]='i';
>    a[2]='n';
>    a[3]='(';
>    a[4]='1';
>    a[5]=')';
>    a[6]=0;
>    na=6;
>
>    unsigned int j;
>
>    for(unsigned int i=0;i<n-1;i++)
                   //~~~~~~~~~~~~~~~
>        cout<<'(';
>
>    for(unsigned int i=2;i<=n;i++){
                      //~~~~~~~~~~~~~~~redefinition
>       cout<<a;
>       cout<<'+';
>
>       cout<<(n-i+2);
>       cout<<')';
>
>       //&#167;&#1066;&#167;&#1065;&#167;&#1070;&#167;&#1062;&#167;&#1071;&#167;&#1062;&#167;&#1071;&#167;&#1066;&#167;&#1062; &#167;&#1057;
>        na=na-i+1; //&#167;&#1066;&#167;&#1060;&#167;&#1071;&#167;&#1072;&#167;&#1074;&#167;&#1066;&#167;&#1074;&#167;&#1077;&#167;&#1062;&#167;&#1070; &#167;&#1075;&#167;&#1068;&#167;&#1072;&#167;&#1058;&#167;&#1068;&#167;&#1066; &#167;&#1075;&#167;&#1073;&#167;&#1074;&#167;&#1057;&#167;&#1059;&#167;&#1057;
>       if((i % 2)==0)
>           a[na]=(char)'-';
>       else
>           a[na]='+';
>       a[na+1]='s';
>       a[na+2]='i';
>       a[na+3]='n';
>       a[na+4]='(';
>       na+=5;
>       if(i<10){
>           val[0]=(char)('0'+i);
>          val[1]=0;
>       }
>       else if(i<100)
>       {
>           val[0]=(char)('0'+i/10);
>          val[1]=(char)('0'+i-i/10*10);
>          val[2]=(char)0;
>       }
>       else
>       {
>           val[0]=(char)('0'+i/100);
>          val[1]=(char)('0'+(i-i/100*100)/10);
>          val[2]=(char)('0'+i-i/10*10);
>          val[3]=(char)0;
>       }
>       j=0;
>       while(val[j]!=0){
>           a[na]=val[j];
>          j++;
>          na++;
>       }
>       for(j=0;j<i;j++)
>           a[na+j]=')';
>       na+=j;
>
>       a[na]=0;
>    }
>
>    cout<<a;
>    cout<<"+1";
>
>     return 0;
> }
>
> >
Re: Compilation error
Posted by Sylap 7 Oct 2012 01:29
THIS CODE WILL LEAD YOU TO AC (PAY ATTENTION TO CORRECTIONS):

#include <iostream> //not # include <iostream.h>

using namespace std; //to be able to use cin,cout and many other functions

int main(void)
{
    unsigned int n;
    cin>>n;
   char *a,*val;
   unsigned int na;

   a=new char[2000];
   val=new char[4];

   if(n==0)
   {
       cout<<'0';
      return 0;
   }

   a[0]='s';
   a[1]='i';
   a[2]='n';
   a[3]='(';
   a[4]='1';
   a[5]=')';
   a[6]=0;
   na=6;

   unsigned int j;

   for(unsigned int i=0;i<n-1;i++)
       cout<<'(';

   for(unsigned int i=2;i<=n;i++){
      cout<<a;
      cout<<'+';

      cout<<(n-i+2);
      cout<<')';

      //&#1080;&#1079;&#1084;&#1077;&#1085;&#1077;&#1085;&#1080;&#1077; &#1072;
       na=na-i+1; //&#1080;&#1075;&#1085;&#1086;&#1088;&#1080;&#1088;&#1091;&#1077;&#1084; &#1089;&#1082;&#1086;&#1073;&#1082;&#1080; &#1089;&#1087;&#1088;&#1072;&#1074;&#1072;
      if((i % 2)==0)
          a[na]=(char)'-';
      else
          a[na]='+';
      a[na+1]='s';
      a[na+2]='i';
      a[na+3]='n';
      a[na+4]='(';
      na+=5;
      if(i<10){
          val[0]=(char)('0'+i);
         val[1]=0;
      }
      else if(i<100)
      {
          val[0]=(char)('0'+i/10);
         val[1]=(char)('0'+i-i/10*10);
         val[2]=(char)0;
      }
      else
      {
          val[0]=(char)('0'+i/100);
         val[1]=(char)('0'+(i-i/100*100)/10);
         val[2]=(char)('0'+i-i/10*10);
         val[3]=(char)0;
      }
      j=0;
      while(val[j]!=0){
          a[na]=val[j];
         j++;
         na++;
      }
      for(j=0;j<i;j++)
          a[na+j]=')';
      na+=j;

      a[na]=0;
   }

   cout<<a;
   cout<<"+1";

    return 0;
}

Edited by author 07.10.2012 01:31

Edited by author 07.10.2012 01:31