2018年自考《Java语言程序设计》综合练习题三
三、写出下列程序完成的功能。
1. public class Sum
{ public static void main( String args[ ])
{ double sum = 0.0 ;
for ( int i = 1 ; i = 0 ; i ―― )
System.out.print(a[i]+' ');
System.out.println( );
}
}
3.import java.awt.*;
public class abc
{ public static void main(String args[])
{ new FrameOut(); }
}
class FrameOut extends Frame // Frame为系统定
{ Button btn; // 义的窗框类
FrameOut( )
{ super('按钮');
btn = new Button('按下我');
setLayout(new FlowLayout( ));
add(btn);
setSize(300,200);
show( );
}
}
4. import java.io.*;
public class Class1
{
public static void main(String args[ ]){
int i , Max , Min ;
int a[ ] = { 12,67,8,98,23,56,124,55,99,100 };
Max = Min = a[0];
for ( i = 1 ; i < a.length; i ++ ) {
if ( a[i]
if ( a[i]>Max ) Max = a[i];
}
System.out.println( Max+' '+Min );
System.out.println( );
}
}
5. public class ABC
{
public static void main(String args[ ]){
int i , j ;
int a[ ] = { 12,67,8,98,23,56,124,55,99,100 };
for ( i = 0 ; i < a.length-1; i ++ ) {
int k = i;
for ( j = i ; j < a.length ; j++ )
if ( a[j][k]>
int temp =a[i];
a[i] = a[k];
a[k] = temp;
}
for ( i =0 ; i;>
System.out.print(a[i]+' ');
System.out.println( );
}
}
6.import java.io.*;
public class Class1 {
public static void main( String args[] )
{
Fact N = new Fact( 4 );
System.out.println( N.fact( ) );
}
}
class Fact {
int n ;
Fact( int nn ) { n = nn; }
int fact( ) {
int i , f = 1;
for ( i=1; i
(一)由于考试政策等各方面情况的不断调整与变化,本网站所提供的考试信息仅供参考,请以权威部门公布的正式信息为准。
(二)本网站在文章内容来源出处标注为其他平台的稿件均为转载稿,免费转载出于非商业性学习目的,版权归原作者所有。如您对内容、版权等问题存在异议请与本站联系。邮箱:23006896@qq.com,我们会及时进行处理解决。