编写一个自定义函数tran(),该函数的功能是将100以内的任意一个整数转化大写数字形式 如99(九十九)

如题所述

#include "iostream.h"
void main(){
int n;
cout<<"请输入整数(1-99):";
cin>>n;
if(n/10==1) cout<<"十";
if(n/10==2) cout<<"二十";
if(n/10==3) cout<<"三十";
if(n/10==4) cout<<"四十";
if(n/10==5) cout<<"五十";
if(n/10==6) cout<<"六十";
if(n/10==7) cout<<"七十";
if(n/10==8) cout<<"八十";
if(n/10==9) cout<<"九十";
if(n%10==1) cout<<"一";
if(n%10==2) cout<<"二";
if(n%10==3) cout<<"三";
if(n%10==4) cout<<"四";
if(n%10==5) cout<<"五";
if(n%10==6) cout<<"六";
if(n%10==7) cout<<"七";
if(n%10==8) cout<<"八";
if(n%10==9) cout<<"九";
cout<<endl;
}
温馨提示:答案为网友推荐,仅供参考
第1个回答  2010-04-29
因为你没写具体的要求和编程语言我简单写一下思路

输入数位为x
x/10得十位数
x%10得个位数
判断十位数是否为零
是的话直接输出个位数
否的话输出“十位数”“十”“个位数”
相似回答