char[,] ch = { { '我', '是', '软' }, { '件', '工', '程' }, { '师', '啦', '!' } };
Console.WriteLine("{0}{1}{2}", ch[1, 1], ch[1, 2], ch[2, 0]);
for(int i=0;i<ch.GetLongLength(0);i++)
{
for (int j = 0; j < ch.GetLongLength(1); j++)
Console.Write(ch[i, j]);
}
Console.WriteLine("{0}{1}{2}", ch[1, 1], ch[1, 2], ch[2, 0]);
for(int i=0;i<ch.GetLongLength(0);i++)
{
for (int j = 0; j < ch.GetLongLength(1); j++)
Console.Write(ch[i, j]);
}
2017-07-26
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-07-26
代码没有办法过题,但是大家可以在VS上面进行编译看看运行结果!没有按照全部的要求去做,个人觉得这样做更有意义。分享一下思路。去学习一下课了。大家一起加油!
第三部分
avg = sum / score.Length;
Console.WriteLine("总:{0}平均:{1}",sum,avg);
for (int i = 0; i < score.Length; i++)
{
int a;
if (score[i] > avg)
{
a = score[i];Console.WriteLine("高于平均值的人有" + name[i]);
avg = sum / score.Length;
Console.WriteLine("总:{0}平均:{1}",sum,avg);
for (int i = 0; i < score.Length; i++)
{
int a;
if (score[i] > avg)
{
a = score[i];Console.WriteLine("高于平均值的人有" + name[i]);
第二部分代码
Console.Write("请输入第" + (i + 1) + "个num:");
score[i] = int.Parse(Console.ReadLine());
}
int sum = 0, avg;
for (int i = 0; i < score.Length; i++)
{
sum += score[i];
}
Console.Write("请输入第" + (i + 1) + "个num:");
score[i] = int.Parse(Console.ReadLine());
}
int sum = 0, avg;
for (int i = 0; i < score.Length; i++)
{
sum += score[i];
}
第一部分代码
string[] name = new string[5];
int[] score = new int[5];
for (int i = 0; i < name.Length; i++)
{
Console.Write("请输入第" + (i + 1) + "个name:");
string[] name = new string[5];
int[] score = new int[5];
for (int i = 0; i < name.Length; i++)
{
Console.Write("请输入第" + (i + 1) + "个name:");
static void Main(string[] args)
{
int year = 2015;//年份
Console.WriteLine(year%4);//求年份除以4的余数
}
{
int year = 2015;//年份
Console.WriteLine(year%4);//求年份除以4的余数
}
2017-07-24
数组长度为 4 、类型为 int ,所以第 11 行应该为:
int[] age = new int[4];
数组元素索引从 0 开始递增,所以第 13 - 16 行应该为:
age[0] = 18;
age[1] = 20;
age[2] = 23;
age[3] = 17;
第 18 行应该为:age[0],age[1],age[2],age[3]);
int[] age = new int[4];
数组元素索引从 0 开始递增,所以第 13 - 16 行应该为:
age[0] = 18;
age[1] = 20;
age[2] = 23;
age[3] = 17;
第 18 行应该为:age[0],age[1],age[2],age[3]);
2017-07-24
for (int x = 1; x <= 7; x++)
{
Console.Write(x);
if(y<X);
}
Console.WriteLine();//换行
{
Console.Write(x);
if(y<X);
}
Console.WriteLine();//换行
2017-07-24