c语言字符数组例题,c语言数组习题(最新整理)

《c语言数组习题(最新整理)》由会员分享,可在线阅读,更多相关《c语言数组习题(最新整理)(16页珍藏版)》请在人人文库网上搜索。

1、第 7 章 数组习题A 卷 1. 单项选择题(1) int a4=5,3,8,9;其中 a3的值为(D )。D A. 5 B. 3 C. 8 D. 9(2) 以下 4 个字符串函数中,( A)所在的头文件与其他 3 个不同。A. gets B. strcpy C. strlen D. strcmp(3) 以下 4 个数组定义中,( D)是错误的。A. int a7; B. #define N 5 long bN;C. char c5; D. int n,dn;(4) 对字符数组进行初始化,(B )形式是错误。A. char c1 =1, 2, 3; B. char c2 =123; C. ch。

2、ar c3 = 1, 2, 3, 0; D. char c4 =123;(5) 在数组中,数组名表示(A )。A. 数组第 1 个元素的首地址 B.数组第 2 个元素的首地址C. 数组所有元素的首地址 D.数组最后 1 个元素的首地址(6) 若有以下数组说明,则数值最小的和最大的元素下标分别是(B ) int a12 =1,2,3,4,5,6,7,8,9,10,11,12;A. 1,12 B. 0,11 C. 1,11 D. 0,12(7) 若有以下说明,则数值为 4 的表达式是(D )。int a12 =1,2,3,4,5,6,7,8,9,10,11,12;char c=a, d, g ;A。

3、. ag-c B. a4 C. ad-c D. ad-c(8) 设有定义:char s12 = string ;则 printf( %dn,strlen(s); 的输出是( A)。A. 6 B. 7 C. 11 D. 12(9) 设有定义:char s12 = string;则 printf(%dn , sizeof(s); 的输出是( B)。A. 6 B. 7 C. 11 D. 12(10) 合法的数组定义是( A)。A. char a = string ; B. int a5 =0,1,2,3,4,5;C. char a= string ; D. char a =0,1,2,3,4,5(1。

4、1) 合法的数组定义是(D )。A. int a3 =0,1,2,3,4,5; B. int a 3 =0,1,2,3,4;C. int a23=0,1,2,3,4,5,6; D. int a23=0,1,2,3,4,5;(12) 下列定义的字符数组中,输出 printf(%sn, str2) ;的输出是(C )。static str320 = basic, foxpro, windows;A. basic B. foxpro C. windows D. 输出语句出错(14) 下列各语句定义了数组,其中哪一个是不正确的( C)。A. char a310=China,American,Asia;。

5、 B. int x22=1,2,3,4; C.float x2 =1,2,4,6,8,10; D. int m3=1,2,3,4,5,6;(15) 数组定义为 int a32=1,2,3,4,5,6,值为 6 的数组元素是(B )。A. a32 B. a21 C. a12 D. a23(16) 下面的程序中哪一行有错误(A )。#include main() float array5=0.0; /第 A 行int i; for(i=0;isk);printf(%dn ,k); (4) 这个程序输入了 20 个数存放在一个数组中,并且输出其中最大者与最小者、20 个数的和及它们的平均值。请填空。。

6、void main() char array; int max,min,average,sum;int i;for(i=0;iarrayi)sum=; average =;printf(20 个数中最大值是%d,max); printf(最小值是%d,min);printf(和是%d,sum);printf(平均值是%d.n,average); 5. 阅读程序,分析程序的功能。(1) #include #include void main( ) char s80; int i ; for(i=0; i0;k-) ak=ak-1;a0=temp; printf(%sn,a); (6) 阅读下列程。

7、序,写出程序运行的输出结果。void main( ) char str1 =*; for(int i=0;i arrayij) min = arrayij; m=i;n=j; printf(min=%d,m=%d,n=%dn,min,m,n); (8) 写出下面这个程序的输出结果:void main() char str=ABCDEFGHIJKL;printf(%sn,str); 屏幕上显示printf(%sn,&str4); 屏幕上显示str2=str5; printf(%sn,str); 屏幕上显示str9=0; printf(%sn,str); 屏幕上显示 (9) 读懂下面的程序并填空。。

8、void main() char str80; int i=0; gets(str); while(stri!=0) if(stri=a&10); for(i=0;in;i+) for(i=2;in;i+) for(j=1;ji;j+);for(i=0;in;i+) for(j=0;ji;j+)printf(%4d,aij);(11) 以下程序的功能是输入一个字符串,如果字符串中有连续的空格,只保留一个空格符。如:输入:I ama boy.,输出字符串应为I am a boy.填空#include string.h main () char b61;int i;gets(b); for(i=0。

9、;i+)if(bi-1= &bi= )(b+i-1,b+i);i-; ;getch();(12) 下列程序的输出结果是。main ()int m=1,2,3,4,5,6,7,8,9,i,j,k;for(i=0;i4;i+)k=mi;mi=m8-i;m8-i=k; for(j=0;j9;j+)printf(%d,mj); putchar(n);本部分参考答案:1. 选择题1-5 D A D B A6-10B D A DA11-15D CC B16-20D C C B C2. 填空题(1)数据类型,0,符号常量,越界(2)连续,数组名,地址( 3) 0,6( 4) 2,0,0( 5) Window。

10、s95( 6) int mesh10; float step4 = 1.9, -2.33, 0, 20.6;(7)int array10 = 9,4,7,49,32,-5; 0 9scanf(%d,&array1); array0 = 39; array0= array5+array3;(8)6 20 16 32 18 24 36 (9)int a10=9,4,12,8,2,10,7,5,1,3; 0 9 8 8(10)103. 判断题 只有 4,6,8 正确4. 程序填空题(1)for(i=0;i20;i+) scanf(“%f”,&ai); pjz/=20; printf(“%f,%fn”。

11、,pjz,t); (2) &ai i%10=0 ai-1(3) k=p(4) 20 20 &arrayi 19 max=arrayi; min=arrayi; sum+arrayi sum/205. 阅读程序,分析程序的功能。(1) 从键盘输入一个字符串,并逐一输出(2) 从键盘输入若干字符串,找到其中最长的一个输出及它的长度(3) 从键盘输入若干字符串,并将它们按大到小顺序排好再输出(4)4 25 27 16(5) gabcdef fgabcde efgabcd (6) * * * *(7)-5.77 2 1(8) ABCDEFGHIJKL EFGHIJKL ABFDEFGHIJKL ABF。

12、DEFGHI(9) 屏幕显示 UPCASE AA1BB2CC(10) ai0=1;aij=ai-1j+ai-1j-1printf(n);(11)i61strcpyputs(b) (12)987654321“”“”At the end, Xiao Bian gives you a passage. Minand once said, people who learn to learn are very happy people. In every wonderful life, learning is an eternal theme. As a professional clerical an。

13、d teaching position, I understand the importance of continuous learning, life is diligent, nothing can be gained, only continuous learning can achieve better self. Only by constantly learning and mastering the latest relevant knowledge, can employees from all walks of life keep up with the pace of enterprise development and innovate to meet the needs of the market. This document is also edited by my studio professionals, there may be errors in the document, if there are errors, please correct, thank you。

你可能感兴趣的:(c语言字符数组例题)