It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened,
visit the help center。
已关闭8年。
给定三个整数,例如10,20和30,每个打算执行数学运算。编写一个C程序以输入任意一个整数并执行其任务,而无需使用比较语句。
在下面的程序中,我使用了整数指针并分配了所有值,并检查所有整数并执行其各自的操作。当试图输入一个整数并执行其任务时,我最终会使用一个/其他比较语句,例如if-else,switch来执行其各自的任务,即
如果输入== 10,则执行A()等。
弄清楚这一点的逻辑。代码表示赞赏。
我正在考虑基于指针的概念来跟踪程序。
弄清楚这一点的逻辑。代码表示赞赏。谢谢。
main()
{
int *i,n;
i = &n;
*i=10;
addition();
*i = 20;
multi();
*i = 30;
subtract();
}
int a=6,b=4,c;
addition()
{
c = a + b;
printf("\n c = %d", c);
}
multi()
{
c = a * b;
printf("\n c = %d", c);
}
subtract()
{
c = a - b;
printf("\n c = %d", c);
}