if (salary > price && salary - price >= 200){
Console.Write("买手机没问题,还有多!");
}
else if (salary > price){
Console.Write("还行吧,买了吃西北风");
}
else{
Console.Write("买个篮子");
}
Console.Write("买手机没问题,还有多!");
}
else if (salary > price){
Console.Write("还行吧,买了吃西北风");
}
else{
Console.Write("买个篮子");
}
其实就是分组找字的代表数字。数字是从0开始,有三组,分别为0,1,2;然后每一组有三个字,每个字的顺序就是0,1,2.所以,举个例子,如工字,在第二组中的第二个子,即1,1(第一个都是0)
2017-09-01
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]);