Symmetric Order

#include<stdio.h>
int main()
{
    int n,i,set=1;
    char str[16][26];
    while(scanf("%d",&n)&&n!=0)
    {
        for(i=1;i<=n;i++)
        {
            scanf("%s",&str[i]);
        }
        printf("SET %d\n",set);
        set++;
        if(n%2==0)
        {
            for(i=1;i<=n;)
            {
                printf("%s\n",str[i]);
                i=i+2;
            }
            for(i=n;i>0;)
            {
                printf("%s\n",str[i]);
                i=i-2;
            }
        }
        else
        {
            for(i=1;i<=n;)
            {
                printf("%s\n",str[i]);
                i=i+2;
            } 
            for(i=n-1;i>0;)
            {
                printf("%s\n",str[i]);
                i=i-2;
            }
        }
    }
    return 0;
}

 

上一篇:1040. Longest Symmetric String (25)


下一篇:[leetcode]101. Symmetric Tree