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]+",");
2016-10-14
static void Main(string[] args)
{
string [] name={"关羽","张飞","赵云","马超","黄忠"};
for(int i=0;i<name.Length;i++)
{
Console.Write(name[i]+",");
}
}
{
string [] name={"关羽","张飞","赵云","马超","黄忠"};
for(int i=0;i<name.Length;i++)
{
Console.Write(name[i]+",");
}
}
static void Main(string[] args)
{
//声明“职位”数组,初始化为:"经理","项目主管","技术总监","财务主管"
string[] job ={"经理","项目主管","技术总监","财务主管"};
for (int i = 0; i < job.Length ; i++)
{
Console.Write(job[i]);//打印职位
}
}
{
//声明“职位”数组,初始化为:"经理","项目主管","技术总监","财务主管"
string[] job ={"经理","项目主管","技术总监","财务主管"};
for (int i = 0; i < job.Length ; i++)
{
Console.Write(job[i]);//打印职位
}
}
2016-10-14
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]);
2016-10-14
for(int x=1;x<=7;x++)
{
for(int y=1;y<=7;y++)
{ if(x==y||x+y==8)
Console.Write("O");
else
Console.Write(".");
}
Console.WriteLine();
}
{
for(int y=1;y<=7;y++)
{ if(x==y||x+y==8)
Console.Write("O");
else
Console.Write(".");
}
Console.WriteLine();
}
static void Main(string[] args)
{
for (int y = 1; y <= 7; y++)
{
for (int x = 1; x <= y; x++)
{
Console.Write(x);
}
Console.WriteLine();//换行
}
}
{
for (int y = 1; y <= 7; y++)
{
for (int x = 1; x <= y; x++)
{
Console.Write(x);
}
Console.WriteLine();//换行
}
}
2016-10-14
static void Main(string[] args)
{
for (int x = 1; x < 10; x++)
{
if(x==3||x==8)
continue;//请添加代码,过滤3和8
Console.Write(x);
}
}
{
for (int x = 1; x < 10; x++)
{
if(x==3||x==8)
continue;//请添加代码,过滤3和8
Console.Write(x);
}
}
2016-10-14
static void Main(string[] args)
{
int x =2;
do
{
x++;
Console.Write(x+" ");
}
while(x>2&&x<=4);
}
{
int x =2;
do
{
x++;
Console.Write(x+" ");
}
while(x>2&&x<=4);
}
2016-10-14
static void Main(string[] args)
{
for (int x=1;x<=12 ;x++ )//请填写代码
{
Console.WriteLine(x+" ");
}
}
{
for (int x=1;x<=12 ;x++ )//请填写代码
{
Console.WriteLine(x+" ");
}
}
2016-10-14
static void Main(string[] args)
{
int x = 1;
int sum = 0;//和,初始化为0
while (x <= 30)//循环条件
{
if (x%2==1)//筛选条件
sum += x;
x++;
}
Console.Write("1-30奇数的和:"+sum);
}
{
int x = 1;
int sum = 0;//和,初始化为0
while (x <= 30)//循环条件
{
if (x%2==1)//筛选条件
sum += x;
x++;
}
Console.Write("1-30奇数的和:"+sum);
}
2016-10-14
int x;//循环计数变量
x=5;//行① 请填写计数变量的初始化语句
while (x>=1 )//行② 请填写循环条件
{
Console.Write("加油!");
x--;//行③ 请填写计数变量的自加语句
x=5;//行① 请填写计数变量的初始化语句
while (x>=1 )//行② 请填写循环条件
{
Console.Write("加油!");
x--;//行③ 请填写计数变量的自加语句
static void Main(string[] args)
{
int y = 5;
while (y>=1)//请输入
{
Console.Write(y+" ");
y--;//请输入
}
}
{
int y = 5;
while (y>=1)//请输入
{
Console.Write(y+" ");
y--;//请输入
}
}
2016-10-14
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;
}
2016-10-14
string text=(year%4)==0?"闰年":"平年";//请填写代码
2016-10-14