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);
}
2018-03-22
int x=1;
bool a = ++x * x > 3;
bool b =x<3 ;//请赋值
Console.WriteLine(a==b);
bool a = ++x * x > 3;
bool b =x<3 ;//请赋值
Console.WriteLine(a==b);
2018-03-21
Console.WriteLine(true||false);//输出True
Console.WriteLine(true&&false);//输出False
Console.WriteLine(!false);//输出True
Console.WriteLine(true&&false);//输出False
Console.WriteLine(!false);//输出True
2018-03-21
static void Main(string[] args)
{
//声明“职位”数组,初始化为:"经理","项目主管","技术总监","财务主管"
string[] job =new string[4]{"经理","项目主管","技术总监","财务主管"};
for (int i = 0; i < job.Length ; i++)
{
Console.Write(job[i]);//打印职位
}
{
//声明“职位”数组,初始化为:"经理","项目主管","技术总监","财务主管"
string[] job =new string[4]{"经理","项目主管","技术总监","财务主管"};
for (int i = 0; i < job.Length ; i++)
{
Console.Write(job[i]);//打印职位
}
2018-03-20
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();//换行
}
}
2018-03-19
for (int x = 1; x < 10; x++)
{
if(x==3||x==8)//请添加代码,过滤3和8
continue;
Console.Write(x);
}
{
if(x==3||x==8)//请添加代码,过滤3和8
continue;
Console.Write(x);
}
2018-03-19