java吧 关注:1,264,142贴子:12,765,241
  • 5回复贴,共1

JAVA操作次数计算怎么做

只看楼主收藏回复

学校的作业,要你算运行了多少次程序,n是输入数字的位数,比如287有三位数字n就等于3.然后不告诉你其中有几个2,有2就加一个次数(有点迷).最后让你算java操作了几次?比如read number算一个操作,set count to 0算一个操作,if算一个操作,while比较算一个操作.endif和endwhile不算操作数.

Lucky Twos determines and displays the number of digits that are 2s in a whole number. For example, the number of 2s in 3487 is 0, while the number of 2s in 272521 is 3. Note: whole numbers are non-negative integers starting at zero 0, 1, 2, 3, 4.Assume that the fractional part is discarded in the division:10 / 4 = 28 / 5 = 120 / 3 = 6
Let n be the number of digits of the whole number. What is the number of operations that are executed in the code in terms of n?


1楼2022-09-17 07:20回复
    d


    2楼2022-09-17 08:00
    回复
      2025-06-13 14:06:20
      广告
      你说的题和图片的题完全不同 我不知道是你自己翻译错了还是其他题


      IP属地:北京来自Android客户端3楼2022-09-25 12:38
      收起回复