Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Distinct of the given array with each element occurence
//Rextester.Program.Main is the entry point for your code. Don't change it. //Microsoft (R) Visual C# Compiler version 2.9.0.63208 (958f2354) using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { int[] arr = {1,4,2,5,4,2,5,1,6,2,5,3,8,9,6 }; int[] fr = new int[arr.Length]; int visited = -1; for (int i = 0; i < arr.Length; i++) { int count = 1; for (int j = i + 1; j < arr.Length; j++) { if (arr[i] == arr[j]) { count++; fr[j] = visited; } } if (fr[i] != visited) fr[i] = count; } for (int i = 0; i < fr.Length; i++) { if (fr[i] != visited) Console.WriteLine(arr[i] + " Count is " + fr[i]); } } } }
run
|
edit
|
history
|
help
0
Homework4
JJ 2
SevenSevenSeven
abebe
Z_non_pow
601
Problem3 Binary
3D Array
Armstrong
sadxasxd