當前位置:星座運勢大全官網 - 八字算命 - 如何用C寫壹個星座查詢系統?求源碼,

如何用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;

}