This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace ITHS1._3 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
List<int> a = new List<int>() { 1,3,5}; | |
List<int> b = new List<int>() { 2, 4, 6, 8 }; | |
List<int> newList = Zip(a, b); | |
newList.ForEach(item => Console.Write(item)); | |
Console.WriteLine(); | |
} | |
public static List<int> Zip(List<int> l1, List<int> l2) | |
{ | |
List<int> newList = new List<int>(); | |
int max = l1.Count; | |
if(l2.Count > max) | |
{ | |
max = l2.Count; | |
} | |
for(int i = 0; i < max; i++) | |
{ | |
if(i < l1.Count) | |
{ | |
newList.Add(l1[i]); | |
} | |
if (i < l2.Count) | |
{ | |
newList.Add(l2[i]); | |
} | |
} | |
return newList; | |
} | |
class ZipList<T> | |
{ | |
public List<T> l { get; set; } | |
public ZipList(List<T> l) | |
{ | |
this.l = l; | |
} | |
public static List<T> operator +(ZipList<T> a, ZipList<T> b) | |
{ | |
// Zip code here | |
return null; | |
} | |
public static List<T> operator -(ZipList<T> a, ZipList<T> b) | |
{ | |
// Unzip code here | |
return null; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment