以下程序的功能是输出a数组中所有字符串,请填空。
#include <stdio.h>
main( )
{ char *a[ ]={”ABC”,”DEFGH”,”IJ”,”KLMNOP”};
int i=0;
for(;i<4; i++) printf(”%s\n【 13 】 );
}
第1题:
以下程序段给数组A的所有元素输入数据,请填空。
include<iostream. h>
void main () {
int a[10], i;
i=0;
while (i<10) cin>> 【 】
}
第2题:
下列给定程序中,函数fun()的功能是逐个比较a,b两个字符串对应位置中的字符,把ASCII值小或相等的字符依次存放到c数组中,形成一个新的字符串。
例如:a中的字符串为fshADfg,b中的字符串为sdAEdi,则c中的字符串应为fdAADf。
请改正程序中的错误,使它能得到正确结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
include <stdio.h>
include <strinq.h>
void fun(char *p,char *q,char *c)
{int k=0;
while(*p || *q)
/**********found**************/
{ if (*p<=*q)
c[k]=*q;
else c[k]:*p;
if(*p) p++;
if(*q)q++;
/**+**********found**************/
k++
}
}
main()
{char a[10]="fshADfg",b[10]="sdAEdi",
c[80]={'\0');
fun(a,b,c);
printf("The string a:");puts(a);
printf("The string b:");puts(b);
printf("The result:");puts(c);
}
第3题:
【填空题】下面程序的功能是在一个字符数组中查找一个指定的字符,若数组中含有该字符则输出该字符在数组中第一次出现的位置(下标值);否则输出-1。请分析程序填空。 #include <stdio.h> #include <string.h> main() {char c='a',t[50]; int n,k,j; gets(t); n=【1】; for(k=0,j=-1;k<n;k++) if(【2】) {j=k;break;} printf("%d",j); }
第4题:
以下程序的输出结果是【 】。
include <stdio.h>
include <string.h>
char *fun(char *0
{ char *p--t;
return (p+strlen(t)/2);
}
main()
{ char *str="abcdefgh";
str=ftm(str);
puts(str);
}
第5题:
以下程序的输出结果是【 】。
include <stdio.h>
include <string.h>
char *fun(char *t)
{ char *p=t;
return (p+strlen(t)/2);
}
main()
{ char *str="abcdefgh";
str=ftm(str);
puts(str);
}