HKGalden科技臺
發表文章發起投票
program jj求救
我想隨機出50個生字,再計每個生字出左幾多次,應該點

program test;
var  x,i,range:integer;
     cha:char;
     s:array[1..50] of string;
     count:array['A'..'Z'] of char;
begin
randomize;
     for x:=1 to 50 do
     begin
     s[x]:=chr(random(26)+65);
     write(s[x]);    (隨機出字)
     end;
         for x:=1 to 50 do     (我想做s[1],s[2]...s[50] loop)
         for cha:='A' to 'Z' do    (係每個s[x] loop入面再check 26次, a to z)
         begin       (下面就問題黎啦)
              if s[x]=count[cha] then
(上面個行都好似有d問題, 直接write(s[x])又出到字,但到哩到就check唔到係咪佢地之間係咪等於)
         [#ff0011]count[cha]:=(count次數應該set係邊同埋點先可以count到?) + 1;[/#ff0011]
         end;
     for x:=1 to 50 do
     begin
     write(s[x]);
     write(count[cha]);
     end;
readln;
end.  
Good1Bad0
2014/03/17, 9:21:51 晚上
本貼文共有 0 個回覆
此貼文已鎖,將不接受回覆
發表文章發起投票