Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import kotlin.math.*
- class Z {
- fun SOfRectangle(a : Int, b : Int) : Int { // 1
- return a*b
- }
- fun SOfSquare(radius : Double) : Double { // 2
- return Math.PI * radius * radius
- }
- fun DifBetween(x1 : Double, x2 : Double, y1 : Double, y2 : Double) : Double { // 3
- return sqrt((x1 - x2)*(x1-x2) + (y1 - y2)*(y1-y2))
- }
- fun predChet(num : Int) : Boolean { // 4
- if (num % 2 == 0) {
- return true
- }
- return false
- }
- fun predOneOfThree(a : Int, b : Int, c : Int) : Boolean { // 5
- if ((a > 0 && b < 0 && c < 0) || (a < 0 && b > 0 && c < 0) || (a < 0 && b < 0 && c > 0)) {
- return true
- }
- return false
- }
- fun checkFree(a : Int, b : Int, c : Int) : Boolean { // 6
- if (a < b && b < c) return true
- return false
- }
- fun sin(x : Double) : Double { // 7
- if (x >= 5.0) {
- return Math.sin(x)
- }
- else {
- return 6.0-x
- }
- }
- fun cos(x : Double) : Double { // 8
- if (x >= -5) return x*x
- else return Math.cos(x)
- }
- fun tan(x : Double) : Double { // 9
- if (x <= 0) return Math.tan(x)
- else return 1/x
- }
- fun ten(a : Double, b : Double) : Double { // 10
- var sum = 0.0
- for(i in floor(a).toInt()+1 until ceil(b).toInt()) {
- sum += i.toDouble().pow(2.0)
- }
- return sum
- }
- fun factorial(n: Int): Double { // 11
- var result = 1.0
- for (i in 1..n) {
- result *= i
- }
- return result
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement