主观

阅读以下说明和Java代码,将应填入(n)处的字句写在对应栏内。

[说明]

 编写一个字符界面的Java Application 程序,接受用户输入的10个整数,并输出这10个整数的最大值和最小值。

 [Java 代码]

 import java. io.* ;

 public class abc

 {

   public static void main ((1))

   {int i, n=10, max=0, min=0, temp=0;

      try {

         BufferedReader br = new BufferedReader (

                new InputStreamReader ( System.in ) );

         max = min =Integer. parselnt ( br. readLine ( ) );

      }. (2) ( IOExccption e ) {} ;

    for ( i=2 ; i<=n ; i++ ) {

     try {

         BufferedReader br = new (3) (

                new InputStreamReader ( System. in ) );

         temp =(4) ( br. readLine ( ));

     if (temp>max ) max=temp;

     if (temp<min) (5) 

     } catch (IOException e ) {};

   }

    System.out.println ( "max="+max+"\nmin="+min );

   }

 }

参考答案
您可能感兴趣的试题

阅读以下说明及Visual Basic 程序代码,将应填入(n)处的字句写在对应栏内。

[说明]

 以下是一账号和密码输入的检验程序。对输入的账号和密码规定如下所述。

 (1)账号为不超过6位的数字,密码为4位字符,在本题中,密码假定为“Pass”。

 (2)密码输入时在屏幕上不显示输入的字符,而以“*”代替。

 (3)当输入不正确,如账号为非数字字符或密码不正确时,显示有关信息。

 (4)当输入正确时,关闭密码窗口,显示记事本窗口。

 按要求完成有关控件的其他属性的设置,编写确定按钮的单击事件过程。相关界面如下:

(可能要用到的单词:MultiLlne,ScrollBars,PasswordChar,MaxLength)密码窗口frmPass控件设置如下表所示。

记事本窗口frmNotepad 控件设置如下表所示。

在密码窗口的属性窗口,对密码文本框设置属性MuniLine 为False。

 [Visual Basic 代码]

 Private Sub cmd OK_ Click ( )

    If txtPas. Text= "Pass" Then

     Load frmNotePad

     frmNotePad. Show

     frmPass.Hide

    Else

     MsgBox "密码错误! ", vbExclamation + vbRetryCancel, "重输入密码"

     txtPas. Text= " "

     txtPas. SetFocus

   (1) 

 End Sub

 Private Sub Form_ Load ( )

    txtPas.PasswordChar = "*"

    xtNo.MaxLength = 6

 End Sub

 Private Sub txtNo LostFocus (

    Dim i As Integer, s As String * 1

    Fori= 1 To (2) 

    s = Mid ( txtNo.Text, i, 1 )

    If (3) Or (4) Then

      MsgBox "账号有非数字符号! ", vbExclamation + vbRetryCancel, "1 输入账号"

       (5) 

      txtNo. SetFocus

      Exit Sub

     End If

   Next i

 End Sub

阅读以下程序说明和C程序,将应填入(n)处的子句,写在对应栏内。

【程序说明】

 函数int commstr(char * str1,char * str2,int * sublen)从两已知字符串str1和str2中,找出它们的所有最长的公共子串。如果最长公共子串不止1个,函数将把它们全部找出并输出。约定空串不作为公共子串。

 函数将最长公共子串的长度送入由参数sublen所指的变量中,并返回字符串str1和str2的最长公共子串的个数。如果字符串str1和str2没有公共子串,约定最长公共子串的个数和最长公共子串的长度均为0。

 【程序】

 int strlen(char * s)

 {char *t=s;

   while( * ++);

   return t-s-1;

 }

 int commstr(char) *str1,char *str2,int *sublen

 { char*s1, *s2;

   int count=0,len1 ,len2,k,j,i,p;

   len1:=strlen(str1)

   len2 = strlen(str2);

   if(len1>len2)

      {s1=str1 ;s2=str2;}

   else {len2 = len1;s1 = str2;s2 = str1;}

   for(j=len2;j>0;j--)           /*从可能最长子串开始寻找*/

      {for(k=0;(1)<:len2;k++) /*k为子串s2的开始位置*/

      {for(i=0;s1[(2)]!='\0';i++;) /*i为子串s1的开始位置*/

        { /*s1的子串与s2的子串比较*/

          for (p=0;p<j)&&(3);p++);

          if ((4)) /*如果两子串相同*/

          {for(p=0);p<j;p++}  /*输出子串*/

            printf ("%c",s2[k+p]);

            printf ("\n");

            count++;/*计数增1 */

           }

         }

       }

      if (count>0) break;

     *sublen=(count>0)?(5):0;

   return count;

 }

¥

订单号:

遇到问题请联系在线客服

订单号:

遇到问题请联系在线客服