ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1047. Simple Calculations

help! what wrong with my code?
Posted by luocean 9 Oct 2008 22:55
#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