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 |
为啥会是Wa呢?结果是最大值和最小值之差的两倍啊,给的测试数据也没错啊。求大牛帮帮 忙,小弟拜谢!#include<stdio.h> #include<stdlib.h> #include<string.h> int main() { int n; int i; int m; int h; int j; int k; int max1[20]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; int min1[20]={100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100}; int s[20]={0}; scanf("%d",&h); for(j=0;j<h;j++) { n=0; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d",&m); if(m<min1[j]) { min1[j]=m; } else if(m>max1[j]) { max1[j]=m; } } s[j]=2*(max1[j]-min1[j]); printf("%d\n",s[j]); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator