Programming 板


LINE

※ 引述《peggypiano (大N)》之铭言: : 这一题的题目我看不太懂QQ : 有人能帮忙解释一下吗? : 我就我所理解的先打出来,麻烦帮忙指正了谢谢>< : ------ : The value e^x can be approximated by the sum : 1 + x^1/1! + x^2/2! + x^3/3! +.........+ x^n/n! :   Write a program that takes a value x as input and outputs this sum for n : taken to be each of the values 1 to 100. : //Q1:让使用者可以输入x,并分别输出n=1(即1+x^1/1!),..,n=100(即1+...+x^100/100!) : 还是 输出n=1(即x^1/1!), n=2(即x^2/2!),...,n=100(即x^100/100!)呢? 第一个解释 (1+...+x^n/n! for n=1,2,...,100) : The program should also output e^x calculated using the predefined : function exp. The function exp is a predefined function such that exp(x) : returns an approximation to the value e^x. : //还要输出e^x的值(使用者输入之x, n为无限大)(收敛值?) : //Q2: predefined function exp,是指要我先写一个exp()出来吗? : The function exp is in the library with the header file cmath. Your program : should repeat the calculation for new values of x until the user says she or : he is through. : //Q3:这句我超不懂QQ 是跟我说在<cmath>里有exp可以参考的意思吗 囧 : 第2句我不懂他的意思,不是已经让user输入过x了吗@_@ repeat the calculation : 是? new value of x是? 直到user怎样呢QQ? Q2跟Q3是同一个问题 就是叫你顺便用内建的exp函式算值并输出, prototype定义在 cmath 里面 include就可以用了 "Your program should repeat ..." 这个跟 Q1 Q2 Q3 都无关 意思是你写的程式应该要 while (the user input a new `x` value) calculate e^x partial sum for n=1,2,...,100 and calculate exp(x) : Use variables of type double to store the factorials or you are likely to : produce integer overflow (or arrange your calculation to avoid any direct : calculation of factorials). : //Q4: 用double变数去储存factorials(n!的值吗?),不然可能会有整数 : 变数漏掉浮点数、无法进行有浮点数的除法计算的问题? 或是避免计算中直接去 : 计算factorials??这是什麽意思呢QQ 对 用douuble去存 n! 的值 不然 n! 会太大, int 存不下, 会跑出错的结果(undefined behavior) 或是计算中避免直接计算 n!, i.e. 避开这样的步骤 1. 计算 a := x^n 2. 计算 b ;= n! 3. 然後计算 c := a/b 懒得避开的话就用 double 来存 n! : 100 lines of output might not fit comfortably on : your screen. Output the 100 output values in a format that will fit all : 100 values on the screen. For example, you might output 10 lines with 10 : values on each line. : 请我每10行输出10个值? : 麻烦大家帮忙看看了 谢谢QQ 每一行输出 10 个值, 共 10 行(100个值) --



※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 118.166.48.166 ※ 编辑: suhorng 来自: 118.166.48.166 (07/17 12:45)
1F:推 peggypiano:太谢谢你了!!!! 1.175.137.110 07/17 13:36
2F:→ peggypiano:我想再问请user输入新的x是指和Q1是同 1.175.137.110 07/17 13:37
3F:→ peggypiano:一次吗 1.175.137.110 07/17 13:37
4F:→ peggypiano:所以题目的整体要求应该是: 1.175.137.110 07/17 13:37
5F:→ peggypiano:1. 请user输入x 2.列出n=1~100的e^x值 1.175.137.110 07/17 13:39
6F:→ peggypiano:3.引用exp()去求出e^x(n无限)的收敛值? 1.175.137.110 07/17 13:41
7F:→ suhorng:是 是同一个 而且要不断loop 140.112.16.131 07/17 17:51
8F:→ peggypiano:谢谢你喔!!!!:))) 1.175.137.110 07/19 12:21







like.gif 您可能会有兴趣的文章
icon.png[问题/行为] 猫晚上进房间会不会有憋尿问题
icon.pngRe: [闲聊] 选了错误的女孩成为魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一张
icon.png[心得] EMS高领长版毛衣.墨小楼MC1002
icon.png[分享] 丹龙隔热纸GE55+33+22
icon.png[问题] 清洗洗衣机
icon.png[寻物] 窗台下的空间
icon.png[闲聊] 双极の女神1 木魔爵
icon.png[售车] 新竹 1997 march 1297cc 白色 四门
icon.png[讨论] 能从照片感受到摄影者心情吗
icon.png[狂贺] 贺贺贺贺 贺!岛村卯月!总选举NO.1
icon.png[难过] 羡慕白皮肤的女生
icon.png阅读文章
icon.png[黑特]
icon.png[问题] SBK S1安装於安全帽位置
icon.png[分享] 旧woo100绝版开箱!!
icon.pngRe: [无言] 关於小包卫生纸
icon.png[开箱] E5-2683V3 RX480Strix 快睿C1 简单测试
icon.png[心得] 苍の海贼龙 地狱 执行者16PT
icon.png[售车] 1999年Virage iO 1.8EXi
icon.png[心得] 挑战33 LV10 狮子座pt solo
icon.png[闲聊] 手把手教你不被桶之新手主购教学
icon.png[分享] Civic Type R 量产版官方照无预警流出
icon.png[售车] Golf 4 2.0 银色 自排
icon.png[出售] Graco提篮汽座(有底座)2000元诚可议
icon.png[问题] 请问补牙材质掉了还能再补吗?(台中半年内
icon.png[问题] 44th 单曲 生写竟然都给重复的啊啊!
icon.png[心得] 华南红卡/icash 核卡
icon.png[问题] 拔牙矫正这样正常吗
icon.png[赠送] 老莫高业 初业 102年版
icon.png[情报] 三大行动支付 本季掀战火
icon.png[宝宝] 博客来Amos水蜡笔5/1特价五折
icon.pngRe: [心得] 新鲜人一些面试分享
icon.png[心得] 苍の海贼龙 地狱 麒麟25PT
icon.pngRe: [闲聊] (君の名は。雷慎入) 君名二创漫画翻译
icon.pngRe: [闲聊] OGN中场影片:失踪人口局 (英文字幕)
icon.png[问题] 台湾大哥大4G讯号差
icon.png[出售] [全国]全新千寻侘草LED灯, 水草

请输入看板名称,例如:Soft_Job站内搜寻

TOP