• R/O
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

練習用です。いろんなものがごちゃまぜです。


Commit MetaInfo

修订版188 (tree)
时间2016-04-16 15:34:51
作者bellyoshi

Log Message

(empty log message)

更改概述

差异

--- tanosii/chap01/chap05/Program.cs (revision 187)
+++ tanosii/chap01/chap05/Program.cs (revision 188)
@@ -1,13 +1,36 @@
11 using System;
2+using System.Collections.Generic;
3+using System.Linq;
24
3-
45 namespace chap05
56 {
67 class Program
78 {
9+ //データを1つ読み取る
10+ private static int read()
11+ {
12+ for (;;)
13+ {
14+ string s = Console.ReadLine();
15+ if (s == null) return 0;
16+ int r;
17+ if (int.TryParse(s, out r))
18+ {
19+ return r;
20+ }
21+ Console.WriteLine("数値として解釈できません。再入力してください");
22+ }
23+ }
824 static void Main(string[] args)
925 {
10- Class16.start();
26+ var list = new List<int>();
27+ for (;;)
28+ {
29+ int r = read();
30+ if (r == 0) break;
31+ list.Add(r);
32+ }
33+ Console.WriteLine(list.Average());
1134 Console.Read();
1235 }
1336 }