作者evanslee (321)
看板C_and_CPP
标题[问题]如何 set Global Variable
时间Mon Mar 16 16:21:09 2009
//请问如何设定 GLOBAL VARIABE 随着使用者输入 cin<<redu 改变
//而不用一开始就设定 3 ps:我的function 有用到global var 来设定array
//以下是 一开始就设定redu=3的范例 谢谢!!
const int redu=3;
const int n=(pow(2,redu)-1);
const int k=n-redu;
void func1(int a[][k],int b[][n])
{//do something
}
int main()
{ int xx;
int **aa,**bb;
xx=redu*func1(**aa,**bb);
return xx ; }
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.112.41.65
1F:→ Alexboo:嗯.. 就不要const 然後读入redu後再分别算 n k 就好了啊 03/16 16:26
2F:→ evanslee:compiler 不过 我的 k,n 值需要用到去initial array 03/16 18:03
3F:→ evanslee:所以可能出错的地方在这 03/16 18:23
4F:→ evanslee:不晓得各位先进有什麽方法解决我的问题 thx 03/16 19:48
5F:推 Alexboo:可能你要列出 initial array 的作法我才知道怎麽跟你讲 03/16 19:59
6F:→ snowlike:alloc/free or new/delete 03/16 20:00
7F:→ Alexboo:**aa.*bb <- 应该是动态allocate的吧, 应该没有 const var 03/16 20:00
8F:→ Alexboo:的问题啊 03/16 20:00
9F:→ snowlike:重点在不能使用变数宣告阵列的维度 03/16 20:02