Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Using System.Collections.Generic.Dictionary

NN--- edited this pageApr 11, 2012 ·5 revisions

Using System.Collections.Generic.Dictionary

  • Category: Arrays, Hash Tables and Dictionaries
  • Description: Create a histogram of the occurrences of particular unicode characters using a dictionary.
  • Code:
using Nemerle.Collections;using System.Console;def tab = Hashtable(30);def data ="The quick brown fox jumps over the lazy dog";foreach (cin data)  tab[c] = tab.GetValueOrDefault(c)+1;foreach ((k, v)in tab.KeyValuePairs)  WriteLine($"Number of '$k' characters = $v");

  • Execution Result:
Number of 'T' characters = 1Number of 'h' characters = 2Number of 'e' characters = 3Number of ' ' characters = 8Number of 'q' characters = 1Number of 'u' characters = 2Number of 'i' characters = 1Number of 'c' characters = 1Number of 'k' characters = 1Number of 'b' characters = 1Number of 'r' characters = 2Number of 'o' characters = 4Number of 'w' characters = 1Number of 'n' characters = 1Number of 'f' characters = 1Number of 'x' characters = 1Number of 'j' characters = 1Number of 'm' characters = 1Number of 'p' characters = 1Number of 's' characters = 1Number of 'v' characters = 1Number of 't' characters = 1Number of 'l' characters = 1Number of 'a' characters = 1Number of 'z' characters = 1Number of 'y' characters = 1Number of 'd' characters = 1Number of 'g' characters = 1

[Copyright ©](Terms of use, legal notice)

Clone this wiki locally


[8]ページ先頭

©2009-2025 Movatter.jp