Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:JAVA 和C 这么大差别?In Reply To:JAVA 和C 这么大差别? Posted by:sun19890208 at 2013-03-10 23:24:08 > #include<stdio.h> > #include<stdlib.h> > int main(){ > float m,sum; > sum=0; > for(int i=0;i<12;i++){ > scanf("%f",&m); > sum=sum+m; > } > sum=sum/12; > printf("$%.2f",sum); > return 0; > } > > java的复制版 Eclipse上完全没问题 Float double 都能满足要求精度。 > 为啥C 一下就AC JAVA总是WA 我了个擦擦 > import java.text.DecimalFormat; > import java.util.Scanner; > > public class M1004 { > public static void main(String[] args) { > float m,sum; > sum=0; > Scanner sc = new Scanner(System.in); > for(int i=0;i<12;i++){ > m = sc.nextFloat(); > sum=sum+m; > } > sum=sum/12; > DecimalFormat df = new DecimalFormat("#.##"); > System.out.println(df.format(sum)); > } > } > Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator