首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

网络考试系统怎样随机调换选择题的位置?解决方案

2012-04-15 
网络考试系统怎样随机调换选择题的位置?网络考试系统怎样随机调换选择题的位置?就是说它的答案有 我、你、他

网络考试系统怎样随机调换选择题的位置?
网络考试系统怎样随机调换选择题的位置?就是说它的答案有 我、你、他。不一定A我 B你 C他 D它,或者A你 B我 C他 D它也行。怎样的算法最简单,而且要核对答案的算法最简单?


[解决办法]

Delphi(Pascal) code
unit customSort;interfaceuses  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,  Dialogs, StdCtrls;type  TForm1 = class(TForm)    Button1: TButton;    procedure Button1Click(Sender: TObject);  private    { Private declarations }  public    { Public declarations }  end;var  Form1: TForm1;  function asort(List:TstringList;index1,index2:integer):integer;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);var stringList:TstringList;beginstringList:=TstringList.Create;stringList.Add('我');stringList.Add('你');stringList.Add('他');stringList.Add('她');stringList.CustomSort(asort);showmessage(stringList[0]+';'+stringList[1]+';'+stringList[2]+';'+stringList[3]+';');end;function asort(list:TstringList;index1,index2:integer):integer;  beginResult := Random(3-1+1);  end;end. 

热点排行