16.json 1.6 KB
Newer Older
每日一练社区's avatar
test  
每日一练社区 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
{
   "question_id": 751134,
   "question_title": "拆分数字",
   "question_content": "比如99 可以拆分为 9和9 9*9=81 81可以拆分为8和1 8*1=8 不能拆分了,得出结果为2\n65可以拆分为6和5,6*5=30 30可以拆分为3和0,3*0=0 不能拆分了,得出结果也为2\n实现这个功能 返回结果(结果为可拆分的次数)",
   "difficulty": "简单",
   "answer_id": 804601,
   "answer_content": "\n```\npublic class HelloWorld {\n\tpublic static int splitmul(int n)\n\t{\n\t\tint r = 1;\n\t\twhile (n > 0)\n\t\t{\n\t\t\tr *= (n % 10);\n\t\t\tn /= 10;\n\t\t}\n\t\treturn r;\n\t}\n    public static void main(String []args) {\n\t\tint n = 99;\n\t\tint x = n;\n\t\tint t = 0;\n\t\twhile (x >= 10)\n\t\t{\n\t\t\tx = splitmul(n);\n\t\t\tSystem.out.println(x);\n\t\t\tn = x;\n\t\t\tt++;\n\t\t}\n\t\tSystem.out.println(t + \"\");\n\n    }\n}\n```\n\n81\n8\n2次",
   "tag_name": "java",
   "java": "public class HelloWorld {\n\tpublic static int splitmul(int n) {\n\t\tint r = 1;\n\t\twhile (n > 0) {\n\t\t\tr *= (n % 10);\n\t\t\tn /= 10;\n\t\t}\n\t\treturn r;\n\t}\n\tpublic static void main(String[] args) {\n\t\tint n = 99;\n\t\tint x = n;\n\t\tint t = 0;\n\t\twhile (x >= 10) {\n\t\t\tx = splitmul(n);\n\t\t\tSystem.out.println(x);\n\t\t\tn = x;\n\t\t\tt++;\n\t\t}\n\t\tSystem.out.println(t + \"\");\n\t}\n}",
   "topic_link": "https://bbs.csdn.net/topics/600469974",
   "status": 1,
   "keywords": "算法",
   "license": "csdn.net",
   "notebook": {
      "java": "https://codechina.csdn.net/csdn/csdn-daily-code/-/jupyter/master/data/notebook/answer/ipynb/java/16.ipynb?type=file"
   },
   "notebook_enable": 1
}