开发者

Passing the values of variable values in C

I have a function say formula(f), where f is a TERM and TERM is a structure pointer. This function prints a formula like forall([U,V],implies(U,V)].These U and V are variable. I need to pass the values in these variable and have to generate the forumula according the combination of the values of the var开发者_如何学运维iable.Suppose the values of the U and V are 2 and 2 then it has to generate the 4 formulas like forall([a_1,b_1]implies(a_1,b_1),forall([a_1,b_2]implies(a_1,b_2)) and so on... Can anybody please help me how to generate it?


Presuming that your TERM structure has U and V as integer members:

void formula(TERM* term) {
  int x = 0;
  int y = 0;
  for (x; x < (*term).U; ++x)
    for (y; y < (*term).J; ++y)
      printf("forall([a_%d,b_%d] implies(a_%d, b_%d))\n", x, y, x, y);
}

Is this what you're looking for?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜