| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 825 人关注过本帖
标题:求助:为什么一精确到分程序就不准了
只看楼主 加入收藏
xiao2hero
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2014-4-8
结帖率:100%
收藏
 问题点数:0 回复次数:1 
求助:为什么一精确到分程序就不准了
[local]1[/local]
图片是运行结果
如下代码:
using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace lingqian
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            double a, b, c, count = 0;
            a = double.Parse(textBox1.Text);
            b = double.Parse(textBox2.Text);
            textBox3.Text = (b - a).ToString();
            c = double.Parse(textBox3.Text);
            while (c >= 100)
            {
                c -= 100;
                count++;
            }
                textBox4.Text = count.ToString();
            int zx = 0;
            while(c<100 && c>=50)
            {
               
                c -= 50;
                zx++;
            }
            textBox5.Text =zx .ToString();
            int zc = 0;
            while (c < 50 && c >= 20)
            {

                c -= 20;
                zc++;
            }
            textBox6.Text = zc.ToString();
            int asd = 0;
            while (c < 20 && c >= 10)
            {

                c -= 10;
                asd++;
            }
            textBox7.Text = asd.ToString();
            int ad = 0;
            while (c < 10 && c >= 5)
            {

                c -= 5;
                ad++;
            }
            textBox8.Text = ad.ToString();
            int vb = 0;
            while (c < 5 && c >= 2)
            {

                c -= 2;
                vb++;
            }
            textBox9.Text = vb.ToString();
            int bn = 0;
            while (c < 2 && c >= 1)
            {

                c -= 1;
                bn++;
            }
            textBox10.Text = bn.ToString();
            int mn = 0;
            while (c < 1 && c >= 0.5)
            {

                c -= 0.5;
                mn++;
            }
            textBox11.Text = mn.ToString();
            int ty = 0;
            while (c < 0.5 && c >= 0.2)
            {

                c -= 0.2;
                ty++;
            }
            textBox12.Text = ty.ToString();
            int rt = 0;
            while (c < 0.2 && c >= 0.1)
            {

                c -= 0.1;
                rt++;
            }
            textBox13.Text = rt.ToString();
            int yu = 0;
            while (c < 0.1 && c >= 0.05)
            {

                c -= 0.05;
                yu++;
            }
            textBox14.Text = yu.ToString();
            int ui = 0;
            while (c < 0.05 && c >= 0.02)
            {

                c -= 0.02;
                ui++;
            }
            textBox15.Text = ui.ToString();
            int oi = 0;
            while (c < 0.02 && c >= 0.01)
            {

                c -= 0.01;
                oi++;
            }
            textBox16.Text = oi.ToString();

            
        }


        private void button2_Click(object sender, EventArgs e)
        {
            textBox1.Text = "";
            textBox2.Text = "";
            textBox3.Text = "";
            label4.Text = "";
        }

    }
}
搜索更多相关主题的帖子: private public double 图片 
2015-05-20 12:20
ares945
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2015-6-15
收藏
得分:0 
浮点数的问题
2015-06-16 11:10
快速回复:求助:为什么一精确到分程序就不准了
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.038730 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved