2012年7月30日

#include<stdio.h>
#include<string.h>
int main()
{
    char a[19][7]={"pop","no","zip","zotz","tzec","xul","yoxkin","mol","chen","yax","zac","ceh","mac","kankin","muan","pax","koyab","cumhu","uayet"};
    char b[20][9]={"imix","ik","akbal","kan","chicchan","cimi", "manik","lamat","muluk","ok","chuen","eb","ben","ix","mem","cib","caban","eznab","canac","ahau"};
    int n,i,j,year[20]={0},day1[20]={0};
    long day[20]={0};
    char m[30][7];
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d. %s %d",&day[i],m[i],&year[i]);
    }
    printf("%d\n",n);
    for(i=0;i<n;i++)
    {
        for(j=0;j<19;j++)
        {
            if(strcmp(m[i],a[j])==0)break;
        }
        day[i]+=j*20+year[i]*365+1;
        year[i]=day[i]/260;
        if(day[i]%13==0)day1[i]=13;
        else day1[i]=day[i]%13;    
        if(day[i]%20!=0)
        printf("%d %s %d\n",day1[i],b[day[i]%20-1],year[i]);
        else printf("%d ahau %d\n",day1[i],year[i]);
    }
    return 0;
}
望各位大神指教 running error????

posted @ 2012-07-30 14:59 梁子 阅读(62) | 评论 (0)编辑 收藏

#include <stdio.h>
typedef struct
{
    char s[55];
    int value;
}DNA;
DNA list[200];//申请200个

int main()
{
    DNA tmp;
    int i,j,k;
    int len,n;
    scanf("%ld%ld",&len,&n);
    for(i=1;i<=n;i++)
    {
        scanf("%s",list[i].s+1);
        list[i].value=0;
        for(k=1;k<=len;k++)
            for(j=k;j<=len;j++)
                if(list[i].s[k]>list[i].s[j])
                    list[i].value++;//输入时计数
    }
    for(i=1;i<=n;i++)//排序
        for(j=i;j<=n;j++)
            if(list[i].value>list[j].value)
            {
                tmp=list[i];
                list[i]=list[j];
                list[j]=tmp;
            }
    for(i=1;i<=n;i++)
        printf("%s\n",list[i].s+1);
    return 0;
}

忙了我好长时间才改成这样,仔细一想不怎么难,只要静下心来想

posted @ 2012-07-30 10:51 梁子 阅读(83) | 评论 (0)编辑 收藏

仅列出标题