解题思路:
先建三个数组,分别是贮存 一.1-9数字;二.0-24数字;三.20-60整数;
再获得输入,可以判断输入是否满足要求,不满足可以结束它;
后判断
结束
注意事项:
注意点我在代码中注释;
参考代码:
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int main()
{
char no[9][10] = { "one","two","three","four","five","six","seven","eight","nine" }; //1--9
char str[25][15] = { "zero","one","two","three","four","five","six","seven","eight","nine" ,"ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen","twenty","twenty one","twenty two","twenty three","twenty four" }; //0--24
char tnt[5][10] = { "twenty","thirty","forty","fifty","sixty" };//20--60
int n1, n2;//n1是:小时;n2是:分钟;
int i, j;//i是用于确定分钟的 十位;j是用于确定分钟的 个位;
scanf("%d%d", &n1, &n2);//获取输入
if (n1 > 24 || n1 < 0 || n2>60 || n2 < 0)//不满足条件的直接结束;
{
return -1;
}
else {
printf("%s", str[n1]);//小时的直接输出;
if (n2 == 0)
{
printf(" o'clock");//分钟为0的情况;
}
else {
if (n2 <= 24)//分钟小于24直接用第二个数组输出;
{
printf(" %s", str[n2]);
}
else {
i = n2 / 10;//i是用于确定分钟的 十位;j是用于确定分钟的 个位;
j = n2 % 10;
printf(" %s", tnt[i - 2]);
printf(" %s", no[j - 1]);
}
}
}
printf("\n");
return 0;
}
0.0分
8 人评分
Hello, world! (C语言代码)浏览:1315 |
【明明的随机数】 (C++代码)浏览:834 |
分糖果 (C++代码)浏览:1537 |
C语言程序设计教程(第三版)课后习题9.8 (C语言代码)浏览:702 |
演讲大赛评分 (C语言代码)浏览:1696 |
C语言程序设计教程(第三版)课后习题5.6 (C语言代码)浏览:631 |
【偶数求和】 (C++代码)浏览:744 |
C语言程序设计教程(第三版)课后习题7.5 (C语言代码)浏览:727 |
1073题解浏览:652 |
很简单,,题解1041:C语言程序设计教程(第三版)课后习题9.8 (C语言代码)浏览:616 |
慢点ei等等我 2020-11-24 15:20:48 |
。。。。。
软件二班谭豪 2021-03-29 20:25:19 |
给了多少钱