C和C++的数据类型所占的空间

/*

* 解题思路:

* 该题目不难,看着吓人,主要就是分别按元音和辅音存储,每个元音不超过21个,每个辅音不超过5个,在长度限定范围内,

*       使得所得到的字符串对应数值最小,分别存储完元音和辅音数组后,对二者进行排序,最后按奇数位元音、偶数位辅音,且以字母序输出!

*/

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
char s1[ 30 ] = "12345678912345678912345678";
char con[ 10 ][ 5 ] = {"JS0","BKT0","CL0","DMV0","NW0","FX0","GPY0","HQZ0","R0"};
char vow[ 5 ][ 2 ] = {"A","U","E","O","I"};
char c[ 250 ] , v[ 250 ];
int t1,t2;
int cmp( const void *a , const void *b )
{ return *(char *)a - *(char *)b; }
int main( )
{
    int t,n;
    int i,j;
    int sum1,sum2;
    int p1,p2,q2;

    scanf("%d",&t);
    for( j=1;j<=t;j++ )
    {
        scanf("%d",&n);
        printf("Case %d: ",j);

        sum1 = sum2 = 0;
        p1 = p2 = q2 = 0;
        t1 = t2 = 0;
        for( i=1;i<=n;i++ )
            if( i & 1 )
            {
                if( sum1 >= 21 )
                {
                    p1++;
                    sum1 = 0;
                }
                v[ t1++ ] = vow[ p1 ][ 0 ];
                sum1++;
            }
            else
            {
                if( sum2 >= 5 )
                {   
                    q2++;
                    if( con[ p2 ][ q2 ] == ‘0‘)
                    {
                        p2++;
                        q2 = 0;
                    }
                    sum2 = 0;
                }
                c[ t2++ ] = con[ p2 ][ q2 ];
                sum2++;
            }

        qsort( v , t1 , sizeof( char ) , cmp );
        qsort( c , t2 , sizeof( char ) , cmp );
        sum1 = sum2 = 0;
        for( i=1;i<=n;i++ )
            if( i & 1 )
                printf("%c",v[ sum1++ ] );
            else
                printf("%c",c[ sum2++ ] );

        puts("");
    }
    return 0;
}


C和C++的数据类型所占的空间

上一篇:RDIFramework.NET ━ .NET快速信息化系统开发框架 V3.2->WinForm版本重构岗位授权管理界面更规范、高效与美观


下一篇:python 环境搭建