]]> ]]>

Числа Фибоначчи в Clarion

Пример для версий Clarion C10

использование 64-битной арифметики

  PROGRAM

OMIT('***')
 * User: Shur
 * Date: 29.02.2016
 * Time: 21:18
 ***

  MAP
      include('i64.inc')
ShowINT64  PROCEDURE(*INT64 a),STRING
  END

a                    LIKE(INT64)
b                    LIKE(INT64)
c                    LIKE(INT64)
str1                 CSTRING(32000)
str2                 CSTRING(32000)

   CODE
      a.lo = 1
      str1 = '1=' & ShowINT64(a)         
      b.lo = 1
      str1 = str1 & '|2=' & ShowINT64(b) 
      str2 ='1, 1'
      loop i# = 3 to 200 
         i64Add(a,b,c)
         if i64Sign(c) = -1
            break
         end   
         a :=: b ! deep assignment uses for structures
         b = c   ! usual assignment can be also used     
         str1 = str1 & '|' & i# & '=' & ShowINT64(c)         
         str2 = str2 & ', ' & ShowINT64(c)         
      end
      message(str2,'Fibonacci',,,,10b)
      message(str1,'Fibonacci',,,,10b)
            
ShowINT64           PROCEDURE(a)
d DECIMAL(30,0)
   CODE
      i64ToDecimal(d,a)
      return(d)

Комментарии

]]>

blog comments powered by Disqus

]]>

Работа программистам