The government of a small but important country has decided that the alphabet needs to be streamlined and reordered. Uppercase letters will be eliminated. They will issue a royal decree in the form of a String of B and A characters. The first character in the decree specifies whether a must come ( B )Before b in the new alphabet or ( A )After b . The second character determines the relative placement of b and c , etc. So, for example, "BAA" means that a must come Before b , b must come After c , and c must come After d .
Any letters beyond these requirements are to be excluded, so if the decree specifies k comparisons then the new alphabet will contain the first k+1 lowercase letters of the current alphabet.
Create a class Alphabet that contains the method choices that takes the decree as input and returns the number of possible new alphabets that conform to the decree. If more than 1,000,000,000 are possible, return -1.
Definition
Visual Basic 6.0可以通過(guò)調(diào)用API函數(shù)格式化一個(gè)磁盤,無(wú)論是軟盤還是硬盤。
打開一個(gè)新的項(xiàng)目(工程1) ,如果你沒(méi)有更改過(guò)缺省模式,那么Visual Basic 6.0會(huì)自動(dòng)添加一個(gè)form1文件,在form1上添加一個(gè)命令控件,將下面的代碼拷入。
Option Explicit
Private Declare Function SHFormatDrive Lib"shell32"( ByVal Hend AS Long,ByVal Drive AS Long,ByVal FormatID AS Long,ByVal Options AS Long) as Long
Private Sub FormatDisk(intDrive as integer,blnQuickFormat as Boolean)
dim lngReturn As Long
if (blnQuickFormat) then
lngReturn= SHFormatDrive(0,intDrive,0&,1&)
else
lngReturn= SHFormatDrive(0,intDrive,0&,0&)
end if
end Sub
Private Sub Command1_Click()
call FormatDisk(0,True)
End Sub
運(yùn)行此程序。
注意FormatDisk函數(shù)的第一個(gè)變量很重要,他的值是0,1,2時(shí)代表格式化的分別是:A、B、C盤。