avatar
c*o
2
我终于,不自觉地走近你
在午夜仍残余的思念里
不肯睡去
如果爱你,是一种惩罚
我会在心里,画着你的影子
每一笔,偿还你给过的呢喃细语
怨恨离愁
我已银丝渐露,岁月盈头
亲爱的
既然爱你是我的必经之路
在我老去之前
再爱我一次吧
avatar
r*y
3
【 以下文字转载自 Java 讨论区 】
发信人: romancity (山顶一枝草), 信区: Java
标 题: javascript
发信站: BBS 未名空间站 (Mon Oct 3 13:28:42 2011, 美东)
I have a file 1.txt
//1.txt
A B
B C
D E
E F
G H
I J
two letters in each line are in same group. So for the file above
A B C is in one group
D E F is in second group
G H is in third group
I J is in the fourth group
I need to use javascript to get the output below:
There are 4 groups:
group 1: A, B, C
group 2: D, E, F
group 3: G, H
group 4: I, J
How to write the javascript code ? Thanks a lot
avatar
f*r
4
股版炒船股还炒的起劲,估计要被套死了
avatar
C*r
5
爱与恨
流过了不眠的青春。
也染白了渐稀的银丝。
如果我是你,
我不后悔,
因为没有爱,
那是啥滋味?

【在 c**o 的大作中提到】
: 我终于,不自觉地走近你
: 在午夜仍残余的思念里
: 不肯睡去
: 如果爱你,是一种惩罚
: 我会在心里,画着你的影子
: 每一笔,偿还你给过的呢喃细语
: 怨恨离愁
: 我已银丝渐露,岁月盈头
: 亲爱的
: 既然爱你是我的必经之路

avatar
X*r
6
You sure you want to use JavaScript? Which environment you're
running JS in? Say, how do you read a file?

【在 r*******y 的大作中提到】
: 【 以下文字转载自 Java 讨论区 】
: 发信人: romancity (山顶一枝草), 信区: Java
: 标 题: javascript
: 发信站: BBS 未名空间站 (Mon Oct 3 13:28:42 2011, 美东)
: I have a file 1.txt
: //1.txt
: A B
: B C
: D E
: E F

avatar
s*t
8
蛮有情绪。加一个积分

【在 c**o 的大作中提到】
: 我终于,不自觉地走近你
: 在午夜仍残余的思念里
: 不肯睡去
: 如果爱你,是一种惩罚
: 我会在心里,画着你的影子
: 每一笔,偿还你给过的呢喃细语
: 怨恨离愁
: 我已银丝渐露,岁月盈头
: 亲爱的
: 既然爱你是我的必经之路

avatar
r*y
9
thanks a lot. I read the homework again and find that I can use any language.
I may try linux shell script

【在 X****r 的大作中提到】
: You sure you want to use JavaScript? Which environment you're
: running JS in? Say, how do you read a file?

avatar
i*o
10
用node.js,这个东西可以替代很多perl,bash在做的事。现在要自己下载,估计以后
的linux都会包括吧。

【在 X****r 的大作中提到】
: You sure you want to use JavaScript? Which environment you're
: running JS in? Say, how do you read a file?

avatar
a*y
11
用perl挺好的,读入一行后,用split(' ',$myline)把行分成2份放进一个array,然后比
较上一个array的第二个元素和这一个array的第一个元素是否相等,if yes,合并成一个
array.

【在 r*******y 的大作中提到】
: thanks a lot. I read the homework again and find that I can use any language.
: I may try linux shell script

avatar
r*y
12
A B
C B
in this case A, B, C are also in same group
I think the time complexity is a big problem here.
I want to use c++ now

【在 a***y 的大作中提到】
: 用perl挺好的,读入一行后,用split(' ',$myline)把行分成2份放进一个array,然后比
: 较上一个array的第二个元素和这一个array的第一个元素是否相等,if yes,合并成一个
: array.

avatar
t*t
13
http://en.wikipedia.org/wiki/Disjoint-set_data_structure
i dunno why you focus on programming language while dealing with this
typical algorithm problem

【在 r*******y 的大作中提到】
: A B
: C B
: in this case A, B, C are also in same group
: I think the time complexity is a big problem here.
: I want to use c++ now

avatar
i*o
14
There are only 27 letters, where is the time complexity? All you need is to
start eith 27 empty pointers. The time for this operation is most likely O(n
).

★ 发自iPhone App: ChineseWeb - 中文网站浏览器

【在 r*******y 的大作中提到】
: A B
: C B
: in this case A, B, C are also in same group
: I think the time complexity is a big problem here.
: I want to use c++ now

avatar
r*y
15
thanks a lot.
The problem is that it is not just about letters. A, B, C stands names
and the data may be huge

to
(n

【在 i*****o 的大作中提到】
: There are only 27 letters, where is the time complexity? All you need is to
: start eith 27 empty pointers. The time for this operation is most likely O(n
: ).
:
: ★ 发自iPhone App: ChineseWeb - 中文网站浏览器

avatar
t*t
16
i thought the number of letters is 26, no?...

to
(n

【在 i*****o 的大作中提到】
: There are only 27 letters, where is the time complexity? All you need is to
: start eith 27 empty pointers. The time for this operation is most likely O(n
: ).
:
: ★ 发自iPhone App: ChineseWeb - 中文网站浏览器

avatar
i*o
17
and I always thought it's 27!
And I proved that using gdb:
(gdb) p 'z'-'a'
$2 = 25
Now we know gdb is the best tool ever! I found no other way in the world to
give me the number of alphabets in just one line of code.

【在 t****t 的大作中提到】
: i thought the number of letters is 26, no?...
:
: to
: (n

avatar
i*o
18
Then you are right, javascript is not suitable for this.

【在 r*******y 的大作中提到】
: thanks a lot.
: The problem is that it is not just about letters. A, B, C stands names
: and the data may be huge
:
: to
: (n

avatar
t*t
19
didn't it print 25? so it's really 25?

to

【在 i*****o 的大作中提到】
: and I always thought it's 27!
: And I proved that using gdb:
: (gdb) p 'z'-'a'
: $2 = 25
: Now we know gdb is the best tool ever! I found no other way in the world to
: give me the number of alphabets in just one line of code.

avatar
i*o
20
haha, you cant trick me on this one, its really 26:)

★ 发自iPhone App: ChineseWeb - 中文网站浏览器

【在 t****t 的大作中提到】
: didn't it print 25? so it's really 25?
:
: to

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。