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
int x = 2;
do
{
x++;
Console.Write(x+" ");
}
while(x>2&&x<=4);
}
do
{
x++;
Console.Write(x+" ");
}
while(x>2&&x<=4);
}
2017-08-29
for (int x=0; x<=12;x++ )//请填写代码
{
Console.WriteLine(x+" ");
}
{
Console.WriteLine(x+" ");
}
2017-08-29
int x = 1;
int sum = 0;//和,初始化为0
while (x <= 30)//循环条件
{
if (x%2==1)//筛选条件
sum += x;
x++;
}
Console.Write("1-30奇数的和:"+sum);
}
int sum = 0;//和,初始化为0
while (x <= 30)//循环条件
{
if (x%2==1)//筛选条件
sum += x;
x++;
}
Console.Write("1-30奇数的和:"+sum);
}
2017-08-29
switch (job)
{
case"局长":Console.Write("发双黄月饼"); break;
case"处长":Console.Write("发蛋黄月饼"); break;
case"科长":Console.Write("发枣泥月饼"); break;
default:Console.Write("发五仁月饼"); break;
}不要谢我
{
case"局长":Console.Write("发双黄月饼"); break;
case"处长":Console.Write("发蛋黄月饼"); break;
case"科长":Console.Write("发枣泥月饼"); break;
default:Console.Write("发五仁月饼"); break;
}不要谢我
2017-08-29
static void Main(string[] args)
{
string boy = "秀丽";//男孩名字
string girl = "伟强";//女孩名字
boy=boy+girl;
girl=boy-girl;
boy=boy-girl;
Console.WriteLine("男孩叫" + boy + " 女孩叫" + girl);
}
{
string boy = "秀丽";//男孩名字
string girl = "伟强";//女孩名字
boy=boy+girl;
girl=boy-girl;
boy=boy-girl;
Console.WriteLine("男孩叫" + boy + " 女孩叫" + girl);
}
2017-08-28