1 条题解
-
0
Java :
import java.util.Scanner; public class Main { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Scanner input=new Scanner(System.in); int a=input.nextInt(); int p=0,n=0,t=0; while (a!=0) { t+=a; if (a>0) p++; else n++; a=input.nextInt(); } System.out.println("The number of positives is "+p); System.out.println("The number of negatives is "+n); System.out.println("The total is "+t); System.out.printf("The average is %.2f",(t*1.0/(p+n))); } }
- 1
信息
- ID
- 2957
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者