• R/O
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

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

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


Commit MetaInfo

Revision109 (tree)
Time2015-12-30 09:43:18
Authorbellyoshi

Log Message

Change Summary

Incremental Difference

--- tanosii/chap01/chap02/Program.cs (revision 108)
+++ tanosii/chap01/chap02/Program.cs (revision 109)
@@ -10,7 +10,7 @@
1010 {
1111 static void Main(string[] args)
1212 {
13- list8.start(args);
13+ list1.start(args);
1414 Console.ReadLine();
1515
1616 }
--- tanosii/chap01/chap02/list1.cs (revision 108)
+++ tanosii/chap01/chap02/list1.cs (revision 109)
@@ -11,38 +11,13 @@
1111 public static void start(string[] args)
1212 {
1313 int[] stoneWeights = new int[] { 7, 12, 5, 9, 17 };
14- int min = stoneWeights[0];
15- int max = stoneWeights[0];
16- int upper10Count = 0;
17- bool existupper12 = false;
18- int sum = 0;
19- foreach (int weight in stoneWeights)
20- {
21- sum += weight;
22- if (weight < min)
23- {
24- min = weight;
25- }
26- if (max < weight)
27- {
28- max = weight;
29- }
30- if (10 < weight)
31- {
32- upper10Count++;
33- }
34- if (12 < weight)
35- {
36- existupper12 = true;
37- }
38- }
39- double avrg = sum / stoneWeights.Count();
14+ var weightsOver10kg = stoneWeights.Where(c => c >= 10);
4015
41- Console.WriteLine($"10kg以上の石の数は{upper10Count}個です。");
42- Console.WriteLine($"最軽量の石の重さは{min}kgです。");
43- Console.WriteLine($"最重量の石の重さは{max}kgです。");
44- Console.WriteLine($"平均の石の重さは{avrg}kgです。");
45- if (existupper12)
16+ Console.WriteLine($"10kg以上の石の数は{weightsOver10kg.Count()}個です。");
17+ Console.WriteLine($"最軽量の石の重さは{weightsOver10kg.Min()}kgです。");
18+ Console.WriteLine($"最重量の石の重さは{weightsOver10kg.Max()}kgです。");
19+ Console.WriteLine($"平均の石の重さは{weightsOver10kg.Average()}kgです。");
20+ if (stoneWeights.Any(c => c == 12))
4621 {
4722 Console.WriteLine("重さ12kgの石は含まれます。");
4823 }