如何try()修改函数(以及它的调用)以从下面的程序中获得11的输出?
#include <stdio.h>
/* declare try() here */
int main(void)
{
int x = 10;
try(); /* Call can change */
printf("%d\n", x);
return 0;
}
void try() /* Signature can change */
{
/* how to change x here?? */
}
Run Code Online (Sandbox Code Playgroud) 在这段代码中,我似乎得到零,我不太熟悉为什么我不能用我创建的函数改变变量长度.任何帮助都可能有用.
#include <stdio.h>
double get_length(double a);
int main(int argc, char* argv[])
{
double length = 0;
get_length(length);
printf("%lf", length);
return 0;
}
double get_length(double a)
{
printf("What is the rectangle's length?\n");
scanf("%lf", &a);
return a;
}
Run Code Online (Sandbox Code Playgroud)
打印时,返回0.0000