题解 | #取近似值#
取近似值
https://www.nowcoder.com/practice/3ab09737afb645cc82c35d56a5ce802a
using System;
using System.Collections;
class Program
{
public static void Main(string[] args)
{
string str=Console.ReadLine();
string []str1=str.Split('.');
string str2=str1[0];
string str3=str1[1];
int a=Convert.ToInt32(str2.ToString());
int b=Convert.ToInt32(str3[0].ToString());
if(b>=5)
{
Console.WriteLine(a+1);
}
else
{
Console.WriteLine(a);
}
}
}
using System.Collections;
class Program
{
public static void Main(string[] args)
{
string str=Console.ReadLine();
string []str1=str.Split('.');
string str2=str1[0];
string str3=str1[1];
int a=Convert.ToInt32(str2.ToString());
int b=Convert.ToInt32(str3[0].ToString());
if(b>=5)
{
Console.WriteLine(a+1);
}
else
{
Console.WriteLine(a);
}
}
}