|
|
back to boardhelp! what wrong with my code? #include <iostream> using namespace std; int main() { int n; double head,tail; cin>>n>>head>>tail; double * c =new double[n]; int i=0; while(i!=n) { cin>>c[i]; i++; } double csum=0; for(int j=0;j<n;j++) csum+=(n-j)*c[j];
double a1; a1=(head+n*tail-2*csum)/(n+1); printf("%2.2f",a1); return 0; } my mistake,head and tail should be swapped! Edited by author 09.10.2008 23:14 |
|
|