/**/ /*英文口语表达时间有如下6种句型:It is five past seven.(7点5分)It is eleven to ten.(9点49分)It is half past nine.(9点30分)It is a quarter past eight.(8点15分)It is a quarter to ten.(9点45分)It is three o'clock.(3点)请根据输入的时间,输出相应的英文表达。程序从键盘输入多行数据,每一行为两个非负整数A和B,其中0<=A<13,0<=B<60,分别表示小时数和分钟数。如果输入的某一行为0 0,则表示输入已结束。程序输出要求:对于输入的每一行(最后的0 0行除外),输出相应的时间表达字符串,要求为上面6种句型之一。输入输出样例如下:样例输入:8 2112 455 00 300 0样例输出:It is twenty-one past eight.It is a quarter to thirteen.It is five o'clock.It is half pass zero.*/ #include < stdio.h > #include < string .h > char engMinute[ 20 ]; char * convertHour( int hour ) ... { char *engHour[14]; engHour[0]="zero"; engHour[1]="one"; engHour[2]="two"; engHour[3]="three"; engHour[4]="four"; engHour[5]="five"; engHour[6]="six"; engHour[7]="seven"; engHour[8]="eight"; engHour[9]="nine"; engHour[10]="ten"; engHour[11]="eleven"; engHour[12]="twelve"; engHour[13]="zero"; return engHour[hour];} char * convertMinute( int minute ) ... { char *singleNum[10]; char *doubleNum[10]; char *integerNum[6]; if( 45<minute ) minute=60 - minute; singleNum[1]="one"; singleNum[2]="two"; singleNum[3]="three"; singleNum[4]="four"; singleNum[5]="five"; singleNum[6]="six"; singleNum[7]="seven"; singleNum[8]="eight"; singleNum[9]="nine"; doubleNum[0]="ten"; doubleNum[1]="eleven"; doubleNum[2]="twelve"; doubleNum[3]="thirteen"; doubleNum[4]="fourteen"; doubleNum[5]="fifteen"; doubleNum[6]="sixteen"; doubleNum[7]="seventeen"; doubleNum[8]="eighteen"; doubleNum[9]="nineteen"; integerNum[2]="twenty"; integerNum[3]="thirty"; integerNum[4]="forty"; integerNum[5]="fifty"; if( 1<=minute && 9>=minute ) strcpy( engMinute, singleNum[minute] ); else if( 10<=minute && 19>=minute ) strcpy( engMinute, doubleNum[minute%10] ); else if( 20==minute ) strcpy( engMinute, integerNum[minute/10] ); else if( 30==minute ) strcpy( engMinute, integerNum[minute/10] ); else if( 40==minute ) strcpy( engMinute, integerNum[minute/10] ); else if( 50==minute ) strcpy( engMinute, integerNum[minute/10] ); else ...{ strcpy( engMinute, integerNum[minute/10] ); strcat( engMinute, "-" ); strcat( engMinute, singleNum[minute%10] ); } return engMinute;} void main( void ) ... { int hour; int minute; do ...{ printf( "Please input the time: " ); scanf( "%d%d", &hour, &minute ); if( !( 0<=hour && 13>hour && 0<=minute && 60>minute ) ) ...{ printf( " Input error! Please input again. " ); continue; } if( 0==hour && 0==minute ) break; printf( "It is " ); if( 0==minute ) printf( "%s o'clock. ", convertHour( hour ) ); else if( 15==minute ) printf( "a quarter past %s. ", convertHour( hour ) ); else if( 30==minute ) printf( "half past %s. ", convertHour( hour ) ); else if( 45==minute ) printf( "a quarter to %s. ", convertHour( hour+1 ) ); else if( 45>minute ) printf( "%s past %s. ", convertMinute( minute ), convertHour( hour ) ); else if( 45<minute ) printf( "%s to %s. ", convertMinute( minute ), convertHour( hour+1 ) ); } while( hour!=0 || minute!=0 );}