string[] names = {...};
int[] scores = {...};
int index = 0, Sum = 0, Ave;
for (int i=0; i<scores.Length; i++)
{
Sum+=scores[i];
}
Ave=Sum/scores.Length;
Console.WriteLine("平均分是{0},高于平均分的有:",Ave);
for (int i=0; i<scores.Length;i++)
{
if(scores[i]>Ave)
{
index=i;
Console.Write(names[index]+" ");
}
}
int[] scores = {...};
int index = 0, Sum = 0, Ave;
for (int i=0; i<scores.Length; i++)
{
Sum+=scores[i];
}
Ave=Sum/scores.Length;
Console.WriteLine("平均分是{0},高于平均分的有:",Ave);
for (int i=0; i<scores.Length;i++)
{
if(scores[i]>Ave)
{
index=i;
Console.Write(names[index]+" ");
}
}
string[] job =new string[4]{"经理","项目主管","技术总监","财务主管"};
for (int i = 0; i <job.Length ; i++)
{
Console.WriteLine(job[i]);//打印职位
}
}
}
}
for (int i = 0; i <job.Length ; i++)
{
Console.WriteLine(job[i]);//打印职位
}
}
}
}
2017-08-31
string[,]A = {
{"吴松","89"},
{"钱东宇","90"}, ……
};
int max = 0;
for (int i=1; i<A.GetLongLength(0); i++) {
if (int.Parse(A[max,1]) < int.Parse(A[i,1])) {
max = i;
}
}
Console.WriteLine("分数最高的是{0},分数是{1}",A[max,0],A[max,1]);
{"吴松","89"},
{"钱东宇","90"}, ……
};
int max = 0;
for (int i=1; i<A.GetLongLength(0); i++) {
if (int.Parse(A[max,1]) < int.Parse(A[i,1])) {
max = i;
}
}
Console.WriteLine("分数最高的是{0},分数是{1}",A[max,0],A[max,1]);
int[] score = new int[] {89,39,100,51,94,65,70 };//分数
Console.Write("不及格的有:");
for (int i = 0; i < score.Length ; i++)
{
if(score[i]<60 )//筛选条件
Console.Write(score[i]+",");
}
Console.Write("不及格的有:");
for (int i = 0; i < score.Length ; i++)
{
if(score[i]<60 )//筛选条件
Console.Write(score[i]+",");
}
2017-08-29
int[] age =new int[4] ;//声明并初始化长度为4的整形数组
//为数组元素赋值
age[0] = 18;
age[1] = 20;
age[2] = 23;
age[3] = 17;
Console.WriteLine("四名同学的年龄是:{0}、{1}、{2}、{3}",
age[ 0],age[1 ],age[2 ],age[3 ]);
}
//为数组元素赋值
age[0] = 18;
age[1] = 20;
age[2] = 23;
age[3] = 17;
Console.WriteLine("四名同学的年龄是:{0}、{1}、{2}、{3}",
age[ 0],age[1 ],age[2 ],age[3 ]);
}
2017-08-29