【发布时间】:2013-01-14 12:58:17
【问题描述】:
我有一个程序可以计算出分子的减少质量,并想用 if 函数调用它。这是我目前拥有的代码:
int program ();
int main()
{
printf("Press 1 to calculate the reduced mass of a molecule or press any other button to exit:");
scanf ("%lg",&repeat);
if(repeat==1)
{
program();
}
else
{
return(0);
}
}
int program ()
//etc...
我对 C 不太熟悉,所以解释一下可能会有用。这是否也可以让您可以根据需要多次重复该功能?
【问题讨论】:
-
在 C.
while或for或do-while中查找 条件循环。 -
repeat定义在哪里? -
这里不适合作为问题(如果有的话)。请事先对 SO 或整个网络进行最少的研究。
-
int main()是多年前的标准做法,并在 1989 年正式过时。使用int main(void)或int main(int argc, char **argv) -
if()is not function is flow-control structure in C.你的程序检查repeat的值是否等于1然后调用一个函数program();,该函数在某些地方定义你的代码。如果repeat不等于1,则程序终止。
标签: c function if-statement