简单问题 关于 % 计算 我想做一个投票系统,但是不知道怎么计算投票 那位高手可以帮帮我啊总票数 5557 非常好 2000一般 1000很差 2557请问怎么计算我才知道 非常好,一般,很差 的百分比啊 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 把数据转换成 float 数据类型,再用/除去一下就可以了。 class MainClass { private static float good=0.8f;//优秀比例 private static float bad=0.3f;//差比例 public static void Main(string[] args) { int Ticket=5000;//总票数 Console.WriteLine(TP(3500,Ticket)); Console.ReadLine(); } private static string TP(float ticket,float TicketCount) { string RetVal="一般"; float t=ticket/TicketCount; if (t>good) RetVal="优秀"; if (t<bad) RetVal="差"; return RetVal; } } int verygood;int nornal;int bad;你原来是不是这样写的代码呀?写成这样不就成了?double verygood=0;//好 double nornal = 0;//一般 double bad = 0;//差 string 好; string 一般; string 差; double all = 0;//总投票 all = verygood + nornal + bad; //这中间是你取3样投票的标数的地方,如果没有代码,会出现0分母错误 if (all == 0) { 好 = "0%"; 一般 = "0%"; 差 = "0%"; } else { double bverygood = verygood / all * 100; double bnornal = nornal / all * 100; double bbad = bad / all * 100; 好 = bverygood.ToString("0.00") + "%"; 一般 = bnornal.ToString("0.00") + "%"; 差 = bbad.ToString("0.00") + "%"; } 如何实现点击文本框后,自动选中所有文字 这张图的容器是哪个???? 线程,异步,回调??? C#窗体疑问 菜鸟请教俩问题 .net中如何动态获得一个类的所有实例对象 急求正则表达式! 高分求解:vc代码如何改成c# 这几天脑子进水,关于怎么把webform.aspx.cs文件编译.dll的问题? 各位大虾,请教教小生,为什么在C#中这样调用API函数不起作用啊。。。。 选项卡删除了怎么办??? 跪求Developer Express的中文使用手册,或者哪个有什么使用心得的啊给兄弟看看嘛
{
private static float good=0.8f;//优秀比例
private static float bad=0.3f;//差比例
public static void Main(string[] args)
{
int Ticket=5000;//总票数
Console.WriteLine(TP(3500,Ticket));
Console.ReadLine();
}
private static string TP(float ticket,float TicketCount)
{
string RetVal="一般";
float t=ticket/TicketCount;
if (t>good)
RetVal="优秀";
if (t<bad)
RetVal="差";
return RetVal;
}
}
int nornal;
int bad;
你原来是不是这样写的代码呀?写成这样不就成了?
double verygood=0;//好
double nornal = 0;//一般
double bad = 0;//差
string 好;
string 一般;
string 差;
double all = 0;//总投票
all = verygood + nornal + bad; //这中间是你取3样投票的标数的地方,如果没有代码,会出现0分母错误
if (all == 0)
{
好 = "0%";
一般 = "0%";
差 = "0%";
}
else
{
double bverygood = verygood / all * 100;
double bnornal = nornal / all * 100;
double bbad = bad / all * 100; 好 = bverygood.ToString("0.00") + "%";
一般 = bnornal.ToString("0.00") + "%";
差 = bbad.ToString("0.00") + "%";
}