当前位置:网站首页>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] + " ");
}
}
}
}
结果:
边栏推荐
猜你喜欢

皮质-皮质网络的多尺度交流

Implement general-purpose, high-performance sorting and quicksort optimizations

基于FPGA的FIR滤波器的实现(5)— 并行结构FIR滤波器的FPGA代码实现

opencv实现数据增强(图片+标签)平移,翻转,缩放,旋转

PIXHAWK飞控使用RTK

ROS 话题通信理论模型

接口测试的基础流程和用例设计方法你知道吗?

Multiscale communication in cortical-cortical networks

Discourse's Close Topic and Reopen Topic

TF中的条件语句;where()
随机推荐
Get Pinduoduo product information operation details
concept noun
MySQL使用GROUP BY 分组查询时,SELECT 查询字段包含非分组字段
年薪40W测试工程师成长之路,你在哪个阶段?
《猪猪1984》NFT 作品集将上线 The Sandbox 市场平台
Production and optimization of Unity game leaderboards
Redis源码-String:Redis String命令、Redis String存储原理、Redis字符串三种编码类型、Redis String SDS源码解析、Redis String应用场景
国密规范 SM2 SM3 SM4
Pico neo3 Unity打包设置
go-grpc TSL认证 解决 transport: authentication handshake failed: x509 certificate relies on ... ...
详述 MIMIC护理人员信息表(十五)
How to choose professional, safe and high-performance remote control software
Service的两种状态形式
easyrecovery15数据恢复软件收费吗?功能强大吗?
Pinduoduo API interface
一张图了解JVM八大原子操作
Daily sql - judgment + aggregation
从何跟踪伦敦金最新行情走势?
C语言每日一练——Day02:求最小公倍数(3种方法)
【深度学习】什么是互信息最大化?