代码拉取完成,页面将自动刷新
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace EFT2
{
class Program
{
public class User
{
private int id;
private string name;
private bool liberal_arts;
private int chinese;
private int math;
private int eng;
private int integrated;
public int Chinese { get => chinese; set => chinese = value; }
public int Math { get => math; set => math = value; }
public int Eng { get => eng; set => eng = value; }
public int Integrated { get => integrated; set => integrated = value; }
public int Id { get => id; set => id = value; }
public string Name { get => name; set => name = value; }
public bool Liberal_arts { get => liberal_arts; set => liberal_arts = value; }
}
public class Scoreval
{
}
static List<User> user = new List<User>
{
new User
{
Id = 1, Name = "张珊", Liberal_arts=false,Chinese= 127, Math =145,Eng= 122,Integrated= 289
},
new User
{
Id = 2, Name = "刘亮", Liberal_arts=true, Chinese=103,Math =145,Eng=122,Integrated=250
},
new User
{
Id = 3, Name = "薛贵", Liberal_arts=true, Chinese=136,Math =102,Eng=89,Integrated=189
},
new User
{
Id = 4, Name = "吴迪", Liberal_arts=true, Chinese=126,Math =98,Eng=140,Integrated=238
}
} ;
static void Main(string[] args)
{
//列举所有
var linq = from u in user select u;
Console.WriteLine("编号\t" + "姓名\t" + "文科\t" + "语文\t" + "数学\t" + "英语\t" + "综合");
foreach (var item in linq)
{
Console.WriteLine(
item.Id.ToString()+ "\t" + item.Name + "\t" + item.Liberal_arts.ToString()+ "\t" + item.Chinese+ "\t" + item.Math+ "\t" + item.Eng+ "\t" + item.Integrated);
}
Console.WriteLine("");
Console.WriteLine("==========筛选文科==========");
linq = from u in user where u.Liberal_arts == true select u;
Console.WriteLine("编号\t" + "姓名\t" + "文科\t" + "语文\t" + "数学\t" + "英语\t" + "综合");
foreach (var item in linq)
{
Console.WriteLine(
item.Id.ToString() + "\t" + item.Name + "\t" + item.Liberal_arts.ToString() + "\t" + item.Chinese + "\t" + item.Math + "\t" + item.Eng + "\t" + item.Integrated);
}
Console.WriteLine("");
Console.WriteLine("==========文科平均分==========");
var linq2 = user.Where(u => u.Liberal_arts == true).Average(a => a.Chinese+a.Math+a.Eng+a.Integrated);
Console.WriteLine("平均分为:{0}", linq2);
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。