验证中...
Languages: Java
Categories: 其他
Latest update 2019-11-09 19:41
gistfile1.txt
Raw Copy
class Person{
String name;
int age;
public void tell(){
System.out.println("姓名;"+name+",年龄;"+age);
}
}
public class ClassDemo03 {
public static void main(String args[]){
Person per =null;
per.name="张三";
per.age =30;
per.tell();
}
}
gistfile2.txt
Raw Copy
public class flower {
public static void main(String[] args){
int count=0;
for (int i=100;i<1000;i++){
int g=i%10;
int s=i/10%10;
int b=i/100;
if (g*g*g+s*s*s+b*b*b==i){
count++;
System.out.println(i);
}
}
System.out.println("1000以内水仙花数的个数:"+count);
}
}
gistfile3.txt
Raw Copy
public class Test {
public static void main(String[] args) {
int arr[]=new int[]{1,6,21,7,-2,9,0,81}; // 定义一个数组
int jishu=0; // 用来统计奇数个数
int oushu=0; // 用来统计偶数个数
for(int i=0;i<arr.length;i++){ // 遍历数组
if(arr[i]%2==1){ // 假如求余余数是1 就是奇数
jishu++; // 奇数个数加1
}
if(arr[i]%2==0){ // 假如求余余数是0 就是偶数
oushu++;
}
}
System.out.println("数组中的奇数个数:"+jishu);
System.out.println("数组中的偶数个数:"+oushu);
}
}
gistfile4.txt
Raw Copy
public class ArrayDemo05 {
public static void main(String[] args){
int score[]={67,89,87,69,90,100,75,90};
int max=0;
int min=0;
max=min=score[0];
for (int x=0;x<score.length;x++){
if (score[x] > max) {
max=score[x];
}
if (score[x] < min) {
min=score[x];
}
}
System.out.println("最高成绩:"+max);
System.out.println("最低成绩:"+min);
}
}
gistfile5.txt
Raw Copy
public class Demo045 {
public static void maian(String[] args){
int score[]={67,89,87,69,90,100,75,90};
for (int i=1;i<score.length;i++){
if (int j= 0;j<score.length;j++){
if (score[i]<score[j]){
int temp=score[i];
score[i]=score[j];
score[j]=temp;
}
}
System.out.print("第“+i+”次排序的结果:\t);
for (int j=0;j<score.length;j++){
System.out.print(score[j]+"\t");
}
System.out.print("");
}
System.out.print("最终排序结果为:\\t");
for (int i=0;i<score.length;i++){
System.out.print(score[i]+"\t");
}
}
}

Comment list( 0 )

Sign in for post a comment

Help Search

191139_cd20d5fd_5186603 191143_ebef6f8d_5186603