|  | 
|  | 
| вернуться в форум | W: compilation error!!! Послано Quyon  14 ноя 2008 13:51My 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!!! Послано zrp  14 дек 2008 07:21first,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!!! don'r post the stupid thingsRe: W: compilation error!!! 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
 | 
 | 
|