欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

蓝桥题目:B-26、报时助手

程序员文章站 2022-03-14 09:49:05
...

蓝桥题目:B-26、报时助手

#include<iostream>
using namespace std;

void prounce(int n)
{
	switch(n)
		{
		case 0:cout<<"zero";break;
		case 1:cout<<"one";break;
		case 2:cout<<"two";break;
		case 3:cout<<"three";break;
		case 4:cout<<"four";break;
		case 5:cout<<"five";break;
		case 6:cout<<"six";break;
		case 7:cout<<"seven";break;
		case 8:cout<<"eight";break;
		case 9:cout<<"nine";break;
		case 10:cout<<"ten";break;
		case 11:cout<<"eleven";break;
		case 12:cout<<"twelve";break;
		case 13:cout<<"thirteen";break;
		case 14:cout<<"fourteen";break;
		case 15:cout<<"fifteen";break;
		case 16:cout<<"sixteen";break;
		case 17:cout<<"seventeen";break;
		case 18:cout<<"eighteen";break;
		case 19:cout<<"nineteen";break;
		case 20:cout<<"twenty";break;
		case 30:cout<<"thirty";break;
		case 40:cout<<"forty";break;
		case 50:cout<<"fifty";break;
		}
}

void read(int h)
{
	if(h<=20)
		prounce(h);
	else
	{
		int unit, decade;
		unit = h % 10;//1
		decade = h - unit;//30
		prounce(decade);
		cout<<" ";
		prounce(unit);
	}
	
}
int main()
{
	int h, m;
	cin>> h >> m;
	if(m == 0)
	{
		read(h);
		cout<<" o'clock";
	}
	else
	{
		read(h);
		cout<<" ";
		read(m);
	}
	return 0;
}