import javax.swing.JOptionPane;
public class Ex1 {
public static void main(String[] args){
String nStr=JOptionPane.showInputDialog("Please enter how many numbers you want to operate");
int n=Integer.parseInt(nStr);
int[] array=new int[n];
for(int i=0;i
System.out.print(array[i]+" ");
}
System.out.println();
int max=array[0];
for(int j=1;j
max=array[j];
}
}
int min=array[0];
for(int k=1;k
}
}
System.out.println("The max number is: "+max);
System.out.println("The min number is: "+min);
}
}
public class Ex2 {
public static void main(String[] args){
int num=1;
int total=0;
int counts=0;
while(num<=100){
if(num%3==0&&num%5!=0&&num%9!=0){
System.out.print(num+" ");
total+=num;
counts++;
}
num++;
}
System.out.println();
System.out.println("平均:"+(total/counts));
}
}
public class Ex7 {
public static void main(String[] args){
String nStr=JOptionPane.showInputDialog("Please enter how many numbers you want to show:");
int n=Integer.parseInt(nStr);
for(int i=1;i<=n;i++){
System.out.print(fibinacc(i)+" ");
}
}
public static int fibinacc(int i){
if(i==1||i==2)
return 1;
else return fibinacc(i-2)+fibinacc(i-1);
}
}
public class Ex8 {
public static void main(String[] args){
int num=100;
while(num<1000){
int num1=num%10;
int temp=num/10;
int num2=temp%10;
int num3=num/100;
if(num==(Math.pow(num1,3)+Math.pow(num2,3)+Math.pow(num3,3)))
System.out.print(num+" ");
num++;
}
}
}
import javax.swing.JOptionPane;
public class Ex9{
public static void main(String[] args){
String nStr=JOptionPane.showInputDialog("Please enter how many number");
int n=Integer.parseInt(nStr);
int[] array=new int[n];
for(int i=0;i
}
bubbleSort(array);
for(int j=0;j
System.out.println(array[j]+" ");
else System.out.print(array[j]+" ");
}
}
public static void bubbleSort(int[] array){
boolean changed=true;
do{
changed=false;
for(int i=0;i
array[i+1]=array[i];
array[i]=temp;
changed=true;
}
}
}while(changed);
}
}
作业的话要好好做,在网上找别人做是不好的!
JAVA是个好东西,学好了对楼主是有很大的帮助的:)
你可以加QQ:4136716
帮你一起做答,
每道给20分还差不多