|
|
back to boardtest #3 Posted by Angel 25 Feb 2012 21:56 Can anybody explain, what dates are insertrd in test N3, i made my own test everything is working, but test N3 said what wrong answer #include "stdafx.h" #include<stdio.h> #include<conio.h> //#include<math.h> void main() { int k, A[102], t, B[52],i,l,minp,min; scanf("%d", &k); for (i=0; i<k; i++) scanf("%d",&A[i]); t=k/2+1; for (l=0; l<t; l++) { min=9999; for (i=0; i<k; i++) { if (A[i]<min) { min=A[i]; minp=i; B[l]=min; } if (i==(k-1)) A[minp]=9999; } } k=0; for (l=0; l<t; l++) k+=((B[l]/2)+1); printf("%d",k); getch(); } Re: test #3 Posted by falicos 26 Feb 2012 00:14 try test 1 9999 in this test array B[52] in your program will contain random numbers and so is answer. Your algo is true but not effective ,use qsort for example |
|
|