1 Star 0 Fork 0

SkyDreamX/EFT2

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Program.cs 3.16 KB
一键复制 编辑 原始数据 按行查看 历史
SkyDreamX 提交于 2020-04-11 19:52 . first commit 2
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);
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C#
1
https://gitee.com/skydreamx/EFT2.git
[email protected]:skydreamx/EFT2.git
skydreamx
EFT2
EFT2
master

搜索帮助