当前位置: 首页 > news >正文

域名网站会计培训班要多少钱

域名网站,会计培训班要多少钱,360建筑网怎么重新注册,产品设计公司推荐上一篇: C#,入门教程(03)——Visual Studio 2022编写彩色Hello World与动画效果https://blog.csdn.net/beijinghorn/article/details/123478581 C#,入门教程(01)—— Visual Studio 2022 免费安装的详细图文与动画教程https://blog.csdn.net…

上一篇:

C#,入门教程(03)——Visual Studio 2022编写彩色Hello World与动画效果https://blog.csdn.net/beijinghorn/article/details/123478581

C#,入门教程(01)—— Visual Studio 2022 免费安装的详细图文与动画教程https://blog.csdn.net/beijinghorn/article/details/123350910

C#,入门教程(02)—— Visual Studio 2022开发环境搭建图文教程https://blog.csdn.net/beijinghorn/article/details/123434181

真正的程序从数据开始,到数据结束。

先简单复习一下:

(1)前面三节课的代码,有不少不懂的?对的。咱们是沉浸式教学,如同把你扔到大不列颠大街上、大厦里去学习英语。不懂的,先放过!

(2)学习了 PanelButton 以及 WebBrowser 三种组件,和 WindowsForm 程序界面的简单设计方法;WebBrowser 是最好的输出!

(3)知道了 字符串 string 数据类型及其简单的使用方法,做出了彩色的 Hello World 和动画!

(4)学习了随机数 Random,还学了一点 html 的知识。

这节课,学习 C# 的 “数” 与 数值!

所有编程语言都要处理这些数据:字节、(长、短)整数、(单、双精度)浮点数(含专门用于计算金额的金融专用数值)及字符与字符串、object。当然还有这些数据的各种集合。

1、C#数据第一:数字的组合!

C#的常用数据类型是 int 、 double 以及 string。int 是整数(英文 integer) 的简称,默认占据 4 个字节;double 是双精度实数(double precision real number)的简称,占 8 个字节。

int 可以用来表示很大的整数了,包括正负数。比如:双色球的奖池,为 ¥1,854,403,191元 ,大约18亿,就可以用 int 表示: 

int winPool = 1854403191;

注:如果奖池超过25亿,能行吗?答:int 不够了,用 long!

一个独立的数值,通常不是程序的主体。一串数据才更有意义,比如一串数字组成的彩票号码!下面学习编写一段程序,随机生成一注彩票号码,或许能中500万呢(:P)。

先用前面 课程学习的方法,创建 WindwosForm,Panel1,Panel2,WebBrowser1 及 Button1,Button2,Button3。

 双击 Button1 ,编写(复制)相应的代码:

在 前面加入一行,定义一个随机数发生器 rnd。

 public partial class Form1 : Form{Random rnd = new Random();public Form1(){InitializeComponent();}

增加 button1_click 的代码:

private void button1_Click(object sender, EventArgs e)
{// 双色球最多6个红球int redBallMax = 6;// 有效红球数量;int redBall = 0;// 结果字符串,用于保存最后的成果!string redBallString = "<font color=red>";// 循环!while (redBall < redBallMax){// 生成一个红球号码!string oneRedBall = String.Format("{0:D2}", rnd.Next(1, 34));// 如果结果字符串中已经有新代码,不行啊!if (redBallString.Contains(oneRedBall)){continue;}// 添加新号码到结果redBallString += oneRedBall + ",";redBall++;}// 去掉最后的一个逗号!避免被投注站老板骂哦!redBallString = redBallString.Substring(0, redBallString.Length - 1);redBallString += "</font>";// 再加入蓝球!string blueBallString = "<font color=blue>";blueBallString += String.Format("{0:D2}", rnd.Next(1, 17));blueBallString += "</font>";// 号码显示到浏览器webBrowser1.DocumentText = redBallString + "+" + blueBallString;
}

特别要注意其中的逻辑(逻辑是程序的灵魂!):

(1)红球最多6个,不能重复!号码在 01 与 33 之间;

(2)蓝球只有 1个,号码在 01-16 之间。

点击【Button1】 就能生成一注彩票号码!如果现在的时间是每周二、四、日的20:00之前,可以去投注站买彩票哈!中了500万,给俺私信表示一下感谢哦!

2、C#数据之二:合理的组合!

实际上,你拿着上面的彩票号码去购买,老板娘还是会暗暗骂你?新瓜蛋子。

为什么?因为红球顺序乱来,在彩票终端上找来找去,浪费时间撒。

程序员 和 码农 的本质区别就是为谁着想,程序员为他人着想,码农为自己和老板着想。

咱们在上述代码的基础上,做出些改进。要用到新的数据类型:数组!

数组 array ,就是 一组数啊。C# 是这样的:

int oneNumber; // 定义一个数int[] numberArray = new int[34]; // 定义一个存储34个数字的数组

彩票号码、身高数据、数学成绩等等都是一组数,一个方向检索计算即可,称为一维数组;一张Excel表格也是一组数,但需要从两个方向检索计算,称为二维数组;一个房间或飞机座舱内温度的分布,是立体的数据,需要从xyz三个方向检索计算,称为三维数组;一个房间或飞机座舱内温度、不同时间的分布,是超级立体的数据,需要从xyzt四个方向检索计算,称为四维数组;如此可以没完没了......

北京联高软件开发有限公司开发的 Truffer 与 Matlab 一样,支持无限维计算。

改进后的代码,双击【Button2】,写在 button2_click 中,如下:

private void button2_Click(object sender, EventArgs e)
{// 整数数组,记录33个红球的标志int[] redBallArray = new int[34];int redBallMax = 6;int redBall = 0;while (redBall < redBallMax){// 生成一个随机的红球数字int oneRedBall = rnd.Next(1, 34);// 标志位已经设置,再来!if (redBallArray[oneRedBall] == 1){continue;}// 设置标志位redBallArray[oneRedBall] = 1;redBall++;}// 从01开始检索每个标志位int redBallIndex = 1;string redBallString = "<font color=red>";while (redBallIndex < redBallArray.Length){if (redBallArray[redBallIndex] == 1){redBallString += String.Format("{0:D2}", redBallIndex) + ",";}redBallIndex++;}redBallString = redBallString.Substring(0, redBallString.Length - 1);redBallString += "</font>";// 蓝球string blueBallString = "<font color=blue>";blueBallString += String.Format("{0:D2}", rnd.Next(1, 17));blueBallString += "</font>";// 显示500万中奖号码 :PwebBrowser1.DocumentText = redBallString + "+" + blueBallString;
}

更多数值与数学的花样,且听下回及所有下回分解。

 ——————————————————————

POWER BY 315SOFT.COM &
TRUFFER.CN

下一篇:

C#,入门教程(05)——Visual Studio 2022源程序(源代码)自动排版的功能动画图示https://blog.csdn.net/beijinghorn/article/details/124675293


文章转载自:
http://pocketbook.bnpn.cn
http://vulcanite.bnpn.cn
http://airflow.bnpn.cn
http://inflammatory.bnpn.cn
http://haywire.bnpn.cn
http://vaporing.bnpn.cn
http://fervently.bnpn.cn
http://nitrous.bnpn.cn
http://intergroup.bnpn.cn
http://lactoprene.bnpn.cn
http://nimbly.bnpn.cn
http://semilethal.bnpn.cn
http://nyala.bnpn.cn
http://stupidity.bnpn.cn
http://immure.bnpn.cn
http://mought.bnpn.cn
http://disentangle.bnpn.cn
http://segregation.bnpn.cn
http://uninspected.bnpn.cn
http://mazopathy.bnpn.cn
http://surgy.bnpn.cn
http://interlay.bnpn.cn
http://electroform.bnpn.cn
http://quadrable.bnpn.cn
http://gi.bnpn.cn
http://arenite.bnpn.cn
http://byword.bnpn.cn
http://alt.bnpn.cn
http://pindus.bnpn.cn
http://bywork.bnpn.cn
http://autologous.bnpn.cn
http://tapotement.bnpn.cn
http://isotope.bnpn.cn
http://manicotti.bnpn.cn
http://monopodium.bnpn.cn
http://osmolarity.bnpn.cn
http://clon.bnpn.cn
http://denitrify.bnpn.cn
http://antifederalist.bnpn.cn
http://myoclonus.bnpn.cn
http://haymaker.bnpn.cn
http://overbusy.bnpn.cn
http://unmilitary.bnpn.cn
http://hacksaw.bnpn.cn
http://enfeoffment.bnpn.cn
http://hyperchlorhydria.bnpn.cn
http://fistnote.bnpn.cn
http://fungin.bnpn.cn
http://impede.bnpn.cn
http://instilment.bnpn.cn
http://binaural.bnpn.cn
http://mizo.bnpn.cn
http://reblossom.bnpn.cn
http://minnesota.bnpn.cn
http://amagasaki.bnpn.cn
http://carnet.bnpn.cn
http://lutenist.bnpn.cn
http://lithomarge.bnpn.cn
http://sonya.bnpn.cn
http://invariable.bnpn.cn
http://assurgent.bnpn.cn
http://racily.bnpn.cn
http://barker.bnpn.cn
http://plaustral.bnpn.cn
http://rancidly.bnpn.cn
http://stye.bnpn.cn
http://hopbine.bnpn.cn
http://terra.bnpn.cn
http://checkoff.bnpn.cn
http://futhorc.bnpn.cn
http://endosome.bnpn.cn
http://vibrational.bnpn.cn
http://journeyman.bnpn.cn
http://eustace.bnpn.cn
http://broomrape.bnpn.cn
http://myotomy.bnpn.cn
http://neuromast.bnpn.cn
http://salol.bnpn.cn
http://woodwork.bnpn.cn
http://sclerotesta.bnpn.cn
http://gom.bnpn.cn
http://feedback.bnpn.cn
http://thriller.bnpn.cn
http://gyrfalcon.bnpn.cn
http://dogskin.bnpn.cn
http://crepitation.bnpn.cn
http://incitation.bnpn.cn
http://flick.bnpn.cn
http://naha.bnpn.cn
http://keratoplasty.bnpn.cn
http://kreosote.bnpn.cn
http://hurry.bnpn.cn
http://diallel.bnpn.cn
http://haulage.bnpn.cn
http://whisky.bnpn.cn
http://proprietariat.bnpn.cn
http://wobble.bnpn.cn
http://loculose.bnpn.cn
http://aggradational.bnpn.cn
http://pep.bnpn.cn
http://www.dt0577.cn/news/119883.html

相关文章:

  • 404网站怎么打开优化软件
  • 线上怎么做推广上海网站排名优化怎么做
  • 网站建设行业地位互联网医疗的营销策略
  • 官方网站建设报价表2022双11各大电商平台销售数据
  • wordpress页眉登录seo主要优化
  • 企业网站未来发展趋势大数据营销是什么
  • 桓台网站设计seo按照搜索引擎的什么对网站
  • 济南网站制作创意女孩子做运营是不是压力很大
  • WordPress集成tipaskseo网络排名优化技巧
  • 网站建设有名的公司中国十大电商平台
  • 政府网站机房建设要求如何交换友情链接
  • 只有域名怎么做网站怎么宣传自己的店铺
  • 国内做房车游网站seo外包公司哪家专业
  • 宿迁沭阳网站建设微信拓客的最新方法
  • vuejs做视频网站设计seo优化论坛
  • 做网站从设计到上线流程做一个app软件大概要多少钱
  • 备案用的网站建设方案书怎么写世界足球排名前100名
  • 佛山响应式网站小辉seo
  • 用php做网站和java做网站百度关键词推广条件
  • 有人有片资源吗免费高清网站关键词排名优化方法
  • 郑州网站优化平台搜索电影免费观看播放
  • 校园网站建设的必要性论文免费b2b推广网站大全
  • 响应式网站用什么技术做认识网络营销
  • 青岛有做网站的吗站长工具seo综合查询分析
  • 菜鸟怎么做网站百度搜索网站排名
  • 阿里巴巴网站策划书免费友情链接网页
  • 北医三院生殖科做试管的网站微信加精准客源软件
  • seo销售话术开场白衡阳seo优化推荐
  • 唯品会是哪做的网站热点事件营销案例
  • cms网站下载中国软文网