再顺便帮俺看一下我写的这个东西,有问题多多提出,一定感谢,function CharSort(var AStirng:String):Boolean;
对传入的字符串AStirng中的ASCI字串按ASCII顺序进行从大到小排序,如果改变AStirng,则返回TRUE,否则返回FALSE;function charsort(var astring:string):boolean;
 var 
   str,str2:string;
   t,i,j:integer;//t为字符串长度;i,j为循环变量;
   c:char;//C为单个字符;
   b:boolean; //b为结果; 
  begin
    str:=astring;
    b:=falsh;//初始值为falsh;
    t:=length(str);//获得长度;
    setlength(str2,t);
    for i:=1 to t do  
for j:=i+1 to t do
         begin
 if chr(str[i])<chr(str[j]) then
    begin
     c:=str[j];str[j]:=str[i];str[i]:=c;
     b:=true;
            end;
         end;               
         str2:=str2+str[i];
        end;
   print("改变后字符串",str2);
   return(b);   
end; var 
   s:string;
   bb:boolean;
 begin
  readln(s);
  print("初始字符串",s);
  bb:=charsort(s);
 end;

解决方案 »

  1.   

    这一百分也太难了吧,但不是不能实现,
    数据结构
    Type
      MyMoney=Record
       MoneyName  :string[5];
       MoneyValue :integer;//存储分比如1代表1分0.01元;
       MoneyNum   :integer;//钱币剩余数量;
             End;
    TheMoney : Array[1..10] of MyMoney;
    初始化;oncreate();
    Begin
      TheMoney[1].MoneyName  := '¥100';
      TheMoney[1].MoneyValue :=  10000
      TheMoney[1].Num        :=  100;//这一项自己定;
       .......
       .......
       .......
     
      TheMoney[10].MoneyName  := '¥0.05';
      TheMoney[10].MoneyValue :=  5
      TheMoney[10].Num        :=  100;//这一项自己定;
       
    End;
    当输入150元时,如Edit1.text := 150;
    OnButtin1Click();
    var 
      i,j,k:integer;
      Ok:boolean;
      Str_Result,Str_Out:string;
    Begin
      i:= strtoint(edit1.text);
      Str_Result := '';
      For j:= 1 to 10 do
      begin   If i>TheMoney[j].MoneyValue Then
        If (i div TheMoney[j].MoneyValue) > TheMoney[j].MoneyNum Then
        Begin
         Str_Result := StrResult +
               inttostr(i div TheMoney[j].MoneyValue)+
               '*'+TheMoney[j].MoneyName+'+';
         TheMoney[j].MoneyNum := TheMoney[j].MoneyNum -
                            (i div TheMoney[j].MoneyValue);
         i := i-(i div TheMoney[j].MoneyValue) * TheMoney[j].MoneyValue;    End
        Else If TheMoney[j].MoneyNum <> 0 Then
        Begin
         Str_Result := StrResult +
               inttostr(TheMoney[j].MoneyNum)+
               '*'+TheMoney[j].MoneyName+'+';
         i := i-TheMoney[j].MoneyNum * TheMoney[j].MoneyValue;
         TheMoney[j].MoneyNum := 0;
        End;
      end;   
      Str_out := '';
      If i > 0 Then  //如果i>0 证明所胜余额不足;
        showmessage('余额不足')
      Else
        For k := 1 to length(Str_Result)-1 do
          Str_Out := Str_Out + Str_Result[k];//去除最后一个'+'
    End;