当前位置:网站首页>1002 写出这个数 (20 分)
1002 写出这个数 (20 分)
2022-08-11 06:45:00 【呆比特】
题目要求:
代码:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
//輸入接收
String str = scan.nextLine();
//提前定义数字与拼音的对应关系
String result[] = {
"ling","yi","er","san","si","wu","liu","qi","ba","jiu"};
//和
int sum = 0;
//求輸入每位和
String[] strs = str.split("");
for (int i = 0; i < str.length(); i++) {
sum += Integer.valueOf(strs[i]);
}
//对应输出
for (int i = 0; i < (sum + "").length(); i++) {
int index = Integer.valueOf((sum + "").split("")[i]);
if (i == (sum + "").length() - 1){
System.out.print(result[index]);
} else{
System.out.print(result[index] + " ");
}
}
}
}
结果:
边栏推荐
- Tensorflow中使用tf.argmax返回张量沿指定维度最大值的索引
- Internet phone software or consolidation of attack must be "free" calls security clearance
- 年薪40W测试工程师成长之路,你在哪个阶段?
- 微信小程序功能上新(2022.06.01~2022.08.04)
- 3GPP LTE/NR信道模型
- exness:黄金1800关口遇阻,静待美国CPI出炉
- 详述MIMIC 的ICU患者检测时间信息表(十六)
- Unity程序员如何提升自己的能力
- Redis + lua implements distributed interface current limiting implementation scheme
- Activity的四种启动模式
猜你喜欢
Daily sql-employee bonus filtering and answer rate ranking first
Douyin get douyin share password url API return value description
Taobao product details API interface
皮质-皮质网络的多尺度交流
公牛10-11德里克·罗斯最强赛季记录
Douyin API interface
从苹果、SpaceX等高科技企业的产品发布会看企业产品战略和敏捷开发的关系
jar服务导致cpu飙升问题-带解决方法
【LaTex-错误和异常】\verb ended by end of line.原因是因为闭合边界符没有在\verb命令所属行中出现;\verb命令的正确和错误用法、verbatim环境的用法
【@网络工程师:用好这6款工具,让你的工作效率大翻倍!】
随机推荐
Activity的四种状态
联想集团:2022/23财年第一季度业绩
常见激活函数及其导数
NFT 的价值从何而来
Douyin get douyin share password url API return value description
daily sql - query for managers and elections with at least 5 subordinates
Taobao API interface reference
【LeetCode每日一题】——844.比较含退格的字符串
redis操作
MindManager2022全新正式免费思维导图更新
从何跟踪伦敦金最新行情走势?
Multiscale communication in cortical-cortical networks
JD.com product details API call example explanation
redis + lua实现分布式接口限流实现方案
Daily sql: request for friend application pass rate
【Pytorch】nn.ReLU(inplace=True)
伦敦银规则有哪些?
如何选择专业、安全、高性能的远程控制软件
语音信号处理:预处理【预加重、分帧、加窗】
NTT的Another Me技术助力创造歌舞伎演员中村狮童的数字孪生体,将在 “Cho Kabuki 2022 Powered by NTT”舞台剧中首次亮相