Fortune Telling Collection - Zodiac Analysis - How to write a constellation query system with C? Seek source code,
How to write a constellation query system with C? Seek source code,
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;
}
- Previous article:Seemingly kind, in fact, do you know which constellations are bad for water?
- Next article:Help me look at my horoscope,
- Related articles
- In the process of getting along with people, which aspect of the twelve constellations is the most disgusting?
- Constellation phenomenon _ Constellation phenomenon psychology
- What constellation is Gregorian calendar1September 23rd, 996?
- Information about Constellation _ Information picture about Constellation
- Which constellation failed more _ which constellation was the most successful?
- What is the constellation of 165438+ 10/0?
- Help me look at the eight characters and answer the questions.
- Who is the most capable of creating beauty in fire sign?
- What constellation's love story is the most romantic?
- Love dominates, air-cooled, and domineering.