注册 登录
编程论坛 C++教室

求助今晚得交作业....用数字输入,把它输出为英文字母

sorebas 发布于 2011-10-30 17:28, 918 次点击
学校有意个作业
就是用数字写时间,用英文输出,
比如
输 20    14(空格要用tab)
其结果应该为 twenty fourteen.
以我的能力只能写到这个水平,
请各位高手指导指导应该怎么修改。


#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
int main()
{
int a,b;
char hour[];
char minute[];
switch(a)
{
case 0:hour="zero";break;
case 1:hour="one";break;
}
switch(b)
{
case 0:minute="o'clock";break;
}
scanf("%d,%d",&a,&b);
printf("hour[]\t","minute\n");
return 0;
2 回复
#2
jcw081201102011-10-31 14:11
使用enum枚举24小时和60分钟;

int h,m; cin>>h>>m;if(!m){hh();cout<<"o' clock;";} else{hh();mm();}
mm(){switch(m)case 0:cout<<"zero";break; case 1:...} hh(){switch(h)case 0:cout<<"zero";break; case 1:...}
#3
lucky5635912011-10-31 20:41
这只有一个个存到数组了。
1