大神们给跪,再没有我明天死定了
pascal吧
全部回复
仅看楼主
level 3
ppennydope 楼主
给QB什么的也行,给我做三道题。
1、随机生成100个数。求其中低于平均分的是哪几个数,值分别是多少。
2、随机生成100个数,求其中偶数的个数
3、随机生成10个数,删除其中最高最低数
大神们求解,我会兑现诺言的,做出来的留下QQ号码[惊讶]
2013年03月16日 13点03分 1
level 3
ppennydope 楼主
求解[爱心]
2013年03月16日 13点03分 2
level 3
ppennydope 楼主
来人呐[瀑布汗~][88]
2013年03月16日 13点03分 3
level 9
哇哈。。。
水题还有QB。。。
2013年03月16日 13点03分 7
[惊讶]给跪
2013年03月16日 13点03分
15QB行么。。我上课没好好听[委屈]
2013年03月16日 13点03分
不用跪,我也是弱菜
2013年03月16日 13点03分
代码我贴下面吧
2013年03月16日 13点03分
level 9
var
a:array[1..10000] of longint;
i,sum:longint;
ave:real;
begin
randomize;
for i:=1 to 100 do begin
a[i]:=random(maxint)+1;
sum:=sum+a[i];
end;
ave:=sum/100;
for i:=1 to 100 do
if a[i]<ave then writeln(i,' ',a[i]);//如果这个数小于平均数,输出序号和值
end.
2013年03月16日 13点03分 8
[啊!]大神这是pascalMe
2013年03月16日 13点03分
a[i]:=random(maxint)+1; //随机产生1~32767的数
2013年03月16日 13点03分
sum表示所有数的和
2013年03月16日 13点03分
ave表示平均数
2013年03月16日 13点03分
level 9
var
x,total,i:longint;
begin
randomize;
for i:=1 to 100 do begin
x:=random(maxint)+1;
if x mod 2=0 then total:=total+1;//如果被2除余数为0,也就是能被2整除,计数器+1
end;
writeln('Total=',total);
end.
2013年03月16日 13点03分 9
我真的爱死你了。。
2013年03月16日 13点03分
这是第二题
2013年03月16日 13点03分
level 9
第三题有些题意不清,删除最高最低数,然后输出剩下的8个数么
2013年03月16日 13点03分 10
en
2013年03月16日 13点03分
level 7
话说随机生成数字我也不会啊。。。看来我要好好学习了。。
2013年03月16日 13点03分 11
这个在竞赛中应该用不到吧,顺便orz提高一等第三的
2013年03月16日 13点03分
level 9
第三题稍微等一会儿哦
2013年03月16日 13点03分 12
恩恩
2013年03月16日 13点03分
level 9
你们排序教过吗
2013年03月16日 13点03分 13
level 9
var
a:array[1..10] of longint;
i,j,t:longint;
begin
randomize;
for i:=1 to 10 do a[i]:=random(maxint)+1;
for i:=1 to 9 do
for j:=9 downto i do
if a[j]>a[j+1] then begin
t:=a[j];a[j]:=a[j+1];a[j+1]:=t;
end;//冒泡排序
for i:=2 to 9 do write(a[i],' ');
writeln;
end.
2013年03月16日 13点03分 14
是不是那个把第一个数抽出来放到一个临时变量里然后都往前?
2013年03月16日 13点03分
谢谢,好人一生平安[开心]
2013年03月16日 13点03分
以后有什么要帮忙的我能做一定帮你
2013年03月16日 13点03分
回复 pp290777182 :这么也不能这么说,可以看看排序有关的内容,楼下的方法比我的精妙,不排序也可以
2013年03月16日 13点03分
level 7
话说。。。这随机出的100个数。。应该是输入吧。。。。哪有自己random的。。。这样就没法测程序是否正确了、、、
话说。。。会排序都好做。。。
1. 可以开[0..110,1..2] 的数组,存num{数值}和id{位置},求和及平均值,排序,遍历找出比平均值大的序号{i} 输出 1 to i-1 的 id 和 num ;
2.直接O(1) odd()
3.开数组记录数值及相应的boolean{初值设成true},遍历找到最大值,最小值序号,设成false
输出true的数
好吧。。。算法不一定最减。。。也该够了吧。。。。
2013年03月16日 13点03分 15
分析的有道理,膜拜大神
2013年03月16日 13点03分
回复 可否考虑q :这是在黑我吗。。。。
2013年03月16日 13点03分
好吧2. 应该是O(N)。。遍历。。。时间复杂度没学好。。。
2013年03月16日 13点03分
咋能说是黑呢
2013年03月16日 13点03分
level 9
排序算法传送门 https://tieba.baidu.com/p/2153678890
2013年03月16日 13点03分 16
谢谢谢谢,我要给你生孩子[花心]
2013年03月16日 13点03分
level 9
另:如果是照15L所说,请将所有的随机数生成内容改为读入
2013年03月16日 13点03分 17
level 9
哎呀,一不小心似乎搞错了。。。
希望楼主来没睡。。。
2013年03月16日 14点03分 18

2013年03月16日 14点03分
回复 可否考虑q :我没睡。。。
2013年03月16日 14点03分
回复 pp290777182 :还在吗
2013年03月16日 14点03分
回复 可否考虑q :在么[啊]
2013年03月16日 14点03分
level 9
var
a:array[1..10000] of longint;
i,max,maxx,min,minx:longint;
begin
randomize;min:=maxint;max:=-maxint;
for i:=1 to 10 do a[i]:=random(maxint)+1;
for i:=1 to 10 do begin
if a[i]<min then begin min:=a[i];minx:=i;end;
if a[i]>max then begin max:=a[i];maxx:=i;end;
end;
for i:=1 to 10 do if (i<>minx)and(i<>maxx) then write(a[i],' ');
end.
这才是正确的。。。
我错了,愧对楼主一片感激[我错了]
2013年03月16日 14点03分 19
level 9
题意是“剩下的8个数据不排序”错看成“剩下的8个数据排序”了。
真心诚意地向楼主说一声抱歉
2013年03月16日 14点03分 20
。。在的在的,我还要对你说谢谢,抱歉个毛
2013年03月16日 14点03分
回复 pp290777182 :一时的没留意啦。。。[委屈]
2013年03月16日 14点03分
level 9
楼主还在么?
2013年03月16日 14点03分 21
level 9
2013年03月16日 14点03分 22
在的= - 少年不早了睡觉吧[haha]
2013年03月16日 14点03分
呵呵[生日快乐]
2013年03月16日 14点03分
回复 可否考虑q :[委屈]在么
2013年03月30日 05点03分
回复 pp290777182 :有一道冒泡排序题看都看不懂哇[爱心]
2013年03月30日 05点03分
level 11
第二题好简单= =
2013年03月17日 00点03分 23
1 2 尾页