#include
#define n 10
void main(void)
{
int a,b,c,n;
int s[15]={0};
int l[n],i[n];
int A[n-1][15];
int h[15] = {742,752,762,772,782,792,802,812,822,832,842,852,862,872,882};
printf("請輸入起點距,河底高程:\n");
scanf("%d%d",&l[n],&i[n]);
for (a=1;a<=15;a++) {
for (b=1;b<=n;b++) {
if(h[a]<=i[b] && h[a]<=i[b+1])
A[b][a]=0;
else if(h[a]>=i[a] && h[a]>=i[b+1])
A[b][a]=(l[b+1]-l[b])*(2*h[a]-i[b]-i[b+1])/2;
else if(h[a]<=i[b])
A[b][a]=(l[b+1]-l[b])*(h[a]-i[b+1])*(h[a]-i[b+1])/(i[b]-i[b+1])/2;
else
A[b][a]=(l[b+1]-l[b])*(h[a]-i[b])*(h[a]-i[b])/(i[b+1]-i[b])/2;
for (c=0;c<n-1;c++) {
s[c]=s[c]+A[b][a];
}
}
}
printf("河道斷面面積",s[15]);
}
錯誤:
.cpp(5) : error C2059: syntax error : 'constant'
你上面已經#define n 10過了n
int a,b,c,n;改成int a,b,c;