慢点ei等等我


私信TA

用户名:uq_54102361448

访问量:2623

签 名:

谁能教教我,我不会啊~_~!

等  级
排  名 2225
经  验 2396
参赛次数 1
文章发表 4
年  龄 0
在职情况 学生
学  校
专  业

  自我简介:

解题思路:

先建三个数组,分别是贮存 一.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 人评分

  评论区

666,世界最牛逼,unstoppable,前无古人后无来者,独一无二的作品真牛逼
2020-11-24 15:19:54
真牛,6666,写的真不错
2020-11-24 15:11:18
  • «
  • 1
  • »