E20 Ex 12 + 13
This commit is contained in:
parent
62432e655b
commit
dbf7abb9eb
@ -25,8 +25,15 @@ namespace Exercises_C_Sharp.E20_Lists
|
||||
static List<string> Meth(List<string> lis, char c)
|
||||
{
|
||||
/*Code START*/
|
||||
List<string> tempList = [];
|
||||
|
||||
return new List<string>();
|
||||
foreach(var element in lis)
|
||||
if(!element.Contains(c))
|
||||
tempList.Add(element);
|
||||
|
||||
return tempList;
|
||||
//ODER:
|
||||
return lis.Where(k => !k.Contains(c)).ToList();
|
||||
/*Code ENDE*/
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
namespace Exercises_C_Sharp.E20_Lists
|
||||
{
|
||||
@ -20,9 +21,49 @@ namespace Exercises_C_Sharp.E20_Lists
|
||||
static List<int> Meth(List<int> lis)
|
||||
{
|
||||
/*Code START*/
|
||||
var newList = MakeKehrwertList(lis);
|
||||
newList.Sort();
|
||||
newList = MakeKehrwertList(newList);
|
||||
|
||||
return new List<int>();
|
||||
return newList;
|
||||
|
||||
//ODER:
|
||||
lis.Sort((k, l) => MakeKehrwert(k).CompareTo(MakeKehrwert(l)));
|
||||
return lis;
|
||||
|
||||
/*Code ENDE*/
|
||||
}
|
||||
static List<int> MakeKehrwertList(List<int> list)
|
||||
{
|
||||
List<int> temp = [];
|
||||
foreach(var element in list)
|
||||
temp.Add(MakeKehrwert(element));
|
||||
return temp;
|
||||
}
|
||||
|
||||
static int MakeKehrwert(int i)
|
||||
{
|
||||
int res = 0;
|
||||
i *= 10;
|
||||
|
||||
while(i / 10 != 0)
|
||||
{
|
||||
i /= 10;
|
||||
res *= 10;
|
||||
res += i % 10;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
static int MakeKehrwertString(int i)
|
||||
{
|
||||
string newI = i.ToString();
|
||||
string temp = "";
|
||||
|
||||
for(int k = newI.Length - 1; k >= 0; k--)
|
||||
temp += newI[k];
|
||||
|
||||
return Convert.ToInt32(temp);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user