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 arrays

NN--- edited this pageApr 18, 2012 ·4 revisions

Using arrays

  • Category: Arrays, Hash Tables and Dictionaries
  • Description: Create a histogram of the occurrences of particular letters
  • Code:
using System.Console;def results    =array('Z'+1-'A') :array[int];def data       ="The quick brown fox jumps over the lazy dog";foreach (cwhen c >='A' && c <='Z'in data.ToUpper()with i)  results[c :int-'A']++;foreach (cin ['A' ..'Z'])   WriteLine($"Number of '$c' characters = $(results[c - 'A' : int])");

Execution Result:

Number of 'A' characters = 1Number of 'B' characters = 1Number of 'C' characters = 1Number of 'D' characters = 1Number of 'E' characters = 3Number of 'F' characters = 1Number of 'G' characters = 1Number of 'H' characters = 2Number of 'I' characters = 1Number of 'J' characters = 1Number of 'K' characters = 1Number of 'L' characters = 1Number of 'M' characters = 1Number of 'N' characters = 1Number of 'O' characters = 4Number of 'P' characters = 1Number of 'Q' characters = 1Number of 'R' characters = 2Number of 'S' characters = 1Number of 'T' characters = 2Number of 'U' characters = 2Number of 'V' characters = 1Number of 'W' characters = 1Number of 'X' characters = 1Number of 'Y' characters = 1Number of 'Z' characters = 1

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

Clone this wiki locally


[8]ページ先頭

©2009-2025 Movatter.jp