igorich1376

Leciono #2

Jul 25th, 2024
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 1.38 KB | None | 0 0
  1. //Лекция №2  21-07-2024
  2. ##
  3. //Println(1+2, 3-4, 5*6, 7/8, 2**8);
  4. //Println(Cos(60/180*Pi), Sin(123), Logn(2,256));
  5. //var a: byte;
  6. //a := 250;
  7. //Print(a);
  8. //a := a + 10;
  9. //Print(a);
  10. Println(100/7, 100 div 7, 100 mod 7);
  11. Println(100/-7, 100 div -7, 100 mod -7);
  12. Println(-100/7, -100 div 7, -100 mod 7);
  13. Println(-100/-7, -100 div -7, -100 mod -7);
  14. ////////////////////////////////////////
  15. ## //просто функция
  16. function Fn1(a: integer): integer;
  17. begin
  18.   if (a > 100) then Result := a - 100
  19.     else Result := a * 10;
  20. end;
  21.  
  22. Print(Fn1(550));
  23. ////////////////////////////////////////
  24. ## //фибоначчи
  25. [cache] // кэширование - это (определение)
  26. function Fibo(n: integer): Biginteger;
  27. begin
  28.   if n <= 2 then Result := 1
  29.   else Result := Fibo(n-1) + Fibo(n-2)
  30. end;
  31.  
  32. for var i:=1 to 10000 do Fibo(i);
  33. Print(Fibo(10000))
  34. /////////////////////////////
  35. ## //№16 ЕГЭ
  36. function F(n: integer): BigInteger;
  37. begin
  38.   if (n = 1) then Result :=1;
  39.   if (n mod 2 = 0) then Result := n+F(n-1);
  40.   if (n > 1) and (n mod 2 = 1) then Result := 2*F(n-2)
  41.  
  42. end;
  43. Print(F(26))
  44. ///////////////////////////////////////////////
  45. ## //№23 ЕГЭ
  46. function F(a,b: integer): integer ;
  47. begin
  48.   if (a > b) or (a = 12) then Result := 0
  49.   else if a=b then Result := 1
  50.   else Result := F(a+1,b)+F(a+2,b)+F(a*3,b)
  51. end;
  52.  
  53. Print(F(2,9) * F(9,19))
  54.  
Advertisement
Add Comment
Please, Sign In to add comment