I have so far written a question myself confused

import Foundation var z = ["10 10 10 10", "20 25 20 25", "100 30 20 40", "23 40 44 100"] for x in z { var s: [String] = [] NSString(string: x).componentsSeparatedByString(" ") // [ } 

An array of z is given in which the size of the side of the figure is written in the lines. You need to find out what kind of figure it is.

as I understand it, you just need to parse the array line -> then make them ints -> compare and get the result so the question is what is the line from the array I divided I got four lines with numbers like me to do something further with these numbers

  • if all 4 are equal, this is either a square or a rhombus or a parallelogram, if 1 = 3 and 2 = 4, then this is either a rectangle or a parallelogram, the rest is a trapezium. something like that. You did not miss anything in the condition? - Max Mikheyenko 10:35 pm
  • forgot to clarify if 4 are equal to a square if 1 = 3 and 2 = 4 is a rectangle the rest of the trapezoid - DmitrievichR

1 answer 1

  var z = ["10 10 10 10", "20 25 20 25", "100 30 20 40", "23 40 44 100"] for x in z { var values:[Int] = [] let strValues:[String] = x.componentsSeparatedByString(" ") for i in strValues { values.append(Int(i)!) } if(values[0] == values[1] && values[1] == values[2] && values[2] == values[3]) { print("квадрат") } else if(values[0] == values[2] && values[1] == values[3]) { print("прямоугольник") } else { print("трапеция") } }