更多"对于下列字符串,说明表达式strlen(s)值的是( )。 cha"的相关试题:
[单项选择]运算结果是字符串“home”的表达式是( )。
A. LEFT("myhome",4)
B. RIGHT("hometown",4)
C. SUBSTR("myhometown",4,4)
D. SUBSTR("myhometown",3,4)
[填空题]有字符串"Iamastudent",求其长度的函数表达式为()。
[单项选择]从字符串S("abcdefs")中返回子串B("cd")的正确表达式是______。
A. Mid(S,3,2)
B. Right(Left(S,4),2)
C. Left(Right(S,5),2)
D. 以上都可以
[单项选择]若要在文本型字段查询以“Access”开头的字符串,正确的条件表达式是______。
A. like"Access*"
B. like"Access"
C. like"*Access*"
D. like"*Access/
[填空题]以下程序的功能是将字符串s中的数字字符放入d数组中,最后输出d中的字符串。例如,输入字符串:abcl23edf456gh,执行程序后输出:123456。请填空。
#include <stdioo.h>
#include <ctype.h>
main( )
char s[80],d[80]; int i,j;
gets(s);
for(i=j=0;s[i]!=’/0’;i++)
if( 【20】 )d[j]=s[i];j++;
d[j]=’/0’;
puts(d);
[填空题]以下程序中函数huiwen的功能是检查一个字符串是否是回文,当字符串是回文时,函数返回字符串:yes!,否则函数返回字符串:no!,并在主函数中输出。所谓回文,即正向与反向的拼写都一样,例如:adgda。请填空。
#include <string.h>
char *huiwen(char *str)
char *p1,*p2;int i,t=0;
p1=str; p2= (18) ;
for(i=0;i<=strlen(str)/2;i++)
if(*p1++!=*p2--)t=1;break;
if( (19) )return("yes!");
else return("no!");
main( )
char str[50];
printf("Input:");scanf("%s",str);
printf("%s/n", (20) );
[填空题]下面程序是把从终端读入的20个字符作为字符串放在字符数组中,然后利用指针变量输出上述字符串,请填空。
#include<stdio.h>
main( )
int i;char s[21],*p;
for(i=0;i<20;i++)
s[i]=getchar( );
s[i]=______;
p=______;
while(*p) putchar(______);
[填空题]请补充main( )函数,该函数的功能是:从键盘输入一个字符串并保存在字符str1中,把字符串str1中下标为偶数的字符保存在字符串str2中并输出。例如,当str1="computer",则str2="cmue"。
注意:部分源程序给出如下。
请勿改动函数中的任何内容,仅在横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
#define LEN 80
void main( )
{
char str1[LEN],str2[LEN];
char*p1=str1,*p2=str2;
int i=0,j=0;
system("CLS");
printf("Enter the string:/n");
scanf(______);
printf("***the origial string***/n");
while(*(p1+j))
{
printf("______",*(p1+j));
j++;
}
for(i=0;i<j;i+=2)
*p2++=*(str1+i);
*p2="/0";
printf("/nThe new string is:%s/n",______);
}
[多项选择]填空题
请补充main函数,该函数的功能是:从键盘输入一个字符串并保存在字符str1中,把字符串str1中下标为偶数的字符保存在字符串str2中并输出。例如,当str1=“cdefghij”,则str2=“cegi”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
#include
#include
#define LEN 80
main( )
{
char str1[LEN],str2[LEN];
char *p1=str1,*p2=str2;
int i=0,j=0;
clrscr( );
printf("Enter the string:/n");
scanf(【1】);
printf("***the origial string***/n");
while(*(p1+j))
{
printf("【2】",*(p1+j));
j++;
}
for(i=0;i
[单项选择]字符A,B,C一次进入一个栈,按出栈的先后顺序组成不同的字符串,至多可以组成多少个不同的字符串
A. 4
B. 6
C. 2
D. 5
[简答题]编写函数fun,其功能是:求ss所指字符串中指定字符的个数,并返回此值。
例如,若输入字符串“123412132”,输入字符为“1”,则输出3。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入你编写的若干语句。
试题程序:
#include<sfdlib.h>
#include<conio.h>
#include<sfdio.h>
#define M 81
int fun(char*SS,char C)
void main( )
char a[M],ch;
system("CLS");
printfl(/nPlease enter a string:");
getsia);
printf("/nPlease enter a char:");
ch=getchar( );
printf("/nThe number of the char is:%d/n",fun(a,ch));
[填空题]给定程序MODI1.C中函数fun的功能是首先把b所指字符串中的字符按逆序存放,然后将a所指字符串中的字符和b所指字符串中的字符,按排列的顺序交叉合并到c所指数组中,过长的剩余字符接在c所指数组的尾部。例如,当a所指字符串中的内容为“abcdefg”,b所指字符串中的内容为“1234”时,c所指数组中的内容应该为“a4b3c2d1efg”;而当a所指字符串中的内容为“1234”,b所指字符串中的内容为“abcdefg”时,c所指数组中的内容应该为“1g2f3e4dcba”。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!
给定源程序如下。
#include<stdio.h>
#include<string.h>
void fun(char*a,char*b,char*c)
{
int i,j;char ch;
i=0;j=strlen(b)-1;
/***********found************/
while(i>j)
{ ch=b[i];b[i]=b[j];b[j]=ch;
i++; j--;
}
while(*a||*b){
/**************found**********/
If(*a)
{ *c=*a;c++;a++;}
if(*b)
{ *c=*b;c++;b++;}
}
*c=0;
}
main( )
{
char s1[100],s2[100],t[200];
printf("/nEnter s1 string:");scanf("%s",s1);
printf("/nEnter s2 string:");scanf("%s",s2);
fun(s1,s2,t);
printf("/nThe result is:%s/n",t);
}
[单选题]单击'查找下一处'按钮,找到源字符串后,单击()按钮,替换一个字符串.
A.常规
B.查找下一处
C.取消
D.替换
[单项选择]在Excel中输入字符串时,若该字符串的长度超过单元格的显示宽度,则超过的部分最有可能( )。
A. 被截断删除
B. 继续超格显示
C. 给出错误提示
D. 作为另一个字符串存入右侧相邻单元
[简答题]函数fun的功能是:将s所指字符串中ASCII值为奇数的字符删除,串中剩余字符形成一个新串放在t所指的数组中。
例如,若s所指字符串中的内容为:"ABCDEFG12345",其中字符A的ASCII码值为奇数、…、字符1的ASCII码值也为奇数、… 都应当删除,其它依此类推。最后t所指的数组中的内容应是:"BDF24"。
注意: 部分源程序存在文件PROG1.C中。
请勿改动主函数main和其它函数中的任何内容,仅在函数fun的花括号中填入你编写的若干语句。
给定源程序:
#include
#include
void fun(char *s, char t[])
{
}
main( )
{
char s[100], t[100];
printf("/nPlease enter string S:"); scanf("%s", s);
fun(s, t);
printf("/nThe result is: %s/n", t);
NONO( );
}
[填空题]请补充函数fun( ),该函数的功能是:把从主函数中输入的字符串str2接在字符串str1的后面。
例如:str1=“How do”,str2=“you do”,结果输出:How do you do
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<conio.h>
#define N 40
void fun(char *str1,char *str2)
int i=0;
char *p1=str1;
char *p2=str2;
while( 【1】 )
i++;
for( ; 【2】 ;i++)
*(p1+i)= 【3】 ;
*(p1+i)=’/0’;
main( )
char str1[N],str2[N);
clrscr( );
printf("*****Input the string str1 & str2*****/n");
printf("/nstr1:");
gets(str1);
printf("/nstr2:");
gets(str2);
printf("**The string str1 & str2**/n");
puts(str1);
puts(str2);
fun(str1,str2);
printf("*****The new string *****/n");
puts(str1);
[单项选择]在Excel 2003中,若A1单元格中的字符串是“四川师范大学”,A2单元格的字符串是“计算机系”,希望在A3单元格中显示“四川师范大学计算机系招生情况表”,则应在A3单元格中键入的公式为______。
A. =A1&A2&"招生情况表"
B. =A2&A1&"招生情况表"
C. =A1+A2+"招生情况表"
D. =A1-A2-"招生情况表"
[简答题]给定程序MODI1.C中函数 fun 的功能是:将s所指字符串中最后一次出现的与t1所指字符串相同的子串替换成t2所指字符串,所形成的新串放在w所指的数组中。在此处,要求t1和t2所指字符串的长度相同。
例如,当s所指字符串中的内容为:"abcdabfabc",t1所指子串中的内容为:
"ab",t2所指子串中的内容为:"99"时, 结果,在w所指的数组中的内容应为:
"abcdabf99c"。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!
给定源程序:
#include
#include
int fun (char *s, char *t1, char *t2 , char *w)
{
int i; char *p , *r, *a;
strcpy( w, s );
/************found************/
while ( w )
{ p = w; r = t1;
while ( *r )
/************found************/
IF ( *r == *p )
{ r++; p++; }
else break;
if ( *r == ’/0’ ) a = w;
w++;
}
r = t2;
while ( *r ){ *a = *r; a++; r++; }
}
main( )
{
char s[100], t1[100], t2[100], w[100];
printf("/nPlease enter string S:"); scanf("%s", s);
printf("/nPlease enter substring t1:"); scanf("%s", t1);
printf("/nPlease enter substring t2:"); scanf("%s", t2);
if ( strlen(t1)==strlen(t2) )
{ fun( s, t1, t2, w);
printf("/nThe result is : %s/n", w);
}
else printf("/nError : strlen(t1) != strlen(t2)/n");
}