|
|
back to boardEverything works fine, but still doesn't accept... Any ideas why? #include <iostream.h> void main() { long int num, subnum[101], i, j, calc=0, temp, result=0; cin>>num; calc=num; for (i=0;i<num;i++) cin>>subnum[i]; if (num=1) cout<<(subnum[0]+1)/2; else for (i=num-1;i>0;i--) { for (j=num-1;j>num-i-1;j--) if (subnum[j]<subnum[j-1]) { temp=subnum[j-1]; subnum[j-1]=subnum[j]; subnum[j]=temp; }; calc--; result+=(subnum[num-i-1]+1)/2; if (calc*2<num) { cout<<result; break; } } } Obviously, you are wrong!@ Posted by Seany 6 Aug 2003 20:13 > Any ideas why? > > #include <iostream.h> > void main() > { > long int num, subnum[101], i, j, calc=0, temp, result=0; > cin>>num; > calc=num; > for (i=0;i<num;i++) cin>>subnum[i]; > if (num=1) > cout<<(subnum[0]+1)/2; > else > for (i=num-1;i>0;i--) { > for (j=num-1;j>num-i-1;j--) > if (subnum[j]<subnum[j-1]) { > temp=subnum[j-1]; > subnum[j-1]=subnum[j]; > subnum[j]=temp; > }; > calc--; > result+=(subnum[num-i-1]+1)/2; > if (calc*2<num) { > cout<<result; > break; > } > } > } > > |
|
|