不会改代码,,,还是感觉逻辑非常对但就是没有输出,,,
package hahaha;import java.util.Scanner;
public class haha {
public static void main(String[] args)
{
Scanner in=new Scanner(System.in);
String a=in.nextLine();
String[]smg={"zero","one","two","three","four","five","six","seven","eight","nine"};
int []n={0,1,2,3,4,5,6,7,8,9};
String b;
int sum=0;
for(int i=0;i<a.length();i++)
{ sum+=a.charAt(i)-'0';}
b=String.valueOf(sum);
for(int i=0;i<b.length();i++)
{
{
if((b.charAt(i)-'0')==i)
{System.out.println(smg[i]);}
}
}
//System.out.println()
in.close();
}
// TODO Auto-generated method stub
}
我想利用下标,对照输出,,,但是就是没有输出,,,,,,自己都晕了,开始是接收字符串,然后把字符串变成一个个数字加起来,然后又变成字符串,一个一个利用下标相等就输出对应的拼音。