Created
October 29, 2014 07:38
-
-
Save MeilCli/882f67bed1e3f8aac0fb to your computer and use it in GitHub Desktop.
Linq
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace CLinq { | |
class Program { | |
static void Main(string[] args) { | |
Console.Out.WriteLine("整数値をスペース区切りで入力してください"); | |
var v = Console.In.ReadLine().Split(' ',' ').Select(x => int.Parse(x));// var is IEnumerable<int> | |
Console.Out.WriteLine("平均値より大きい数 : {0}個",v.Where(x => x > v.Average()).Count()); | |
Console.Out.WriteLine("平均値より小さい数 : {0}個",v.Where(x => x < v.Average()).Count()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment