Not a member of Pastebin yet?
                        Sign Up,
                        it unlocks many cool features!                    
                - int[] a = { 5, 3, 1, -1, -3, 3, 9, -4 };
 - int teller = 0;
 - Console.WriteLine("vul een getal in");
 - int input = int.Parse(Console.ReadLine());
 - int tellerTwee = 0;
 - bool check = false;
 - foreach(int getal in a)
 - {
 - if (getal == input)
 - {
 - tellerTwee++;
 - check = true;
 - }
 - }
 - int[] indexcheck = new int[tellerTwee];
 - int indexchecklocation = 0;
 - if (check == true)
 - {
 - foreach(int index in a)
 - {
 - if (index == input)
 - {
 - indexcheck[indexchecklocation] = teller;
 - indexchecklocation++;
 - }
 - teller++;
 - }
 - Console.Write($"{input} is gevonden op index ");
 - foreach(int output in indexcheck)
 - {
 - Console.Write($"{output}, ");
 - }
 - }
 - else
 - {
 - Console.WriteLine("niet gevonden");
 - }
 
Advertisement
 
                    Add Comment                
                
                        Please, Sign In to add comment