Skip to content

Instantly share code, notes, and snippets.

@MeilCli
Created October 29, 2014 07:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MeilCli/882f67bed1e3f8aac0fb to your computer and use it in GitHub Desktop.
Save MeilCli/882f67bed1e3f8aac0fb to your computer and use it in GitHub Desktop.
Linq
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