예제 #1
0
void spiralOrder(s* r,int h)
{
    int level=1;
    if(r==NULL)
    {
        return;
    }
    else
    {
        printf("%c -> ",r->data);
        while(level < h)
        {
            if(level%2!=0)
            {
                spiralPrint(r->left,level,0);
                spiralPrint(r->right,level,0);
            }
            else
            {
                spiralPrint(r->right,level,1);
                spiralPrint(r->left,level,1);
            }
            level++;
        }
        printf("end");
    }
예제 #2
0
void spiralPrint(s* r,int level,int n)
{
    if(r==NULL)
    {
        return;
    }
    else if(level==1)
        {
            printf("%c -> ",r->data);
            return;
        }
    else
        {
            level--;
                if(n==1)
                {
                    spiralPrint(r->right,level,n);
                    spiralPrint(r->left,level,n);
                }
                else
                {
                     spiralPrint(r->left,level,n);
                     spiralPrint(r->right,level,n);
                }
        }
예제 #3
0
int main()
{

	int i;
	//,j,n,x;
	//int R;
	char string1[50]; ///< It takes a string with wildcard character as input
	char string2[50]; ///< It takes a string to compared as input

	//printf("Enter order of the array:");
	//scanf("%d", &n);
	/*if(n%2==0)
		printf("The order of the array should be odd");*/

	//R=n;
	//C=n;
	//int a[R][C];

	//for(i=0;i<n;i++)
		//for(j=0;j<n;j++)
			//scanf("%d",a[i][j]);

	/*printf("The scanned array is: \n");
	for(i=0;i<n;i++)
			for(j=0;j<n;j++)
				printf("%d ",ar[i][j]);*/


	int a[R][C] = { {1,  2,  3,  4,  5},
        {7,  8,  9,  10, 11},
        {13, 14, 15, 16, 17},
	{18,19,20,21,22},
	{23,24,25,26,27}
    }; ///< This is the sample array for printing elements in revesre spiral order.

    /// This function is used to print the array elements.
	spiralPrint(R, C, a);

    for(i=24;i>=0;i--)
    	printf("%d ",ar[i]);

    printf("\n Enter a string with wildcard character: \n ");
    gets(string1);
    printf("\n Enter the string which needs to be compared: \n ");
    gets(string2);

    test(string1,string2);

	/*test("g*ks", "geeks"); // Yes
    test("ge?ks*", "geeksforgeeks"); // Yes
    test("g*k", "gee");  // No because 'k' is not in second
    test("*pqrs", "pqrst"); // No because 't' is not in first
    test("abc*bcd", "abcdhghgbcd"); // Yes
    test("abc*c?d", "abcd"); // No because second must have 2
                             // instances of 'c'
    test("*c*d", "abcd"); // Yes
    test("*?c*d", "abcd"); // Yes*/
    return 0;
}
예제 #4
0
파일: spiral.c 프로젝트: sspark1973/C-Prog
int main()
{
	int a[R][C] = { {1, 2, 3, 4, 5, 6},
					{7, 8, 9, 10, 11, 12},
					{13, 14, 15, 16, 17, 18}};

	spiralPrint(R, C, a);
	return 0;
}
예제 #5
0
int main()
{
    int a[3][6] = { {1,  2,  3,  4,  5,  6},
        {7,  8,  9,  10, 11, 12},
        {13, 14, 15, 16, 17, 18}
    };
 
    spiralPrint(3, 6, a);
    return 0;
}