44问答网
所有问题
#include <stdio.h> int fun(int a) { int b=0; static int c=3; a=(c++,b++); return (a); }
int main()
{
int a=2,i,k;
for(i=0;i<2;i++)
k=fun(a++);
printf("%d\n",k);
return 0;
}
为什么结果是0
举报该问题
推荐答案 2014-03-03
a=(c++,b++);由于(c++,b++)中用了逗号,逗号作为
运算符
时返回最后的
表达式
值,所以这句相当于a=b++,由于++在后,所以这又相当于a=b;所以返回0
温馨提示:答案为网友推荐,仅供参考
当前网址:
http://44.wendadaohang.com/zd/YDZVY3KGW36VYY6ZYZR.html
其他回答
第1个回答 2011-09-18
#include <stdio.h>
int f(int a)
{
int b=0;
static int c=3;//静态变量,只做一次初值赋值,即:第一次调用fun c=3
a=c++,b++; //第一次调用本函数后,c=4,第二次后,c=5,第三次后c=6......
return a; //第一次调用本函数后,a=3,二次后,a=4,第三次后a=5.....
}
第2个回答 2014-03-03
a=(c++,b++); 这行没有看懂,可能就是这里出问题的
第3个回答 2014-03-03
fun是个函数调用你的fun函数写的好奇怪。
第4个回答 2014-03-03
让公司地宫哥是荣
1
2
下一页
相似回答
一道
c
语言的程序题 答案是
0
答:
int
fun(int
a ){int
b=0;static
int
c=3;a=(c++,b+
+);//从这里可以看到 a的值和输入的a无关 只是这个表达式的值//这是一个逗号运算符表达式 其值和前一个c++无关//所以等效为a=b++; //++在后 所以是先赋值再自加//a的值就是b的初始化值0//返回的也就是0了return(
a);
} ...
fun
函数问题
答:
include
<
stdio.h
>int
fun(int
a){int
b=0;static
int
c=3;a=(c++,b+
+); //整体为逗号最右边的值,【即 b==0 赋值给a , b再自增为1】return(a);}main(){int a=2,i,k;for(i=0;i<2;i++)k=fun(a++); //每一次调用,不管实参 a 的值是多少,形参 a 的值取 ...
...f
(int
a)
{
int
b=0;
static
int
c=3;
a=c++,b+
+; return a; } vo...
答:
include
<
stdio.h
> int f
(int
a){
int
b=0;static
int
c=3;
//静态变量,只做一次初值赋值,即:第一次调用
fun
c=3
a=c++,b+
+; //第一次调用本函数后,c=4,第二次后,c=5,第三次后c=6...return a; //第一次调用本函数后,a=3,二次后,a=4,第三次后a=5...} ...
C语言求助
答:
程序有问题,正确程序:
include
<
stdio.h
>
fun(int
a){int
b=0;static
int
c=3;
b++;
c++
;return(a+b+c);} main(){ int i,a=5;for(i=0;i<3;i++)printf("%d\n",fun(a));} 结果:10,11,12 静态变量的值每次调用函数累加,因此得出这个结果 c++累计
,b+
+一直是1 ...
大家正在搜
include iostream
c语言include stdio
int fun(int n)
includestdio
int main(void)
int main(void)含义
visual studio
void main和int的区别
stdio库函数file的原名
相关问题
#include <stdio.h> int fun(int...
#include<stdio.h>int f(int a){...
设有以下函数: #include <stdio.h> int...
9. 以下程序的输出结果是 ( ) #include"std...
#include <stdio.h> int b=0; in...
#include(stdio.h); int main() ...
#include <stdio.h> int main() ...
c语言设计m