//*************************************************************************************
void SinglyLinkedList::printList()
{
    if(m_debug == true)
    {
        cout<<"In function isListEmpty"<<endl;
    }
    if(isListEmpty())
    {
        throw myException(m_error = "Empty list");
    }
    
    if(isCircleExist())
    {
        printCircle();
        return;
    }
    Node* temp = m_head;
    int index = 1;
    cout<<endl;
    while(temp != NULL)
    {
        cout<<"|";
        cout<< temp->data;
        cout<<"|";
        if(temp->link != NULL)
        {
            cout<<" --> ";
        }

        index++;
        temp = temp->link;
    }
    cout<<endl;
}
 vector<int> spiralOrder(vector<vector<int>>& matrix) {
   vector<int> ret;
   if(matrix.size()==0) return ret;
   int start=0;
   while(start*2<matrix.size() && start*2<matrix[0].size()){
     printCircle(matrix,ret,start);
     ++start;
   }
   return ret;
 }
void printClockwisely(int num[][4],int col,int row)
{
    int start=0;
    if(num==NULL || col<=0 || row<=0)
        return;
    while(col >start*2 && row >start*2) 
    {
        printCircle(num,col,row,start);
        start ++;
    }
    printf("\n");
}
Exemple #4
0
void printMatrix(int **arr,int m,int n)
{
	if(arr==NULL||m<=0||n<=0)
	{
		return;
	}
	int start=0;
	while(m>start*2&&n>start*2)
	{
		printCircle(arr,m,n,start);
		start++;
	}
}
Exemple #5
0
int main() {
//	freopen("in.txt", "r", stdin);
	int m, n;
	while (scanf("%d%d", &m, &n) != EOF) {
		int i, j;
		for (i = 0; i < m; i++)
			for (j = 0; j < n; j++)
				scanf("%d", &mat[i][j]);

		int start = 0;
		while (start * 2 < m && start * 2 < n) {
			printCircle(m, n, start);
			start++;
		}
		printf("\n");

	}
	return 0;
}