main() {int a[10]={1,2,3,4,5}; printf("%d\n",a[6]);}输出的结果是啥,为啥?

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/16 11:36:42
main() {int a[10]={1,2,3,4,5}; printf(
xR]OA+D,V>_>lc(!~.hQlKQJW?3wf~F ifνs=g&r$< jDѶN"`Pj w'@W_k˛i9)cn(.2+u;M~Xéx쥦Ӓl2 ~vybTmS8``qH ]Y!;Wd hVgxf,s JOx`)L4F :%(tUjć#L4>lr; VLk[Q|]jĒE ^?^ ?S7}3+rg }0Eb 5λĥ2Z~-sr<mA9xY³ Kr-UidZrET #Ô-`FĴ d0rk

main() {int a[10]={1,2,3,4,5}; printf("%d\n",a[6]);}输出的结果是啥,为啥?
main() {int a[10]={1,2,3,4,5}; printf("%d\n",a[6]);}输出的结果是啥,为啥?

main() {int a[10]={1,2,3,4,5}; printf("%d\n",a[6]);}输出的结果是啥,为啥?
运行结果为0
LZ可以在编程软件中,如visual C++,中可得到该结果.
因为a[10]是一个数组,从0开始赋值,第0个数,即a[0]为1,第1个数a[1]为2,依次类推,a[4]=5,
而a[5]之后到a[9]没有给它赋值,它只好为0,可以理解为1楼所说的初始化,也可理解为相当于为假.
不过,要注意,若说要输出a[10],已经超出这个数组的大小,或者理解为越界,运行结果是一个莫名其妙的数.

main() {int m[10],a;for(a=0,a main() { int a; for(a=1;a #include int b=2; int fun(int *k) {b=*k+b;return(b);} main() {int a[10]={1,2,3,4,5,6,7,8}, .main() { int a=1,b=10; do {b-=a;a++;}while(b-- #include int b=2; int fun(int*k) { b=*k+b;return(b);} main() {int a[10]={1,2,3,4,5,6,7,8}#include int b=2; int fun(int*k) { b=*k+b;return(b);} main() {int a[10]={1,2,3,4,5,6,7,8},i;for(i=2;i void fun(int a,int b) { int t; t=a;a=b;b=t; } main()void fun(int a,int b){ int t; t=a;a=b;b=t; } main() { int c[10]={1,2,3,4,5,6,7,8,9,0}.i; for(i=0;i #define MAX 10 int a[MAX],i; int main( ) sub1( ) { for(i=0;i #define N 20 fun(int a[],int n,int m) {int i; for(i=m;i>n;i--)a[i+1]=a[i]; return m; } void main() #define N 20fun(int a[],int n,int m){int i;for(i=m;i>n;i--)a[i+1]=a[i];return m;}void main(){ int i,a[N]={1,2,3,4,5,6,7,8,9,10};fun(a,0,N/2);for(i=0;i void main() {int t=1;fun(fun(t));} fun(int h) {stvoid main(){int t=1;fun(fun(t));}fun(int h){static int a[3]={1,2,3}; int k; for(k=0;k error C2065:'a' :undeclared identifier#includeint main(){int print_shang();int print_xia();print_shang();print_xia();return 0;}int print_shang(){int a,b;for(a=1;a #include void fun(int a, int b) { int t; t=a; a=b; b=t;main() { int c[10]={1,2,3,4,5,6,7,8,9,0), i; for (i=0; i main(){ int i=1;while (i #include stdio.h void fun(int a,int b) { int t; t=a,a=b,b=t; } main() { int c[10]={1,2,3,4,5,6,7#include stdio.hvoid fun(int a,int b){int t;t=a,a=b,b=t;}main(){int c[10]={1,2,3,4,5,6,7,8,9,0},i;for(i=0;i main(){int a[]={2,4,6,8,10};int y=1,x,*p;p=&a[1];for(x=0;x #include void main() { int a=3,b=2,c=1; int x=10,y=20; if(a int b=2;int fun(int*k) {b=*k=b;return (b);} main() {int a[10]={1,2,3,4,5,6,7,8} for (i=2;i 帮我看一下这个编程题 我不明白为什么运行结构会是那样.#includevoid func();int n=1;int main (){static int a;int b = -10;cout main() {int a[10]={1,2,3,4,5}; printf(%d ,a[6]);}输出的结果是啥,为啥?