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 |
这道题目用递归写为什么是Runtime Error呢?请高手指教下#include<stdio.h> #include<math.h> double C[4000],A[4000]; int n; double calculate(int i) { double temp; if(i==0) return A[0]; if(i==n+1) return A[n+1]; temp=(calculate(i-1)+calculate(i+1))/2-C[i]; return (calculate(i-1)+calculate(i+1))/2-C[i]; } int main() { int i; double result; scanf("%d",&n); scanf("%lf%lf",&A[0],&A[n+1]); for(i=1;i<=n;i++) scanf("%lf",&C[i]); result=calculate(1); printf("%.2lf\n",result); return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator