网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)

设有以下语句,若0<k<4,下列选项中不能对数组中字符串的正确引用的是()。 char str[4][12]={"aaa","bbb","ccc","ddd"},*strp[4]; int j; for(j=0;j<4;j++) strp[j]=str[j];

A.strp

B.*strp

C.strp[k]

D.str[k]


参考答案和解析
C
更多 “设有以下语句,若0<k<4,下列选项中不能对数组中字符串的正确引用的是()。 char str[4][12]={"aaa","bbb","ccc","ddd"},*strp[4]; int j; for(j=0;j<4;j++) strp[j]=str[j];A.strpB.*strpC.strp[k]D.str[k]” 相关考题
考题 以下程序按下面指定的数据给 x 数组的下三角置数,并按如下形式输出,请填空。43 72 6 91 5 8 10#include stdio.hmain(){ int x[4][4],n=0,i,j;for(j=0;j4;j++)for(i=3;i=j; 【 12 】 ) {n++;x[i][j]= 【 13 】 ; }for(i=0;i4;i++){ for(j=0;j=i;j++) printf("%3d",x[i][j]);printf("\n");}}

考题 请补充函数proc,该函数的功能是按条件删除一个字符串指定字符一半的数目,具体要求如下:如果该字符串所包含的指定字符的个数是奇数,则不删除,如果其数目是偶数,则删除原串后半部分的指定字符。其中,str指向原字符串,删除后的字符串存放在b所指的数组中,c中存放指定的字符。例如,当str输入“abcabcabcab”,c=b时,b的输出为“abcabcaca”;如果str的输入为“abcabcabca”,则b的输出为“abcabcabca”。 注意:部分源程序给出如下。 请勿改动main函数和其他函数中的任何内容,仅程函数prOC的横线上填入所编写的若干表达式或语句。 试题程序: includestdlib.h includestdio.h includeconio.h define M 80 void proc(char str[],char b[],char c) { int i=0,j=0; int n=0: int m=0: while(str[i]!=\0) { if(str[i]==c) n++: i++: } 【1】 ; if(n%2) { while(str[j]!=\0 ) { b[j]=str[j]; j++; } b[j]=\0; } else { while(str[i]!=\0 ) { b[j++]=str[i]; if(str[i]==c) m++: if((mn/2)&&(str[i]==c)) 【2】 ; i++: } 【3】 ; } } void main { char str[M],b[M]; char C; system("CLS"); printf("Enter the strin9:\n"); gets(str); printf("Enter the character of the string deleted:"): scanf("%C",&c); proc(str,b,c); printf("The new string is:%s\n",b); }

考题 下列函数的功能是判断字符串str是否对称,对称则返回true,否则返回false。请在横线处填上适当内容,实现该函数。 Boo1 fun (char*str) { int i=0,j=0; while(str[j]j++; for(j--;i<jstr[i]==str[j];i++,j--); return i ______ j; }A.>==B.||C.D.<==

考题 下列程序的运行结果为()。 include voidabc(Char*str) {inta,b,i,j; for(i=j=0;str[i]! 下列程序的运行结果为( )。#include<stdio.h>voidabc(Char*str){ inta,b,i,j;for(i=j=0;str[i]!='\0';i++)if(str[i]!='a')str[j++]=str[i];str[j]='\0';}void main(){ char str[]="abcdef";abc(str);printf("str[]=%s",str);}A.str[]=bcdefB.str[]=abcdefC.str[]=aD.str[]=ab

考题 下列函数的功能是判断字符串str是否对称,对称则返回true,否则返回false。请在画线处填上适当内容,实现该函数。bool fun(char*str)}int i:0,j=0;while(str[j]) (6) ;for(J--;i<jstr[i]==str[J];i++,J--);return i (7) J;}

考题 阅读下列程序,当运行函数时,输入asd af aa z67,则输出为#include#include#includeint fun (char *str){ int i,j=0;for(i=0;str[i]!=′\0′;i++)if(str[i]!=′ ′)str[j++]=str[i];str[j]= ′\0′;}main(){char str[81];int n;clrscr();printf("Input a string : ");gets(str);puts(str);fun(str);printf("%s\n",str);}A.asdafaaz67B.asd af aa z67C.asdD.z67

考题 下列程序的运行结果为()。includevoidabc(char*str){int a,b,i,j;for(i=j=0;str[i]!='\ 下列程序的运行结果为( )。#include<stdio.h>voidabc(char*str){int a,b,i,j;for(i=j=0;str[i]!='\0';i++)if(str[i]!='a')str[j++]=str[j];str[j]='\0';}void main(){char Str[]="abcdef';abc(str);printf("str[]=%s",str);}A.str[]=bcdefB.str[]=abcdefC.str[]=aD.str[]=ab

考题 请补充函数fun(),该函数的功能是:把字符串str中的字符按字符的ASCⅡ码降序排列,处理后的字符串仍然保存在原串中,字符串及其长度作为函数参数传入。例如,如果输入“cdefgh”,则输出为“hgfedc”。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。试题程序:include <stdio.h>define N 80void fun (char s [], int n){int i, j;char ch;for (i=0; i<n; i++)for(j=【 】;j<n;j++)if (s[i]<s [j]){ch=s [j];【 】;s [i] =ch;}main ( ){int i=0, strlen=0;char str [N];clrscr ();printf ("\nInput a string: \n");gets (str);while (str [i] !=' \0'){strlen++;i++;}fun (str, strlen);printf ("\n***display string ***\n");puts (str);}

考题 下列给定程序中,函数fun()的功能是:根据形参m的值(2≤m≤9),在m行m列的二维数组中存放如下所示的数据,由 main()函数输出。例如,若输入2,则输出1 22 4输入4,则输出1 2 3 42 4 6 83 6 9 124 8 12 16请改正程序中的错误,使它能得出正确的结果。注意:不要改动main函数,不得增行或删行,也不得更改程序的结构.试题程序:include <conio.h>include <stdio. h>define M 10int aiM] [MI={0};/***************found*******************/fun( int **a, int m){int j,k;for (j=0; j<m; j++)for (k=0; k<m; k++)/***************found*******************/a[j] [k]=k*j;}main ( ){int i, j, n;clrscr ();printf ("Enter n\n"); scanf ("%d", n);fun (a, n);for (i=0; i<n; i++){ for (j=0;j<n;j++)printf ("%4d ",a[i] [j]);printf ("\n ");}}

考题 函数f_str(char *str,char del)的功能是;将非申字符串str分割成若干个子字符串并输出,del表示分割时的标志字符。例如,若str的值为“66981636666257”,del的值为“6”,调用此函数后,将输出3个子字符串,分别为“981”、“3”和“257”。请将函数f_str中(6)~(8)空缺处的内容填写完整。[函数]void f_str(char *str,char del){ int i,j,len;len = strlen(str);i = 0;while (i<len) {while ( (6) )i++; /* 忽略连续的标志字符 *//* 寻找从srt[i]开始直到标志字符出现的一个子字符串 */j = i+1;while (str[j] !=del str[j] !='\0')j++;(7)="\0"; /* 给找到的字符序列置字符串结束标志 */printf (" %s\t", str [i]);(8);}}

考题 下列给定程序中,函数fun()的功能是:统计字符串substr在字符串srt中出现的次数。例如,若字符串为aaas 1 kaaas,子字符串为as,则应输出2。请改正程序中的错误,使它能得出正确的结果。注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。试题程序:include <stdio.h>fun (char *str, char *substr){int i, j, k, num=0;/*************found**************/for (i=0, str [i], i++)for (j=i, k=O; substr [k]==str [ j ]; k++, j ++ )if (substr [k+l]==' \0'){num++;break;}return num;}main ( ){ char str[80],substr[80];printf("Input a string: ");gets (str);printf("Input a sbustring: ");gets (substr);printf ("%d\n ", fun (str, substr) );

考题 下列程序的运行结果为()。includevoid abc(char*str){int a,b,i,j; for(i=j=0;str[i]!= 下列程序的运行结果为( )。 #include<stdio.h> void abc(char*str) { int a,b,i,j; for(i=j=0;str[i]!='\0';i++) if(str[i]!='a' str[j++]=str[i]; str[j]='\0'; } void main() { char str[]="abcdef"; abc(str); printf("str[]=%s",str); }A.str[]=bcdefB.str[]=abcdefC.str[]=aD.str[]=ab

考题 以下程序是求矩阵a、b的和,结果存入矩阵c中,请填空。 include main() {int a[4][4]={1,2, 以下程序是求矩阵a、b的和,结果存入矩阵c中,请填空。 include<stdio.h> main() {int a[4][4]={1,2,6,7},{0,4,2,-8},{1,4,5,2},{2,4,6,8}}; int b[4][4]={{-4,0,7,9},{2,-7,7,4),{6,9,0,1),{8,8,6,5)}; int i,j,c[4][4]; for(i=0;i<4;i++) for(j=0;j<4;j++) c[i][j]=( ); for(i=0;i<4;i++) for(j=0;j<4;j++) printf("%d",c[i][j]); }

考题 下列函数的功能是判断字符串str是否对称,对称则返回true,否则返回false,则横线处应填上( )。 Bool fun(char*str) { int i=0,j=0; while(str[j])j++; for(j--;i<jstr[i]==str[j];i++,j--); return i______j; }A.>==B.||C.D.<==

考题 有以下程序:include int f(int b[] [4]){int i,j,s=0; for(j=0;j2) 有以下程序: #include <stdio.h> int f(int b[] [4]) { int i,j,s=0; for(j=0;j<4;j++) { i=j; if(i>2) i=3-j; s+=b[i][j]; } return s; } main() { int a[4][4]={{1,2,3,4},{0,2,4,6},{3,6,9,12},{3,2,1,0}}; printf("%d\n",f(a)); } 执行后的输出结果是( )。A.12B.11C.18D.16

考题 若有定义:int a[4][10];,则以下选项中对数组元素a[i][j]引用错误的是_______。 (0<=i<4,0<=j<10)A.*(a[0][0]+10*i+j)B.*(a+i)+jC.*(*(a+i)+j)D.*(a[i]+j)

考题 若有定义:int a[4][10];,则以下选项中对数组元素a[i][j]引用错误的是______。 (o<=i<4,0<=j<=10A.*(a[0][0]+10*i+j)B.*(a+i)+jC.*(*(a+i)+j)D.*(a[i]+j)

考题 以下程序按下现指定的数据给x数组的下三角置数,并按如下形式输出,请填空。43 72 6 91 5 8 10include <stdio.h>main(){ int x[4][4],n=0,i,j;for(j=0;j<4;j++)for(i=3;i>j;【 】) {n++;x[i][j]=【 】:}for(i=0;i<4;i++){ for(j=0;j<=i;j++) printf("%3d",x[i][j]);printf("\n");}}

考题 有以下程序的输出结果是 int f(int b[ ][4]) { int i,j,s=0; for(j=0;j4;j++) { i=j; if(i2) i=3-j; s+=b[i][j]; } return s; } main( ) { int a[4][4]={{1,2,3,4},{0,2,4,5},{3,6,9,12},{3,2,1,0}}; printf(“%d\n”,f(a)); }A.12B.11C.18D.16

考题 下列程序中,定义了一个3行4列的数组A,并将A的内容转换为ASCII码值,并复制到数组B中,然后打印出来。注意:请勿改动main()主方法和其他已有语句内容,仅在横线处填入适当语句。public class Example1_4{private char A[] [] = {{'a', 'b', 'c', 'd'},{'e', 'f', 'g', 'h'},{'i', 'j', 'k', 'l'}};public int ______; //生成一个空的3行4列的数组Bpublic void copy(){for(int i = 0; i < 3; i++)for(int j = 0; j < 4; j++)______;}public static void main(______ argv[]){Example1_4 example = new Example1_4();example.copy();for(int i = 0; i < 3; i ++){for(int j = 0; j < 4; j++)System.out.print(example. B[i] [j] *+" ");System.out.println ();}}}

考题 若有以下程序main(){ int a[4][4]={{1,2,-3,-4},{0,-12,-13,14},{-21,23,0,-24},{-31,32,-33,0}}; int i,j,s=0; for(i=0;i4;i++) { for(j=0;j4;j++) { if(a[i][j]0) continue; if(a[i][j]==0) break; s +=a[i][j]; } } printf("%d\n",s);}程序执行后的输出结果是

考题 设有以下语句: char str[4][12]={"aaa","bbbb","ccccc","dddddd"},*strp[4]; int i; for(i=0;i<4;i++) strp[i]=str[i]; 下列选项不是对字符正确引用的是(其中0≤k<4)( )。A.strpB.str[k][k]C.* strp[k]D.** strp

考题 设有以下语句:其中0≤k5。以下不是对字符串的正确引用的是( )。A.*strpB.strp[k]C.str[k]D.strp

考题 有以下程序:int f(int b[][4]){ int i, j, s=0;for(j=0j2) i=3-j;s+=b[i][j]; 有以下程序:int f(int b[][4]){ int i, j, s=0; for(j=0j<4;j++) { i=j; if(i>2) i=3-j; s+=b[i][j]; } return s;}main(){ int a[4][4]={ { 1,2,3,4}, {0,2,4,6},{3,6,9,12 }, {3,2,1,0} }; printf("%d\n", f(a)); }执行后的输出结果是( )。A.12B.11C.18D.16

考题 有以下程序:int f(int b[][4]){int i, j, s=0;for(j=0; j2)i=3-j;S+=b[i][j]; 有以下程序: int f(int b[][4]) { int i, j, s=0; for(j=0; j<4; j++) { i=j; if(i>2)i=3-j; S+=b[i][j]; } return s; } main() { int a[4][4]={{1, 2, 3, 4}, {0, 2, 4, 6}, {3, 6, 9, 12}, {3, 2, 1, 0}}; printf("%d\n", f(a)); } 执行后的输出结果是______。A.12B.11C.18D.16

考题 用“起泡法”对输入的10个字符排序后按从小到大的次序输出。#define N 10char str[N];main(){ int i,flag;for(flag=1;flag==1;){ scanf("%s",str);flag=0;printf("\n");}sort(___(4)___);for(i=0;iN;I++)printf("%c",str[i]);printf("\n");}sort(char str[N]){ int i,j;char t;for(j=1;jN;J++)for(i=0;(iN-J)(STR[I]!='\0');I++)if(str[i]str[i+1]){ t=str[i];____(5)____;____(6)____;}}

考题 单选题若有以下程序段char str[4][12] = {aa,bbb,ccccc,d},*strp[4];int i;for(i=0;i4;i++)strp[i]=str[i];不能正确引用字符串的选项是(  )。A *strpB str[0]C strp[3]D strp

考题 单选题若有以下程序段,则数组b中列下标为偶数的元素之和是() int a[12],b[3][4],i,j; for(i=0;i12;i++)a[i]=i+1;for(i=0;i3;i++) for(j=0;j4;j++)b[i][j]=a[i*4+j]A 42B 15C 36D 24