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 1656. Far Away Kingdom's Army

W: compilation error!!!
Posted by Quyon 14 Nov 2008 13:51
My program

# include <iostream>
using namespace std;
void Paryad(int x,int y,int a[100]);
void Tart(int x,int y,int a[100],int b[100]);
int main ()
{
 int n=0;
 cin>>n;
 int a[100],b[100],d[100];
 for (int i=1;i<=n*n;i++)
  cin>>a[i];
 Paryad(1,n*n,a);
 Tart(1,n*n,a,b);
 int k=1,y=3;
 while(k<=n*n)
 {
  Paryad(k,y+k-1,b);
  Tart(k,y+k-1,b,d);
  k=k+3;
 }
 int t=0,c[100][100];
 for (i=1;i<=n;i++)
  for(int j=1;j<=n;j++)
  {
   t=t+1;
   c[j][i]=d[t];
  }

 for (i=1;i<=n;i++)
 {
  for(int j=1;j<=n;j++)
   cout<<c[i][j]<<' ';
  cout<<endl;
 }
return 0;
}
void Paryad(int x,int y,int a[100])
{
 int y1=0;
 for (int i=x;i<=y; i++)
 {
  for (int j=i+1; j<=y; j++)
  {
   if (a[i]>a[j])
   {
    y1=a[i];
    a[i]=a[j];
    a[j]=y1;
   }
  }
 }
}
void Tart(int x,int y,int a[100],int b[100])
{
 int j=x-1,u=1;
 for(int i=x;i<=y;i++)
 {
  if(u==1)
  {
   j=j+1;
   b[j]=a[i];
   u=0;
  }
  else
  {
   b[y-j+x]=a[i];
   u=1;
  }
 }
}
Re: W: compilation error!!!
Posted by zrp 14 Dec 2008 07:21
first,define your varible before "for"
      just like "for(i=0;i<n;i++)"
      and don't use "for(int i=0;i<n;i++)"
second,actually i don't know your"using namespace std"means,
      but it says it has some syntax error
and var"endl" is undefined
Re: W: compilation error!!!
Posted by Michail Yudin 11 Apr 2009 19:29
don'r post the stupid things
Re: W: compilation error!!!
Posted by Dima_Philippov 20 Nov 2010 01:24
you forgot to undeclarate identifier i in two for(...)

int 22 and 29 lines of your program (must be for (int i = 0; ...), but you wrote for(i = 0;...))

But, your program gets WA3 after this.

Edited by author 20.11.2010 01:24

Edited by author 20.11.2010 01:24