Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

请问wa在哪??????

Posted by sakula at 2010-05-28 11:56:46 on Problem 3752
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator