140201126-杨鹏飞-作业二
2016-03-13 21:27 140201126杨鹏飞 阅读(149) 评论(0) 编辑 收藏 举报(1)public class Shuixianhuashu1{
public static void main(String[] args){
for(int i=0;i<=25;i++){
for(int j=0;j<=25;j++){
for(int k=0;k<=25;k++){
int shu=100*i+10*j+1*k;
if(shu==i*i*i+j*j*j+k*k*k&&shu<=10000&&shu>=100){
System.out.print("shu="+shu);
}
}
}
}
}
}
(6)public class QiuHe6{
public static void main(String[] args){
int sum1=0;
int i=13;
do{
sum1+=i;
i=i+10;
}while(i<=993);
System.out.println("13-->993累加结果为:"+sum1);
int sum2=0;
int j=-1003;
do{
sum2+=j;
j=j+10;
}while(j<=-23);
System.out.println("-1003-->-23累加结果为:"+sum2);
int sum=0;
sum=sum1+sum2;
System.out.println("sum="+sum);
}
}
(10)public class ZhengChu10{
public static void main(String[] args){
for(int i=1;i<=1000;i++){
if(i%3==0&&i%5==0&&i%7==0){
System.out.println("i="+i);
}
}
}
}
(11)public class QiuJie11{
public static void main(String[] args){
int i=1;
long sum=0,sum1=1;
do{
sum1=sum1*i;
i++;
System.out.print("sum1="+sum1);
System.out.print("\n");
sum=sum1+sum1;
}while(i<=20);
System.out.println("sum="+sum);
System.out.print("\n");
}
}
(4)public class Shuzu4{
public static void main(String[] args){
int score[]={67,89,87,69,90,100};
int sum=0;
int max=0;
int min=0;
max=min=score[0];
for(int i=1;i<score.length;i++){
for(int j=0;j<score.length;j++){
if(score[i]<score[j]){
int temp=score[i];
score[i]=score[j];
score[j]=temp;
}
}
}
for(int i=0;i<score.length;i++){
System.out.print(score[i]+"\t");
sum=sum+score[i];
}
System.out.println("数组的和为:"+sum);
for(int i=0;i<score.length;i++){
if(score[i]>max){
max=score[i];
}
if(score[i]<min){
min=score[i];
}
}
System.out.println("最高成绩:"+max);
System.out.println("最低成绩:"+min);
}
}
(8)public class Cishu8{
public static void main(String[] args){
int score[]={1,4,2,5,6,5,1,0,5,4,8,4,7,8,9,0,4,2,7,3,2,7,9,4,2,5,2,9,3,9};
int count1=0,count2=0,count3=0,count4=0,count5=0,count6=0,count7=0,count8=0,count9=0,count10=0;
for(int i=1;i<score.length;i++){
for(int j=0;j<score.length;j++){
if(score[i]<score[j]){
int temp=score[i];
score[i]=score[j];
score[j]=temp;
}
}
}
for(int i=0;i<score.length;i++){
System.out.print(score[i]+"\t");
}
for(int i=0;i<score.length;i++){
if(score[i]==0){
count1++;
}
}
System.out.println("0的次数为:"+count1);
for(int i=0;i<score.length;i++){
if(score[i]==1){
count2++;
}
}
System.out.println("1的次数为:"+count2);
for(int i=0;i<score.length;i++){
if(score[i]==2){
count3++;
}
}
System.out.println("2的次数为:"+count3);
for(int i=0;i<score.length;i++){
if(score[i]==3){
count4++;
}
}
System.out.println("3的次数为:"+count4);
for(int i=0;i<score.length;i++){
if(score[i]==4){
count5++;
}
}
System.out.println("4的次数为:"+count5);
for(int i=0;i<score.length;i++){
if(score[i]==5){
count6++;
}
}
System.out.println("5的次数为:"+count6);
for(int i=0;i<score.length;i++){
if(score[i]==6){
count7++;
}
}
System.out.println("6的次数为:"+count7);
for(int i=0;i<score.length;i++){
if(score[i]==7){
count8++;
}
}
System.out.println("7的次数为:"+count8);
for(int i=0;i<score.length;i++){
if(score[i]==8){
count9++;
}
}
System.out.println("8的次数为:"+count9);
for(int i=0;i<score.length;i++){
if(score[i]==9){
count10++;
}
}
System.out.println("9的次数为:"+count10);
}
}