Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
请问wa在哪??????#include <iostream> using namespace std; void Set(int p ,int q,int m ,int n,int k,int **a) { int dk = (k + 2*(m-p + n-q)); if ( (m == 0) || (n == 0)) { return; } for ( int j = q ; j <= n; j++) { if(a[p][j] == 0 ) a[p][j] = k++; } for ( int i = p+1 ; i < m ;i++ ) { if(a[i][n] == 0 ) a[i][n] = k++ ; } for ( int j = n ; j >= q; j-- ) { if(a[m][j] == 0 ) a[m][j] = k++; } for ( int i = m-1 ;i > p ;i-- ) { if(a[i][q] == 0 ) a[i][q] = k++; } Set(p+1,q+1,m-1,n-1,dk,a); } int main() { int M,N; cin>>M>>N; int** a = new int*[M]; for (int k =0 ; k < M;k++) { a[k] = new int[N]; } for (int i = 0 ;i < M; i++) { for (int j = 0;j < N;j++) { a[i][j] = 0; } } Set(0,0,M-1,N-1,0,a); for ( int i = 0 ;i < M; i++) { cout<<endl; for (int j = 0;j < N;j++) { char c = (char)(a[i][j]%26 + 65); cout<<" "<<c; } } delete *a; return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator