问题描述
我们可以算出73! c或c ++中的值,不会丢失有效数字。
can we calculate the 73! value in c or c++ without loss of significant digits.
推荐答案
是的。我自己做的。
-
/ - Joona Palaste(pa*****@cc.helsinki.fi) - ------------芬兰-------- \
\-- -------------------- - 规则! -------- /
Yes. I''ve done it myself.
--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
是的。你去吧:
/ * homework.c * /
#include< stdio.h>
#include< string.h>
char f [] =" 4470115461512684340891257138125051110076800700282 9050"
" 1581908009237042210406718331701690368000000000000 0001" ;;
int main(无效)
{
f [strlen(f)-1] - ; / *计算73!从73!+ 1 * /
put(f);
返回0;
}
在c ++中它更容易,因为你可以省略void参数到main。
祝你好运,
Sidney
Yes. Here you go:
/* homework.c */
#include <stdio.h>
#include <string.h>
char f[] = "4470115461512684340891257138125051110076800700282 9050"
"1581908009237042210406718331701690368000000000000 0001";
int main(void)
{
f[strlen(f)-1]--; /* calculate 73! from 73!+1*/
puts(f);
return 0;
}
In c++ it''s even easier, since you can omit the void parameter to main.
Best regards,
Sidney
位数。
奇怪的是,口袋科学计算器的范围大于
C的长度或甚至是双精度数。你会注意到计算器不会计算73!它可以完成,但它需要编码(或获取)一种处理非常大数字的方法。
的人问这个措辞相当措辞的人可能希望
答案是不,但我不是一个心灵读者。
简而言之,我们*可以*做几乎任何我们可以在
中表达的数学问题。或者任何我们可以通过
数学运算序列来表示的方式。
digits.
Oddly enough, the range of a pocket scientific calculator is greater than
that of C for long or even double precision numbers. And you will note that
the calculator will not compute 73!. It could be done but it would require
coding (or acquiring) a method of dealing with very large numbers. The
person who asked that rather poorly worded question probably expects the
answer to be "no", but I am not a mind reader.
In short, we *can* do almost any mathematical problem we can formulate in
our mind. Or anything that we can conjure up a way to represent by a
sequence of mathematical operations.
这篇关于计算值73!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!