我想創(chuàng)建一個(gè)代碼,將得到輸入的所有數(shù)字的總和, 示例輸入:241 示例輸出:7 但在制作程序時(shí)有限制,只能使用基本操作,應(yīng)該使用函數(shù),沒(méi)有字符串函數(shù)僅用于獲取所述數(shù)字的總和(循環(huán)、/、%、*、-、+)被允許使用。我想的程序應(yīng)該從這個(gè)開(kāi)始.. public class SumOfDigits{ public static void main(String args[]) throws Exception{ Scanner input = new Scanner(System.in); int num = input.nextInt(); while(){ } }}
添加回答
舉報(bào)
0/150
提交
取消