G*7
2 楼
【 以下文字转载自 CS 讨论区 】
发信人: PharmD (夜里发呆), 信区: CS
标 题: 【灌水】数学大帝小时候
发信站: BBS 未名空间站 (Wed Sep 19 10:26:28 2012, 美东)
1785年,8岁的高斯在德国农村的一所小学里念一年级。
学校的老师是城里来的。他有一个偏见,总觉得农村的孩子不如城市的孩子聪明伶俐。
不过,他对孩子们的学习,还是严格要求的。他最讨厌在课堂上不专心听讲、爱做小动
作的学生,常常用鞭子敲打他们。孩子们倒爱听他的课,因为他经常讲一些非常有趣的
东西。
有一天,他出了一道算术题。他说:“你们算一算,1加2加3,一直加到100等于多少?
谁算不出来,就不准回家吃饭。” 说完,他就坐在椅子上,用目光巡视着趴在桌上演
算的学生。
不到一分钟的工夫,小高斯站了起来,手里举着小石板,说:“老师,我算出来了....
..”
没等小高斯说完,老师就不耐烦的说:“不对!重新再算!”
小高斯很快的检查了一遍,高声说:“老师,没错!”说着走下座位,把小石板伸到老
师面前。
老师低头一看,只见上面端端正正的写着正确答案,不禁大吃一惊。他简直不敢相信,
这样复杂的数学题,一个8岁的孩子,用不到一分钟的时间就算出了正确的得数。要知
道,他自己算了一个多小时,算了三遍才把这道题算对的。
只见小高斯的石板上工工整整地写着:
#include
using namespace std;
void main() {
int sum = 0;
for (int i = 1; i <= 100; i++) {
sum += i;
}
cout << sum << endl;
}
老师抡圆了就给了小高斯一个大嘴巴。
“又他妈的void,谁他妈的教你main()返回void的!这么小就不学好!”
发信人: PharmD (夜里发呆), 信区: CS
标 题: 【灌水】数学大帝小时候
发信站: BBS 未名空间站 (Wed Sep 19 10:26:28 2012, 美东)
1785年,8岁的高斯在德国农村的一所小学里念一年级。
学校的老师是城里来的。他有一个偏见,总觉得农村的孩子不如城市的孩子聪明伶俐。
不过,他对孩子们的学习,还是严格要求的。他最讨厌在课堂上不专心听讲、爱做小动
作的学生,常常用鞭子敲打他们。孩子们倒爱听他的课,因为他经常讲一些非常有趣的
东西。
有一天,他出了一道算术题。他说:“你们算一算,1加2加3,一直加到100等于多少?
谁算不出来,就不准回家吃饭。” 说完,他就坐在椅子上,用目光巡视着趴在桌上演
算的学生。
不到一分钟的工夫,小高斯站了起来,手里举着小石板,说:“老师,我算出来了....
..”
没等小高斯说完,老师就不耐烦的说:“不对!重新再算!”
小高斯很快的检查了一遍,高声说:“老师,没错!”说着走下座位,把小石板伸到老
师面前。
老师低头一看,只见上面端端正正的写着正确答案,不禁大吃一惊。他简直不敢相信,
这样复杂的数学题,一个8岁的孩子,用不到一分钟的时间就算出了正确的得数。要知
道,他自己算了一个多小时,算了三遍才把这道题算对的。
只见小高斯的石板上工工整整地写着:
#include
using namespace std;
void main() {
int sum = 0;
for (int i = 1; i <= 100; i++) {
sum += i;
}
cout << sum << endl;
}
老师抡圆了就给了小高斯一个大嘴巴。
“又他妈的void,谁他妈的教你main()返回void的!这么小就不学好!”
x*8
3 楼
青青老师的教程真仔细啊,看完俺这个花盲也可以种玫瑰了。:)
m*r
4 楼
J点?
o*n
5 楼
完全同意楼上意见,原来老师名字叫青青。
g*u
7 楼
这玫瑰养的真好,养眼!
h*4
8 楼
高斯大神肿么可以写i++呢 一定是假的
【在 G*****7 的大作中提到】![](/moin_static193/solenoid/img/up.png)
: 【 以下文字转载自 CS 讨论区 】
: 发信人: PharmD (夜里发呆), 信区: CS
: 标 题: 【灌水】数学大帝小时候
: 发信站: BBS 未名空间站 (Wed Sep 19 10:26:28 2012, 美东)
: 1785年,8岁的高斯在德国农村的一所小学里念一年级。
: 学校的老师是城里来的。他有一个偏见,总觉得农村的孩子不如城市的孩子聪明伶俐。
: 不过,他对孩子们的学习,还是严格要求的。他最讨厌在课堂上不专心听讲、爱做小动
: 作的学生,常常用鞭子敲打他们。孩子们倒爱听他的课,因为他经常讲一些非常有趣的
: 东西。
: 有一天,他出了一道算术题。他说:“你们算一算,1加2加3,一直加到100等于多少?
【在 G*****7 的大作中提到】
![](/moin_static193/solenoid/img/up.png)
: 【 以下文字转载自 CS 讨论区 】
: 发信人: PharmD (夜里发呆), 信区: CS
: 标 题: 【灌水】数学大帝小时候
: 发信站: BBS 未名空间站 (Wed Sep 19 10:26:28 2012, 美东)
: 1785年,8岁的高斯在德国农村的一所小学里念一年级。
: 学校的老师是城里来的。他有一个偏见,总觉得农村的孩子不如城市的孩子聪明伶俐。
: 不过,他对孩子们的学习,还是严格要求的。他最讨厌在课堂上不专心听讲、爱做小动
: 作的学生,常常用鞭子敲打他们。孩子们倒爱听他的课,因为他经常讲一些非常有趣的
: 东西。
: 有一天,他出了一道算术题。他说:“你们算一算,1加2加3,一直加到100等于多少?
C*g
9 楼
FarmD是什么?农业博士?
G*7
18 楼
码农用 i++,
int sum = 0;
for (int i = 1; i <= 100; i++) {
sum += i;
};
码工用
std::accumulate(boost::counting_iterator(1),
boost::counting_iterator(101),
0);
int sum = 0;
for (int i = 1; i <= 100; i++) {
sum += i;
};
码工用
std::accumulate(boost::counting_iterator
boost::counting_iterator
0);
H*g
21 楼
(1+100)*100/2
谢谢
谢谢
w*e
22 楼
大家小时候都是怎么算的?我小时候的算法是先算1+2+3+..9,然后用这个结果来简化
尾数的相加。比如11+12+13+...19=10*10+1+2+3+...9
尾数的相加。比如11+12+13+...19=10*10+1+2+3+...9
k*i
36 楼
最简单的方法显然是手机上买买提找面经啊
t*a
37 楼
高斯大神当然上LISP, HASKELL或者FACTOR之类
(apply + (range 1 101))
(apply + (range 1 101))
G*7
42 楼
your 码神 is not generic, which is the holly grail for both mathematicians
and devs.
the 码神 in my mind
would write a generic, lazy-evaluation based, expression template version of
sum, such that the sum of any arithmetic sequence would be evaluated using
the shortcut (first+last)*num_elem/2, while the sum over any other sequence
is performed through vectorized (and possibly OpenMP paralleled) element-by-
element summation.
this possibly involved overloaded comma operator and boost::counting
iterator.
cout << 1+,_arithmatic,+100 << endl; // prints 5050 by (1+100)*100/2
【在 a9 的大作中提到】![](/moin_static193/solenoid/img/up.png)
: 码神用
: printf("=%d",5050);
and devs.
the 码神 in my mind
would write a generic, lazy-evaluation based, expression template version of
sum, such that the sum of any arithmetic sequence would be evaluated using
the shortcut (first+last)*num_elem/2, while the sum over any other sequence
is performed through vectorized (and possibly OpenMP paralleled) element-by-
element summation.
this possibly involved overloaded comma operator and boost::counting
iterator.
cout << 1+,_arithmatic,+100 << endl; // prints 5050 by (1+100)*100/2
【在 a9 的大作中提到】
![](/moin_static193/solenoid/img/up.png)
: 码神用
: printf("=%d",5050);
k*i
43 楼
Nice!
of
using
sequence
by-
【在 G*****7 的大作中提到】![](/moin_static193/solenoid/img/up.png)
: your 码神 is not generic, which is the holly grail for both mathematicians
: and devs.
: the 码神 in my mind
: would write a generic, lazy-evaluation based, expression template version of
: sum, such that the sum of any arithmetic sequence would be evaluated using
: the shortcut (first+last)*num_elem/2, while the sum over any other sequence
: is performed through vectorized (and possibly OpenMP paralleled) element-by-
: element summation.
: this possibly involved overloaded comma operator and boost::counting
: iterator.
of
using
sequence
by-
【在 G*****7 的大作中提到】
![](/moin_static193/solenoid/img/up.png)
: your 码神 is not generic, which is the holly grail for both mathematicians
: and devs.
: the 码神 in my mind
: would write a generic, lazy-evaluation based, expression template version of
: sum, such that the sum of any arithmetic sequence would be evaluated using
: the shortcut (first+last)*num_elem/2, while the sum over any other sequence
: is performed through vectorized (and possibly OpenMP paralleled) element-by-
: element summation.
: this possibly involved overloaded comma operator and boost::counting
: iterator.
b*n
45 楼
原来肚皮舞有这么多码农
相关阅读
温泉山庄啊Iron man 3哪里跑!! 难怪这么多人想当摄影师(18禁)某教授的《形势与政策》课上用投影放Powerpoint,Re: 車票的故事 (转载)Re: 六四香港媒体造谣,有图有真相! (转载)宅男有三宝:科技,女优,人真好。型男有三宝:亲亲,抱抱,再推倒。腐女有三宝:意淫,淘宝,节日少。韩剧有三宝:车祸,癌症,医不好。周董有三宝:哎呦,不错,这个屌。克里斯蒂亚诺·邓 Gif4连发 (转载)闫凤娇报案笔录独家曝光(图文) (转载)解解这句英文天啊,如何在摄影师和未婚夫之间抉择啊? (转载)棒子拍的隋炀帝(转载)我本来不反党,看了党史才反党的 (转载)这个太牛了挨了一记大耳光,如果是你,该怎么办? (转载)听说满洲国的铁路系统很强悍 (转载)网站管理阶层对基督信仰论坛的决定和指导专贴 (转载)如果蛤蟆想吃天鹅肉,需要给天鹅一个理由(ZT)你敢说自己是JOKE PHD么?