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 1025. Democracy in Danger

Compilation Error ???
Posted by Andrei Nikolov 27 Oct 2001 16:27
I recieve Compilation Error when submitting this code: (It
compiles fine on my compiler)?????

#include <iostream.h>

int main() {
  int grupi[101] ;
  int k, num ;
  int sum=0 ;

  cin >> k ;
  for (int i=0; i<k; i++) {
     cin >> num ;
         if (num==0) grupi[i]=10000 ;
         else grupi[i]=num/2 + 1 ;
     }

  for (i=1; i<k; i++)
    for (int j=k-1; j>=i; j--)
      if (grupi[j-1] > grupi[j]) {
        int Temp=grupi[j-1];
        grupi[j-1] = grupi[j] ;
        grupi[j] = Temp ;
        }

  for (i=0; i<(k/2+1); i++) sum+=grupi[i] ;
  cout << sum ;
  return 0 ;
  }
Re: Compilation Error ???
Posted by Flyer 27 Oct 2001 16:43
> I recieve Compilation Error when submitting this code:
(It
> compiles fine on my compiler)?????
>
> #include <iostream.h>
>
> int main() {
>   int grupi[101] ;
>   int k, num ;
>   int sum=0 ;
>
>   cin >> k ;
>   for (int i=0; i<k; i++) {
>      cin >> num ;
>          if (num==0) grupi[i]=10000 ;
>          else grupi[i]=num/2 + 1 ;
>      }
>
>   for (i=1; i<k; i++)
>     for (int j=k-1; j>=i; j--)
>       if (grupi[j-1] > grupi[j]) {
>         int Temp=grupi[j-1];
>         grupi[j-1] = grupi[j] ;
>         grupi[j] = Temp ;
>         }
>
>   for (i=0; i<(k/2+1); i++) sum+=grupi[i] ;
>   cout << sum ;
>   return 0 ;
>   }
>
 &#1059; &#1090;&#1077;&#1073;&#1103; i &#1086;&#1073;&#1098;&#1103;&#1074;&#1083;&#1077;&#1085;&#1072; &#1074;&#1085;&#1091;&#1090;&#1088;&#1080; &#1094;&#1080;&#1082;&#1083;&#1072;, &#1080;&#1093; &#1082;&#1086;&#1084;&#1087;&#1080;&#1083;&#1103;&#1090;&#1086;&#1088; &#1101;&#1090;&#1086; &#1085;&#1077;
&#1087;&#1086;&#1085;&#1080;&#1084;&#1072;&#1077;&#1090;. &#1055;&#1088;&#1086;&#1089;&#1080; &#1086;&#1090;&#1089;&#1099;&#1083;&#1072;&#1090;&#1100; &#1086;&#1090;&#1074;&#1077;&#1090; &#1085;&#1072; E-MAIL, &#1090;&#1072;&#1084; &#1073;&#1086;&#1083;&#1077;&#1077;
&#1087;&#1086;&#1076;&#1088;&#1086;&#1073;&#1085;&#1072;&#1103; &#1080;&#1085;&#1092;&#1086;&#1088;&#1084;&#1072;&#1094;&#1080;&#1103;.
Re: Compilation Error ???
Posted by Andrei Nikolov 28 Oct 2001 00:50
Ok, which compilator the system uses?

> > I recieve Compilation Error when submitting this code:
> (It
> > compiles fine on my compiler)?????
> >
> > #include <iostream.h>
> >
> > int main() {
> >   int grupi[101] ;
> >   int k, num ;
> >   int sum=0 ;
> >
> >   cin >> k ;
> >   for (int i=0; i<k; i++) {
> >      cin >> num ;
> >          if (num==0) grupi[i]=10000 ;
> >          else grupi[i]=num/2 + 1 ;
> >      }
> >
> >   for (i=1; i<k; i++)
> >     for (int j=k-1; j>=i; j--)
> >       if (grupi[j-1] > grupi[j]) {
> >         int Temp=grupi[j-1];
> >         grupi[j-1] = grupi[j] ;
> >         grupi[j] = Temp ;
> >         }
> >
> >   for (i=0; i<(k/2+1); i++) sum+=grupi[i] ;
> >   cout << sum ;
> >   return 0 ;
> >   }
> >
>  &#1059; &#1090;&#1077;&#1073;&#1103; i &#1086;&#1073;&#1098;&#1103;&#1074;&#1083;&#1077;&#1085;&#1072; &#1074;&#1085;&#1091;&#1090;&#1088;&#1080; &#1094;&#1080;&#1082;&#1083;&#1072;, &#1080;&#1093; &#1082;&#1086;&#1084;&#1087;&#1080;&#1083;&#1103;&#1090;&#1086;&#1088; &#1101;&#1090;&#1086; &#1085;&#1077;
> &#1087;&#1086;&#1085;&#1080;&#1084;&#1072;&#1077;&#1090;. &#1055;&#1088;&#1086;&#1089;&#1080; &#1086;&#1090;&#1089;&#1099;&#1083;&#1072;&#1090;&#1100; &#1086;&#1090;&#1074;&#1077;&#1090; &#1085;&#1072; E-MAIL, &#1090;&#1072;&#1084; &#1073;&#1086;&#1083;&#1077;&#1077;
> &#1087;&#1086;&#1076;&#1088;&#1086;&#1073;&#1085;&#1072;&#1103; &#1080;&#1085;&#1092;&#1086;&#1088;&#1084;&#1072;&#1094;&#1080;&#1103;.
Re: Compilation Error ???
Posted by Stupnikov Pavel 4 Feb 2002 18:20
> Ok, which compilator the system uses?
> May be gcc (GNU C Compiler (Linux))
>
Re: Compilation Error ???
Posted by Blood Night Flamen 8 May 2004 12:07
oh shit mine's the same

#include <iostream.h>
#include <stdlib.h>
#define K 101

void main()
{
    int group_num,person_num[K],temp,m,minimal_quantity=0;
    cin>>group_num;
    for(int i=0;i<group_num;i++)
    {
        cin>>person_num[i];
        if(person_num[i]%2==0||person_num<1)
           exit(1);
        if(person_num[i]>10001)
           exit(1);
    }
    for(i=1;i<group_num;i++)
       for(int j=0;j<group_num-i;j++)
          if(person_num[j]>person_num[j+1])
          {
              temp=person_num[j+1];
              person_num[j+1]=person_num[j];
              person_num[j]=temp;
          }
    for(i=0;i<=group_num/2;i++)
    {
        if(person_num[i]==1)
           m=1;
        else
           m=person_num[i]/2+1;
        minimal_quantity+=m;
    }
    cout<<minimal_quantity<<endl;
}
Re: Compilation Error ???
Posted by David Payne 10 May 2004 08:15
I have the same type of Error.  I would post the source but under rules it says not to post source code.  It compiles fine on my system and I use gcc that comes with MinGW.  The most recent stable version so it should be up to date.
Re: Compilation Error ???
Posted by David Payne 10 May 2004 08:42
Humm, that is very interesting.  I got the error because I didn't add a newline character after the last line in my program.  And I can't declear and array after the first "executable statement in block".  Humm, I think they should update to a C99 standard compiler.
Re: Compilation Error ???
Posted by Vladimir Yakovlev (USU) 10 May 2004 14:53
Maybe instead of

if(person_num[i]%2==0||person_num<1)

you should write

if(person_num[i]%2==0||person_num[i]<1)
Re: Compilation Error ???
Posted by nikman 19 Aug 2004 19:57
for (int j=k-1; j>=i; j--) - error!!!
int j;
for (j=k-1; j>=i; j--) - right!!!
Re: Compilation Error ???
Posted by Yosif Yosifov 20 Aug 2004 05:27
The library u`re using ...

This is how it should be written :

#include <iostream>
using namespace std;

int main() {
int grupi[101] ;
int k, num ;
int sum=0 ;

cin >> k ;
for (int i=0; i<k; i++) {
cin >> num ;
if (num==0) grupi[i]=10000 ;
else grupi[i]=num/2 + 1 ;
}

for (int i=1; i<k; i++) // int i !
for (int j=k-1; j>=i; j--)
if (grupi[j-1] > grupi[j]) {
int Temp=grupi[j-1];
grupi[j-1] = grupi[j] ;
grupi[j] = Temp ;
}

for (int i=0; i<(k/2+1); i++) sum+=grupi[i] ; // int i !
cout << sum ;
return 0 ;
}