×

Loading...

Topic

This topic has been archived. It cannot be replied.
  • 工作学习 / IT杂谈 / 请问最小公被数的英语是什么?如果能有源大妈就更好拉。thanks~~
    • 请看源程序和英文翻译:
      ]LIST
      10 LET LCM=0
      20 INPUT M,N
      30 LET LCM=LCM+M
      40 IF INT(LCM/N)*N<>LCM THEN 30
      50 PRINT "The lowest common multiple is "; LCM
      60 END

      ]RUN
      27,36
      The lowest common multiple is 108

      ]RUN
      19,6
      The lowest common multiple is 114

      ]

      注:此程序在APPLE-II、Laser-310、PZ-80等微电脑上运行通过。
      lowest common multiple 查自金山词霸2000
      • 哇!!!!什么年代的程序了,让我想起十几年前学BASIC的时候,让我想起了APPLE II和中华学习机。
      • 分特,我的词霸三里没有!我要的是一堆数的LCM,有吗?XIEXIEXIEXIE
        • 这有何难!看程序。BTW,就凭咱写这几句,在加拿大找个Apple II的工作应该没问题吧?
          ]LIST
          10 DIM A(10)
          20 FOR I=1 TO 10
          30 READ A(I)
          40 NEXT I
          50 LET M=A(1)
          60 LET N=1
          70 FOR I=2 TO 10
          80 LET LCM=0
          90 LET LCM=LCM+M
          100 IF INT(LCM/N)*N<>LCM THEN 90
          110 LET M=LCM
          120 LET N=A(I)
          130 NEXT I
          140 PRINT "The lowest common multiple is "; LCM
          150 DATA 34,21,6,8,19,2,5,10,24,9
          160 END

          ]
          • thanks, thanks, I will use it as the last few line of my project, I will add a comment: // copy from chang zi...
          • my implementation~~
            void main(int argc, char* argv[])
            {
            int i, tmp = 1, lcm, lcm2, len = 10;
            int *data = new int[len];

            for(i = 0; i < len; i++)
            data[i] = XXX; // initialize data

            for(i = 0; i < len; i ++){
            lcm = lcm2 = data[i];

            while((lcm / tmp) * tmp != lcm){
            lcm += lcm2;
            }

            tmp = lcm;
            }

            printf("%d\n", lcm);
            }
      • cool!
      • 太妙了!让我想起了小时候。我上的小学算是不错的了,四年级就让学生学电脑了(R1机/Laser310),那可是在83年呀!我第一个游戏就是用这种语言写的,嗨……其实算不上游戏!:-)
    • Lowest Common Multiple, or Least Common Multiple, or LCM