Advertisement
Mouamle

Solved

Jun 20th, 2017
571
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.57 KB | None | 0 0
  1. function solve(t1, t2)
  2.   local result = t1;
  3.   for i = 1, #t2 do
  4.     result[#result + 1] = t2[i];
  5.   end
  6.   return result;
  7. end
  8.  
  9. function printTable(title, tbl)
  10.   print(title)
  11.   for i = 1, #tbl do
  12.     io.write(tbl[i] .. " ");
  13.   end
  14.   print()
  15. end
  16.  
  17. table1 = {4, 7, 2, 3, 1};
  18. table2 = {8, 5, 7, 4};
  19.  
  20. tableResult = solve(table1, table2);
  21.  
  22. printTable("First table", table1)
  23. printTable("Second table", table2)
  24. printTable("Result", tableResult)
  25.  
  26.  
  27. --[[
  28. The output
  29.   First table
  30.   4 7 2 3 1 8 5 7 4
  31.   Second table
  32.   8 5 7 4
  33.   Result
  34.   4 7 2 3 1 8 5 7 4
  35. ]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement