数组
数组(Python叫元组)是C/C++、java、Python等众多语言中的数据类型,是计算机程序中最基本的数组。使用数组可以批量创建同一类型数据,极大的方便我们开发程序,这里收集了大量的数组有关的教程、题目等资源
-
若主函数中有定义语句:int a[10],b[10],c;在主函数前定义的fun函数首部为 void fun(int x[]) 则以下选项中错误的调用语句是( )。
-
若有函数:void fun(double a[],int *n) {......}以下叙述中正确的是( )。
-
若有函数声明:void fun(float array[],int*ptr);以下叙述正确的是( )。
-
有以下程序:#include <stdio.h> main() { int x[]={8,2,6,12,5,15},f1,f2; int *p=x; f1=f2=x[0]; for(;p<=x+5;p++) { if(f1<*p)f1=*p; if(f2>*p)f2=*p; } printf("%d,%d\n",f1,f2); }程序的运行结果是( )。
-
有如下程序#include <stdio.h> main() { int i, *ptr; int array[5] = {5,3,1}; for (ptr=array, i=0; i<5; i++, ptr++) { if (*ptr == 0) putchar('X'); else putchar('A' + *ptr); } printf("\n"); }程序运行后的输出结果是( )。
-
有以下程序:#include <stdio.h> main() { int i,*ptr; int array[4]={1,1,3,4}; for(ptr=array,i=0;i<3;i++) printf("%d,",*ptr++); printf("\n"); }程序运行后的输出结果是( )。
-
有如下程序:#include <stdio.h> main() { int i,*ptr; int array[3]={8,2,4}; for(ptr=array,i=0;i<2;i++) printf("%d,",*ptr++); printf("\n"); }程序运行后的输出结果是( )
-
有以下程序#include <stdio.h> main() { int a[]={2,4,6,8,10},x,*p,y=1; p=&a[1]; for(x=0;x<3;x++)y+=*(p+x); printf("%d\n",y); }程序的输出结果是( )。
-
有以下程序:#include <stdio.h> void fun(int *p) { printf("%d\n",p[5]); } main() { int a[10]={1,2,3,4,5,6,7,8,9,10}; fun(&a[3]); }程序运行后的输出结果是( )。
-
有以下程序#include <stdio.h> main() { int a[10]={11,12,13,14,15,16,17,18,19,20},*p=a,i=9; printf("%d,%d,%d\n",a[p-a],p[i],*(&a[i])); }程序运行后的输出结果是( )。
-
以下程序中给数组所有元素输入数据,请从选项中选择正确的答 案填入下划线处。( )#include <stdio.h> main() { int a[10],i=0; while(i<10) scanf("%d", _________); … }
-
以下函数的功能是:通过键盘输入数据,为数组中的所有元素赋值。#include <stdio.h> #define N 10 void fun(int x[N]) { int i=0; while(i<N)scanf("%d",______); }在程序中下画线处应填入的是( )。
-
fun函数的功能是:通过键盘输入给x所指的整型数组所有元素赋 值。在下画线处应该填写的是( )。#include <stdio.h> #define N 5 void fun(int x[N]) { int m; for(m=N-1;m>=0;m--)scanf("%d",_____); }
-
有以下程序:#include <stdio.h> main() { int a[]={1,2,3,4},y,*p=&a[3];--p; y=*p; printf("y=%d\n",y); }程序的运行结果是( )。
-
有以下程序:#include <stdio.h> main() { int a[]={10,20,30,40},*p=a,i; for(i=0;i<=3;i++) { a[i]=*p; p++; } printf("%d\n",a[2]); }程序运行后的输出结果是( )。
-
有以下程序#include <stdio.h> main() { int i,s=0,t[]={1,2,3,4,5,6,7,8,9}; for(i=0;i<9;i+=2)s+=*(t+i); printf("%d\n",s); }程序执行后的输出结果是( )。
-
执行以下程序段后,s的值为( )。int a[]={1,2,3,4,5,6,7,8,9}, s=0,k; for(k=0;k<8;k+=2) s+=*(a+k);
-
若有以下定义:int x[10],*pt=x;则对x数组元素的正确引用是( )。
-
设有定义double a[10],*s=a;以下能够代表数组元素a[3]的是( )。
-
设有定义:int a[10]={0,1,2,3,4,5,6,7,8,9},*p=a,i;若0≤i≤9,则对a数组元素的引用错误的是( )。