教小朋友输入一个数,输出这个数读音(两位数以内)的程序,但是小朋友写Python,于是写了个c++然后现查python的语法直接改过去
#include<iostream>
using namespace std;
string a[10]={"","一","二","三","四","五","六","七","八","九"};
int main(){
int num;
cin>>num;
if(num==0){
cout<<"零"<<endl;
}else if(num>=10){
int t=num/10;
cout<<(t==1?a[0]:a[t])<<"十";
}
cout<<a[num%10]<<endl;
return 0;
}
num=int(input())
ch=["","一","二","三","四","五","六","七","八","九"]
if num==0:
print("零")
elif num>=10:
t= num//10
if(t!=1):
print(ch[t],end="")
print("十",end="")
print(ch[num%10])
hh