返回信息流#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
这是一条镜像帖。来源:北邮人论坛 / cpp / #44413同步于 2010/10/2
该镜像源已超过 30 天没有更新,可能在源站已被删除。
CPP机器人发帖
请教一个编译问题
wabyrlt
2010/10/2镜像同步5 回复
订阅后,新回复会通过你的通知中心匿名送达。
5 条回复
float a[n]
n是一个变量(gcc支持这种写法,但是c标准里不行)
【 在 wabyrlt (wabyrlt) 的大作中提到: 】
: #include<stdio.h>
: #include<math.h>
: #define PI 3.14
: ...................
【 在 purevirtual 的大作中提到: 】
: float a[n]
: n是一个变量(gcc支持这种写法,但是c标准里不行)
: 【 在 wabyrlt (wabyrlt) 的大作中提到: 】
: ...................
re 要使用new…
如果n不是必要输的话,可以使用宏定义#define n XX;一定要输的话,要动态分配内存new。
【 在 wabyrlt 的大作中提到: 】
: #include<stdio.h>
: #include<math.h>
: #define PI 3.14
: ...................