[java]代码库
public class no1{
public static void main(String[] args){
Scanner in=new Scanner(System.in);
int number,sum=0,count1=0,count2=0;
double avg;
do{
//System.out.println("请随机输入一个整数: ");
number=in.nextInt();
if(number>0){
count1=count1+1;
}if(number<0){
count2=count2+1;
}
sum=sum+number;
}while(number!=0);
System.out.println("正整数的个数为: "+count1);
System.out.println("负整数的个数为: "+count2);
avg=(double)sum/(count1+count2);
System.out.println("这些数的总和是: "+sum);
System.out.println("这些数的平均值是: "+avg);
}
}