当前位置:网站首页>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] + " ");
}
}
}
}
结果:
边栏推荐
猜你喜欢
随机推荐
Unity3D 学习路线?
第一个C函数:如何实现板级初始化?
求职简历这样写,轻松搞定面试官
jar服务导致cpu飙升问题-带解决方法
Daily sql--statistics the total salary of employees in the past three months (excluding the latest month)
如何选择专业、安全、高性能的远程控制软件
Edge provides label grouping functionality
Daily sql - judgment + aggregation
为什么我使用C#操作MySQL进行中文查询失败
Unity开发者必备的C#脚本技巧
软件测试基本流程有哪些?北京专业第三方软件检测机构安利
李沐d2l(十)--卷积层Ⅰ
NFT 的价值从何而来
Activity的四种启动模式
Waldom Electronics宣布成立顾问委员会
When MySQL uses GROUP BY to group the query, the SELECT query field contains non-grouping fields
那些事情是用Unity开发项目应该一开始规划好的?如何避免后期酿成巨坑?
Redis源码-String:Redis String命令、Redis String存储原理、Redis字符串三种编码类型、Redis String SDS源码解析、Redis String应用场景
梅科尔工作室——BP神经网络
联想集团:2022/23财年第一季度业绩









