Fortune Telling Collection - Comprehensive fortune-telling - How to write a constellation query system with C? Seek source code,

How to write a constellation query system with C? Seek source code,

The program is not very good, not very simplified. Enter the format month-day name.

If the input format does not match, it is over. The results are saved in a tab. Txt document.

You can try.

# include & ltstdio.h & gt

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

{

Char t, a[50][20] = {{0}, Aquarius, Pisces, Aries, Taurus, Gemini, Cancer, Leo, Virgo, Libra, Scorpio and Sagittarius.

Int month and day;

FILE * fp

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

{

Printf ("Can't be great tab.txt!" );

Returns 0;

}

Printf ("Please enter the date and name, for example: 04-04- 10 James \ n "););

while( 1)

{

Scanf("%d-%d %s%*c ",& day & amp);

Switch (month)

{

Case12: {if (day > =22){fprintf(fp, "%d-%d% s \ n", month, day, a[ 12], b); printf("%s\n ",a[ 12]); Break; }else{fprintf(fp," %d-%d %s %s\n ",month,day,a[ 1 1],b); printf("%s\n ",a[ 1 1]); Break; }}

Case11:{if (day > =22){fprintf(fp, "%d-%d% s \ n", month, day, a[ 1 1], b); printf("%s\n ",a[ 1 1]); Break; }else{fprintf(fp," %d-%d %s %s\n ",month,day,a[ 10],b); printf("%s\n ",a[ 10]); Break; }}

Case10: {if (day > =23){fprintf(fp, "%d-%d% s \ n", month, day, a[ 10], b); printf("%s\n ",a[ 10]); Break; }else{fprintf(fp," %d-%d %s %s\n ",month,day,a[9],b); printf("%s\n ",a[9]); Break; }}

Situation 9: {if (day > =23){fprintf(fp," %d-%d %s %s\n ",month,day,a[9],b); printf("%s\n ",a[9]); Break; }else{fprintf(fp," %d-%d %s %s\n ",month,day,a[8],b); printf("%s\n ",a[8]); Break; }}

Case 8: {if (day > =23){fprintf(fp," %d-%d %s %s\n ",month,day,a[8],b); printf("%s\n ",a[8]); Break; }else{fprintf(fp," %d-%d %s %s\n ",month,day,a[7],b); printf("%s\n ",a[7]); Break; }}

Situation 7: {if (day > =23){fprintf(fp," %d-%d %s %s\n ",month,day,a[7],b); printf("%s\n ",a[7]); Break; }else{fprintf(fp," %d-%d %s %s\n ",month,day,a[6],b); printf("%s\n ",a[6]); Break; }}

Case 6: {if (day > =22){fprintf(fp, "%d-%d %s %s\n", month, day, a[6], b); printf("%s\n ",a[6]); Break; }else{fprintf(fp," %d-%d %s %s\n ",month,day,a[5],b); printf("%s\n ",a[5]); Break; }}

Situation 5: {if (day > =2 1){fprintf(fp, "%d-%d %s %s\n", month, day, a[5], b); printf("%s\n ",a[5]); Break; }else{fprintf(fp," %d-%d %s %s\n ",month,day,a[4],b); printf("%s\n ",a[4]); Break; }}

Situation 4: {if (day > =2 1){fprintf(fp, "%d-%d %s %s\n", month, day, a[4], b); printf("%s\n ",a[4]); Break; }else{fprintf(fp," %d-%d %s %s\n ",month,day,a[3],b); printf("%s\n ",a[3]); Break; }}

Situation 3: {if (day > =2 1){fprintf(fp, "%d-%d %s %s\n", month, day, a[3], b); printf("%s\n ",a[3]); Break; }else{fprintf(fp," %d-%d %s %s\n ",month,day,a[2],b); printf("%s\n ",a[2]); Break; }}

Case 2: {if (day > = 19){fprintf(fp, "%d-%d %s %s\n", month, day, a[2], b); printf("%s\n ",a[2]); Break; }else{fprintf(fp," %d-%d %s %s\n ",month,day,a[ 1],b); printf("%s\n ",a[ 1]); Break; }}

Case1:{if (day > =20){fprintf(fp, "%d-%d% s \ n", month, day, a[ 1], b); printf("%s\n ",a[ 1]); Break; }else{fprintf(fp," %d-%d %s %s\n ",month,day,a[ 12],b); printf("%s\n ",a[ 12]); Break; }}

}

}

fclose(FP);

Returns 0;

}