如何用C写一个星座查询系统?求源码,

程序不是很好,不是很简化。输入格式月-日名称

如果输入格式不匹配,就结束了。结果保存在选项卡中。Txt文档。

你可以试试。

# include & ltstdio.h & gt

int main(int argc,char *argv[])

{

char t,a[50][20] = {{0},“水瓶座”,“双鱼座”,“白羊座”,“金牛座”,“双子座”,“巨蟹座”,“狮子座”,“处女座”,“天秤座”,“天蝎座”,“射手座”,“摩羯座”},b[20];

int月,日;

FILE * fp

if((fp=fopen("tab.txt "," w"))==NULL)

{

printf("不能伟大tab.txt!");

返回0;

}

Printf("请输入日期和姓名,例如:04-10 James \ n ");

while(1)

{

scanf("%d-%d %s%*c ",& amp月份& amp日& ampb);

开关(月)

{

案例12:{ if(day & gt;=22){fprintf(fp," %d-%d %s %s\n ",月,日,a[12],b);printf("%s\n ",a[12]);打破;}else{fprintf(fp," %d-%d %s %s\n ",month,day,a[11],b);printf("%s\n ",a[11]);打破;}}

案例11:{ if(day & gt;=22){fprintf(fp," %d-%d %s %s\n ",月,日,a[11],b);printf("%s\n ",a[11]);打破;}else{fprintf(fp," %d-%d %s %s\n ",month,day,a[10],b);printf("%s\n ",a[10]);打破;}}

案例10:{ if(day & gt;=23){fprintf(fp," %d-%d %s %s\n ",月,日,a[10],b);printf("%s\n ",a[10]);打破;}else{fprintf(fp," %d-%d %s %s\n ",month,day,a[9],b);printf("%s\n ",a[9]);打破;}}

情况9:{ if(day & gt;=23){fprintf(fp," %d-%d %s %s\n ",month,day,a[9],b);printf("%s\n ",a[9]);打破;}else{fprintf(fp," %d-%d %s %s\n ",month,day,a[8],b);printf("%s\n ",a[8]);打破;}}

案例8:{ if(day & gt;=23){fprintf(fp," %d-%d %s %s\n ",month,day,a[8],b);printf("%s\n ",a[8]);打破;}else{fprintf(fp," %d-%d %s %s\n ",month,day,a[7],b);printf("%s\n ",a[7]);打破;}}

情况7:{ if(day & gt;=23){fprintf(fp," %d-%d %s %s\n ",month,day,a[7],b);printf("%s\n ",a[7]);打破;}else{fprintf(fp," %d-%d %s %s\n ",month,day,a[6],b);printf("%s\n ",a[6]);打破;}}

案例6:{ if(day & gt;=22){fprintf(fp," %d-%d %s %s\n ",月,日,a[6],b);printf("%s\n ",a[6]);打破;}else{fprintf(fp," %d-%d %s %s\n ",month,day,a[5],b);printf("%s\n ",a[5]);打破;}}

情况5:{ if(day & gt;=21){fprintf(fp," %d-%d %s %s\n ",月,日,a[5],b);printf("%s\n ",a[5]);打破;}else{fprintf(fp," %d-%d %s %s\n ",month,day,a[4],b);printf("%s\n ",a[4]);打破;}}

情况4:{ if(day & gt;=21){fprintf(fp," %d-%d %s %s\n ",月,日,a[4],b);printf("%s\n ",a[4]);打破;}else{fprintf(fp," %d-%d %s %s\n ",month,day,a[3],b);printf("%s\n ",a[3]);打破;}}

情况3:{ if(day & gt;=21){fprintf(fp," %d-%d %s %s\n ",月,日,a[3],b);printf("%s\n ",a[3]);打破;}else{fprintf(fp," %d-%d %s %s\n ",month,day,a[2],b);printf("%s\n ",a[2]);打破;}}

情况2:{ if(day & gt;=19){fprintf(fp," %d-%d %s %s\n ",月,日,a[2],b);printf("%s\n ",a[2]);打破;}else{fprintf(fp," %d-%d %s %s\n ",month,day,a[1],b);printf("%s\n ",a[1]);打破;}}

案例1:{ if(day & gt;=20){fprintf(fp," %d-%d %s %s\n ",月,日,a[1],b);printf("%s\n ",a[1]);打破;}else{fprintf(fp," %d-%d %s %s\n ",month,day,a[12],b);printf("%s\n ",a[12]);打破;}}

}

}

fclose(FP);

返回0;

}