G***G 发帖数: 16778 | 1 当k等于3时,实现3个for嵌套
K=3
for
for
for
endfor
endfor
endfor
当k=n时,实现n个for嵌套
请问如何实现? |
|
G***G 发帖数: 16778 | 2 当k等于3时,实现3个for嵌套
K=3
for
for
for
endfor
endfor
endfor
当k=n时,实现n个for嵌套
请问如何实现? |
|
K****n 发帖数: 5970 | 3 是不是可以写一个程序,这个程序自动写程序,你让它写几个for,它就写几个 for
for i in range(n):
print ' ' * 4 * i + 'for'
endfor
for i in range(n):
print ' ' * 4 * (n - i - 1) + 'endfor'
endfor
用 stdout 把 print 放到一个文件里,然后点击开始键,看到确认弹出菜单后,点击
确认键 |
|
z*****n 发帖数: 7639 | 4 suppose there are N points denoted as (1,...,N)
for i=1:N-1
for j=i+1:N
if(distance(i,j)<=d)
put link(i,j) in the set;
endif
endfor
endfor |
|
b******y 发帖数: 9224 | 5
我喜欢pascal的begin, end这种语法,做compiler的时候很方便。我原先编写一个简单
的template engine的时候就碰到过这个问题, 比如说,如果是像c/java这样的,
for (...){
}
就不如搞成这样的:
for (...)
endfor
因为有了endfor,和for对应工整,写compiler的时候就很好写了。
当然,我的compiler知识也是自学的,没用过啥yacc, lex等,都是自己手动编写的
recursive descent parsing。 |
|
x*****w 发帖数: 8 | 6 line()=0
foreach Mesh
for i=1,3
line(node1,node2)++
endfor
endfor
if(line<2) line is boundary
connect all line seg |
|
x*****w 发帖数: 8 | 7 line()=0
foreach Mesh
for i=1,3
line(node1,node2)++
endfor
endfor
if(line<2) line is boundary
connect all line seg |
|
G*******s 发帖数: 76 | 8 要是你的字符串'b1'中的'1'也是动态生成的,也是一样的。类似很多其他语言里的根据
变量名字符串做个宏替换得到真正的变量。
pro test
b1 = [1.,2.,3.]
for j = 1, 1 do begin
str_of_var = 'b' + strtrim(string(j),2)
endfor
for i = 0, n_elements(b1) -1 do begin
r = execute ( 'b_tmp = ' + str_of_var + '[' + strtrim(string(i),2) +
']' )
print, b_tmp
endfor
end |
|
c*******h 发帖数: 1096 | 9 i suggest you do the following:
1. compute Y(i,k) = \sum_j X(i,j)*X(j,k) for all i,k in whatever nasty way
2. sum = 0
3. for i = 1:n
4. for k = 1:n
5. sum += Y(i,k)*X(i,k)
6. endfor
7. endfor
the bottleneck is line 1 |
|
g*******y 发帖数: 1930 | 10 int current_k = N; //global
void VC(int k, int start_v){
if(all_edge_covered(G) && k
current_k = k;
return;
}
if(k == current_k - 1) return; //剪枝
for(; start_v<=N; start_v++){
if(!edge_list[start_v].empty()){ //剪枝
list temp_edge_list = edge_list[start_v];
clear_edge(start_v,G);
VC(k+1, start_v+1);
if(curent_k == k+1) return; //剪枝
reset_edge(start_v,temp_edge_list,G);
}//endif
}//endfor
}//endVC |
|
r******n 发帖数: 170 | 11 一直没弄请怎么解这题,正好从topcoder tutorial上看到有相关讲解:
http://community.topcoder.com/tc?module=Static&d1=tutorials&d2=
不过还是没太清楚,这个伪码里的J=1是怎么选出来的?是直接选结束时间最早的那个
事件吗?记得版上似乎有讨论过,不过没翻出来。哪位知道在哪里吗?
Let N denote the number of activities and
{I} the activity I ( 1 <= I <= N )
For each {I}, consider S[I] and F[I] its starting and finishing time
Sort the activities in the increasing order of their finishing time
- that is, for every I < J we must have F [I] <= F [J]
// A denotes the set of the activities that will be... 阅读全帖 |
|
|
f***c 发帖数: 338 | 13 问题很简单,不知道在这里问是否合适。Django
后台服务器发送数据
data=[['1',1],['2',2],['3',3]]
如果用html的直接显示,没有问题。
{% for row in data %}
{{ row }}
{% endfor %}
但是我需要用Flot做图,jquery接收后,
data变成
data = [['1',1],['2',2],['3 ',3]]
即‘被escape成 '。
如何使jquery看到的data也是['1',1]而不是['1',1].
谢谢! |
|
a*******r 发帖数: 7558 | 14 来自主题: Programming版 - IDL一问 I have data arrays such as b1, b2, b3,...b100...
To do operations like b2/b1, b3/b1,...., I first do this:
FOR i=1, n DO BEGIN
my_data='b'+strtrim(string(i),1)
ENDFOR
Now the string my_data has become b1, b2,..., but how to
convert the string my_data to reference array data b1, b2...?
There must be such a conversion in IDL but I haven't found,
please help. 3x. |
|
f***c 发帖数: 338 | 15 【 以下文字转载自 BuildingWeb 讨论区 】
发信人: franc (笨◎), 信区: BuildingWeb
标 题: 问个jquery处理字符串的问题
发信站: BBS 未名空间站 (Tue Jun 3 00:19:33 2014, 美东)
问题很简单,不知道在这里问是否合适。Django
后台服务器发送数据
data=[['1',1],['2',2],['3',3]]
如果用html的直接显示,没有问题。
{% for row in data %}
{{ row }}
{% endfor %}
但是我需要用Flot做图,jquery接收后,
data变成
data = [['1',1],['2',2],['3 ',3]]
即‘被escape成 '。
如何使jquery看到的data也是['1',1]而不是['1',1].
谢谢! |
|
a*******r 发帖数: 7558 | 16 来自主题: Computation版 - IDL一问 my data array are b1, b2, b3,...b100...
To do operations like b2/b1, b3/b1,...., I first do this:
for i=1, n do begin
my_data='b'+strtrim(string(i),1)
endfor
Now the string my_data has become b1, b2,..., but how to
convert this string to reference data b1, b2...? |
|
a*******r 发帖数: 7558 | 17 3x
my data array are b1, b2, b3,...b100...
To do operations like b2/b1, b3/b1,...., I first do this:
for i=1, n do begin
my_data='b'+strtrim(string(i),1)
endfor
Now the string my_data has become b1, b2,..., but how to
convert the string my_data to the actual data b1, b2...? |
|
G*******s 发帖数: 76 | 18 pro test
b1 = [1.,2.,3.]
for i = 0, n_elements(b1) -1 do begin
r = execute ( 'b_tmp = b1[' + strtrim(string(i),2) + ']' )
print, b_tmp
endfor
end |
|