作业帮 > 综合 > 作业

编程,输入x,计算并输出下列分段函数f(x)的值,当x=10时,输出3x-11

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/18 18:32:10
编程,输入x,计算并输出下列分段函数f(x)的值,当x=10时,输出3x-11
基于c#的
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Please enter a number");
int a = int.Parse(Console.ReadLine());
if (a < 1)
{
Console.WriteLine(a);
}
else if (a >= 1 && a < 10)
{
Console.WriteLine(2 * a - 1);
}
else
{
Console.WriteLine(3 * a - 11);
}
Console.ReadKey();
}
}