IOS Mobile Application Development
Session 5 Swift IOS Code
///Arrays
var intArr = [1,2,3,4,5,6]
var intArr1: [Int] = [1,2,3,34,456,1]
print(intArr)
print(intArr1)
print(intArr[0])
print(intArr1[0])
for i in 0..<intArr.count
{
print(intArr[i])
}
var arr2d: [[Int]] = [[1,2,3],[4,5,6],[7,8,9]]
print(arr2d)
print(arr2d[0][0])
for i in 0...2
{
for j in 0...2
{
print(arr2d[i][j])
}
}
//1 2 3
//4 5 6
//7 8 9
var arr2d1: [[Int]] = [[1,2,3],[4,5,6],[7,8,9]]
for i in 0..<arr2d1.count
{
var line = ""
for j in 0..<arr2d1[i].count
{
line += String(arr2d1[i][j])
line += " "
//print(arr2d[i][j])
}
print(line)
}
No comments:
Post a Comment
Fell free to write your query in comment. Your Comments will be fully encouraged.