#region 找出100以内与7有关的数并打印:
public static void Print()
{
int sum = 0;
Console.WriteLine("100以内与7有关的数有:");
for (int i = 1; i < 100; i++)
{
if (i % 7 == 0)
{
sum++;
Console.Write(i + " ");
}
else if (i % 10 == 7)
{
sum++;
Console.Write(i + " ");
}
}
}
#endregion
#region 输入一个正整数,求1~这个数的阶乘
public static void Factorial(int a)
{
int result = 1;
for (int i = 1; i <= a; i++)
{
result = result * i;
}
Console.WriteLine(result);
}
#endregion
#region 一个游戏,前20关是每一关自身的分数,,21-30关每一关是10分,31-40关,每一关是20分,41-49关,每一关是30分,50关,是100分,输入你现在闯到的关卡数,求你现在拥有的分数。两种做法:if嵌套for for嵌套if
public static void Mark(int a)
{
int sum = 0;
if (a < 21)
{
for (int i = 1; i <=a; i++)
{
sum = sum + i;
}
}
else if (a < 31)
{
sum=210+(a-20)*10;
}else if(a < 41)
{
sum=210+100+(a-20)*20;
}else if (a<50)
{
sum=210+100+200+(a-40)*30;
}else if (a == 50)
{
sum = 210 + 100 + 200 + 9 * 30 + 100;
}
Console.WriteLine($"你的分数为{sum}");
}
#endregion