ans记录[begin,end,height]
inps=list(map(int,input().split(','))) ans=[] finish=[] for i in range(len(inps)): if i not in finish: is_find=False for j in range(i+1,len(inps)): if inps[j]>=inps[i]: ans.append([i,j,min(inps[i],inps[j])]) finish.extend([k for k in range(i+1,j)]) is_find=True break if not is_find and i!=len(inps)-1: finish.append(i) ans.append([i,i+1,min(inps[i],inps[i+1])]) sum=0 for i in ans: sum +=(i[1]-i[0])*i[2] print(sum)计算中位数懵了,哪位大佬可以回复一下怎么计算中位数么?
有一个表t_numbers,第一列为number数字,第二列为frequency出现的频率,计算中位数
create table t_numbers(number int, frequency int); insert into t_numbers(number,frequency) values(1,1); insert into t_numbers(number,frequency) values(2,3); insert into t_numbers(number,frequency) values(4,4);
全部评论
(0) 回帖