1613-3-傅溥衍 总结《2016年11月14日》【连续四十五天总结】

标题:类和对象
关键词:析构函数   整数翻译函数
内容: 
A今日完成情况

1.看类70%


B具体内容

折构函数在对象创建时执行,提供了初始化对象的一种简便手段。

析构函数在对象被撤销时执行,用于完成对象被撤销前的一些清理工作。

析构函数的格式:

<类名>::~<类名>()

{

函数体

}


C明日计划

Aperson类的设计

B实际意义的折构函数



整数翻译函数

#include<iostream>
#include<string.h>
using namespace std;
class
static char *num1[]=
{
	"","one","two","three","four","five","six","seven","eight","nine","ten",
	"eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen",
	"eighteen","nineteen"
};
static char *num10[]=
{
	"",",","twenty","thirty","forty","fifty","sixty","seventy","eighty",
	"ninety"
 };
  robot
{
	private:
		char name[20];
		char type[20];
	public:
		robot()
		{
			strcpy(name,"啊啊啊");
			strcpy(type,"嘤嘤嘤");
			
		}
		void set(char n[],char t[])
		{
			strcpy(name,n);
			strcpy(type,t);
		}
		void out(int a);
		void train_int(int n);
		~robot(){};
};
void robot::out(int a)
{
	int b=a%100;
	{
		cout<<num1[a/100]<<"hundred";
		if(b!=0)
		cout<<"and";
	}
	if(b<20)
		cout<<num1[b];
	else
	{
		cout<<num10[b/10];
		if(b%10!=0)
		cout<<"\b-"<<num1[b%10];
	}
}
void robot::tran_int(int n)
{
	if(n>1999999999)
		cout<<"dev c++无法处理1999999999位的数"<<endl;
		else
		{
			int a=n/1000000000,b=(n%1000000000)/1000000,c=(n%1000000)/1000,
				d=n%1000;
			if(a!=0)
			{	out(a);
				cout<<"billion";
				
			}
			if(b!=0)
			{	out(b);
				cout<<"million";
			}
			if(c!=0)
			{
				out(c);
				cout<<"thousand";
			}
			if(d!=0)
			{
				if(d<100&&(a!=0||b!=0||c!=0))
				cout<<"and";
				out(d);
			}
			cout<<endl;
		}
}
int main()
{
	int n;
	cout<<"请输入n:";
	cin>>n;
	cout<<n<<endl;
	robot brown;
	brown.tran_int(n);
	return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值