求:计算一个数,结果必须是整数且个位数为0且大于原来的结果 本帖最后由 daisyding1984 于 2013-02-24 15:12:24 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 double a = 243.0; int b = 3; int r = (int)(((int)a / (double)10 / (double)b) + 0.9999) * 10; using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace ConsoleApplication1{ class Program { static void Main(string[] args) { double[] a = { -100.00, -1.0, 0.0, 29, 30, 31, 200.00, 243, 243.0, 269.99, 270.00, 270.01, 300.00, 302.0 }; int b = 3; Func<double, int, int> foo = (x, y) => (int)((x / (double)10 / (double)y) + 0.99999) * 10; foreach (double d in a) Console.WriteLine("{0}\t{1}", d, foo(d, b)); } }}-100 -20-1 00 029 1030 1031 20200 70243 90243 90269.99 90270 90270.01 100300 100302 110Press any key to continue . . . js读取元素位置 【100分】c#如何用正则去掉URL里面的参数? xp系統,用iis發布asp網站問題!急 弄了个小博客,VS的内置Server可以打开.IIS上却不行. vs.2003 下如何把.HTML作为资源文件编译到 dll中,让用户看不到 .html文件 关于Mp3文件的ID3v1标签的格式错误地方指正!首先非常感谢原作者,给我非常大的帮助! ItemColumns中的Label如何使用<%# %> 帮忙看看 微信公众平台自定义菜单的创建 如何做一个属性调用? 求一正则,100分奉上------------ .NET架构
int b = 3;
int r = (int)(((int)a / (double)10 / (double)b) + 0.9999) * 10;
using System.Collections.Generic;
using System.Linq;
using System.Text;namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
double[] a = { -100.00, -1.0, 0.0, 29, 30, 31, 200.00, 243, 243.0, 269.99, 270.00, 270.01, 300.00, 302.0 };
int b = 3;
Func<double, int, int> foo = (x, y) => (int)((x / (double)10 / (double)y) + 0.99999) * 10;
foreach (double d in a)
Console.WriteLine("{0}\t{1}", d, foo(d, b));
}
}
}-100 -20
-1 0
0 0
29 10
30 10
31 20
200 70
243 90
243 90
269.99 90
270 90
270.01 100
300 100
302 110
Press any key to continue . . .