任何人都可以为我制作该程序! [英] Can anybody make that program for me pleaseeeeee!

查看:73
本文介绍了任何人都可以为我制作该程序!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您必须编写一个计算机程序,该程序将自身增加1/3的次数,并将结果与​​将1/3乘以1/3的次数进行比较.用½做同样的事情.
该程序将执行两次此算法,一次使用单精度(浮点数),一次使用双精度(双精度).这两个都将在一个程序中.确保您使用的计数器类型可以处理这些较大的数字.
您的程序将执行这些加法109次(十亿次).它打印出结果,每十次幂(10、100、1000等,最多10亿次),然后将1/3乘以自身的结果.不要使用定点输出结果.每个输出应赋予10的幂,到该点为止的1/3加到其结果,相加数的1/3乘以,最后两个数之差,再加上½的结果到该点为止,直到该点为止的相加数的1/2倍的乘积,以及最后两个数字之间的差.程序必须在此数据之前输出标题,以说明输出内容.记住要同时执行单精度和双精度.
确保在程序的开头有注释,其中包含您的姓名,作业编号3,日期和对该程序的简要说明.还要确保在程序中添加注释.确保正确阻止程序中的代码.注意输出的质量,它不应在整个屏幕上倾斜,而应放在整洁的列中(也许在输出语句中使用\ t).请记住,您仅在输出时执行乘法运算,而不要在循环中的每一遍都执行乘法运算.
需要考虑的事项:
1.您注意到½和1/3的结果之间有什么区别吗?
2.您是否注意到单精度和双精度结果之间有任何区别?

You have to write a computer program that will add 1/3 to itself a large number of times and to compare the result to multiplying 1/3 by the number of times 1/3 was added to itself. It is also to do the same thing with ½.
The program is to do this arithmetic twice, once using single precision (float) and once using double precision (double). Both of these will be in one program. Make certain you use a type for your counter that works with these large numbers.
Your program will do these additions 109 (1 billion) times. It is to print out the results, every power of ten times (10, 100, 1000, etc. up to 1 billion) along with the result of multiplying 1/3 to itself up to that point. Do NOT use fixed point to output the results. Each output should give the power of 10, the result from the addition of 1/3 to itself up to that point, the multiplication of 1/3 times the number of additions, the difference between these last two numbers, the result of adding ½ to itself up to that point, the multiplication of ½ times the number of additions up to that point, and the difference between these last two numbers. The program must output a header before this data explaining what the output is. Remember to do this for both single and double precision.
Make certain to have comments at the beginning of your program with your name, assignment number 3, date, and a brief explanation of the program. Also make certain to put comments within your program. Make certain to properly block the code in your program. Pay attention to the quality of your output, it should not be slopped all over the screen, but be in neat columns (perhaps use \t in the output statements). Remember you are only to do the multiplications when you output, do NOT do them every pass in the loop.
Items to think about:
1. Did you notice any difference between the results for ½ and 1/3?
2. Did you notice any difference between the results for single and double precision?

推荐答案

这听起来像是作业.

不幸的是,那些在此论坛上贡献时间来帮助您的人们对那些不屑一顾或懒得自己做事的人并不友善.

功课是你要学习的.

请尊重其他人的时间,并提出真正的问题.
This sounds like homework.

Unfortunately the folks who donate their time to help you in this forum do not look kindly to people who don''t bother or are too lazy to do things for themselves.

Homework is for you to learn.

Please respect the time of others and ask genuine questions.


在这里它不是这样的.

这是询问者的期望:
1. 先尝试您要做什么!您可能会发现它并不难.
2.制定看起来像问题/无法解决的问题.

试试看,告诉他们是否遇到问题.
成员将很乐意为您提供帮助.
It does not work like this here.

Here is what is expected of enquirers:
1. TRY first what you want to do! You may find that it''s not that hard.
2. Formulate what was done by you that looks like an issue/not working.

Try them and tell if you face issues.
Members will be more than happy to help like this.


如前所述,我们不会做您的作业.但这并不意味着我们根本不会提供帮助.

有了这堵墙,我可以想象您会感到内tim,难以上手.建议您单独关注每个段落,确保可以获取在计算机程序中工作的说明,并且如果确定已完成上一个段落,则仅继续下一个段落.

就是说,有些说明-特别是第一段-很难理解.该作业的主要目的是了解舍入误差的影响以及机器精度的限制.我将重新制定任务-也许您会更轻松地了解以下内容:

摘要
编写一个程序,使用重复的加法或乘法来计算一些值,然后打印结果.尝试使用不同的操作数和变量类型,然后比较这些选择的效果.

说明
1.a)使用类型float
的变量将值1/3相加100次 1.b)在添加10次和添加100次之后打印添加结果
2.使用类型float的变量,将值1/3乘以10,再乘以100,并打印这些结果
3.a)使用float
将值1/2加100次 3.b)在添加10次和添加100次后打印添加结果
4.使用float将1/2乘以10,再乘以100,然后打印
5.a)使用类型double
的变量将1/3乘以1000000000次 5.b)打印10、100、1000,...,1000000000次添加后的结果
6.计算并打印将1/3乘以10、100、1000,...,1000000000的结果.
7.a),b)和8 .:如上所述,使用1/2而不是1/3


尝试实施每个步骤,并确保其可以继续操作.
As pointed out, we won''t do your homework. but that doesn''t mean we won''t help at all.

Given this wall of text, I can imagine you feel intimdated and have trouble getting started. I suggest you focus on each paragraph individually, make sure you can get the instructions to work in a computer program, and only continue with the following paragraph if you''re sure you''re done with the previous.

That said, some of the instructions - specifically the first paragraph - are hard to understand. The main goal of this homework is to understand the effect of rounding errors, and the limits of machine precision. I''ll reformulate the task - maybe you will have an easier time understanding this:

Summary
Write a program that calculates some values using repeated addition or multiplication, and print the results. Try different operands, and different variable types, and compare the effects of these choices.

Instructions
1.a) Add the value 1/3 for 100 times, using variables of type float
1.b) print the result of the addition after 10 and after 100 additions
2. Multiply the value 1/3 by 10, and by 100, using variables of type float, and print these results
3.a) Add the value 1/2 for 100 times using float
3.b) print the result of the addition after 10 and after 100 additions
4. Multiply 1/2 by 10 and by 100 using float, and print that
5.a) Add 1/3 for 1000000000 times, using variables of type double
5.b) print the results after 10, 100, 1000, ... , 1000000000 additions
6. Calculate and print the results of multiplying 1/3 by 10, 100, 1000, ... , 1000000000 .
7.a) and b) and 8.: as above, using a base value of 1/2 instead of 1/3


Try to implement each individual step and make sure it works before continuing.


这篇关于任何人都可以为我制作该程序!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆