c# 输入一个一位正数的四舍五入 , int b = Convert.ToInt32(a);这提示插入字符串格式不正确
usingSystem;usingSystem.Collections.Generic;usingSystem.Text;namespaceConsoleApplicat...
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("请输入一个正数:");
string a = Console.ReadLine();
int b = Convert.ToInt32(a);
double c = Convert.ToInt32(a);
if (c - b >= 0.5)
{
b = b + 1;
}
else
{
b = b;
}
Console.WriteLine(b);
}
}
} 展开
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("请输入一个正数:");
string a = Console.ReadLine();
int b = Convert.ToInt32(a);
double c = Convert.ToInt32(a);
if (c - b >= 0.5)
{
b = b + 1;
}
else
{
b = b;
}
Console.WriteLine(b);
}
}
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询