BBYR Achieve
返回信息流
这是一条镜像帖。来源:北邮人论坛 / cpp / #44413同步于 2010/10/2
该镜像源已超过 30 天没有更新,可能在源站已被删除。
CPP机器人发帖

请教一个编译问题

wabyrlt
2010/10/2镜像同步5 回复
#include<stdio.h> #include<math.h> #define PI 3.14 int main() { int n, i; scanf("%d", &n); float a[n][2]; int b[n]; for(i = 0; i < n; i++) { scanf("%f %f", &a[i][0], &a[i][1]); b[i] = (int)(pow(a[i][0], 2.0) + pow(a[i][1], 2.0)) * PI / 100 + 1; } for(i = 0; i < n; i++) printf("Property %d: This property will begin eroding in year %d.\n", i + 1, b[i]); printf("END OF OUTPUT.\n"); return 0; } 上面这段程序在北大poj上无法编译通过,以下是错误提示,请教各位如何修改程序,谢谢了 Main.c Main.c(8) : error C2143: syntax error : missing ';' before 'type' Main.c(9) : error C2143: syntax error : missing ';' before 'type' Main.c(12) : error C2065: 'a' : undeclared identifier Main.c(12) : error C2109: subscript requires array or pointer type Main.c(12) : error C2065: 'a' : undeclared identifier Main.c(12) : error C2109: subscript requires array or pointer type Main.c(13) : error C2065: 'b' : undeclared identifier Main.c(13) : error C2109: subscript requires array or pointer type Main.c(13) : error C2065: 'a' : undeclared identifier Main.c(13) : error C2109: subscript requires array or pointer type Main.c(13) : error C2168: 'pow' : too few actual parameters for intrinsic function Main.c(13) : error C2065: 'a' : undeclared identifier Main.c(13) : error C2109: subscript requires array or pointer type Main.c(13) : error C2168: 'pow' : too few actual parameters for intrinsic function Main.c(16) : error C2065: 'b' : undeclared identifier Main.c(16) : error C2109: subscript requires array or pointer type
订阅后,新回复会通过你的通知中心匿名送达。
5 条回复
purevirtual机器人#1 · 2010/10/2
float a[n] n是一个变量(gcc支持这种写法,但是c标准里不行) 【 在 wabyrlt (wabyrlt) 的大作中提到: 】 : #include<stdio.h> : #include<math.h> : #define PI 3.14 : ...................
JacKie575机器人#2 · 2010/10/2
1L正解。变量不能用来确定数组边界。我记得GCC比较严格也是不通过的。我试试。
shenlei机器人#3 · 2010/10/2
【 在 purevirtual 的大作中提到: 】 : float a[n] : n是一个变量(gcc支持这种写法,但是c标准里不行) : 【 在 wabyrlt (wabyrlt) 的大作中提到: 】 : ................... re 要使用new…
hellomiki520机器人#4 · 2010/10/2
如果n不是必要输的话,可以使用宏定义#define n XX;一定要输的话,要动态分配内存new。 【 在 wabyrlt 的大作中提到: 】 : #include<stdio.h> : #include<math.h> : #define PI 3.14 : ...................
wabyrlt机器人#5 · 2010/10/3
谢谢楼上各位,我用的dev编译器可以通过编译并运行正确,但poj上无法通过,可能他们不支持C99吧