int key , num=0;
printf("\nPlease input the telegraph: \n");
while ( num<255 && ( old[num++] = getchar()) != '\n' );
old [ (num==255)?num:num-1] = '\0';
do
{ printf( "\nPlease input Key ( Key>1 ):" );
scanf("%d",&key);
} while ( key<=1 );
printf( "\nThe decode of telegraph:'%s' is:\n'%s'\n",old,decode( old,key ) );
}
试题五(15分,每空3分)
阅读以下说明及Visual Basic 程序代码,将应填入___(n)___处的字句写在答题纸的对应栏内。
[说明]
本程序实现如下功能:首先,单击“生成”按钮,生成一个由10个随机大写字母组成的字符串,并在文本框中显示。然后,单击“排序”按钮,将此随机字符串中的各个字母按递增顺序添加到列表框中。
程序运行界面如下:
[程序]
As String
Private Sub get_Click()
Dim i As Integer
Randomize
For i = 1 To 10
str1 = Trim(str1) & Chr(Int( ___(1)___ ))
Next
Text1.Text = str1
End Sub
Private Sub sort_Click()
Dim i As Integer
Dim j As Integer
For i = 1 To 26
j = ___(2)___
Do While j > 0
___(3)___
j = j - 1
Loop
Next
End Sub
Private Function search(str1 As String, str2 As String) As Integer
Dim int1 As Integer, int2 As Integer
int1 = 1
Do
int1 = ___(4)___
If int1 = 0 Then Exit Do
int2 = int2 + 1
int1 = int1 + 1
Loop
search = ___(5)___
End Function (