更多"字符A,B,C一次进入一个栈,按出栈的先后顺序组成不同的字符串,至多可"的相关试题:
[填空题]以下程序的功能是将字符串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);
[简答题]给定程序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");
}
[填空题]下面程序是把从终端读入的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
[填空题]给定程序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);
}
[简答题]函数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( );
}
[单项选择]用于获得字符串s从第3个字符开始的3个字符的函数是
A. Mid$(s,2,3)
B. Middle$(s,2,3)
C. Right$(s,2,3)
D. Left$(s,1,3)
[单选题]单击'查找下一处'按钮,找到源字符串后,单击()按钮,替换一个字符串.
A.常规
B.查找下一处
C.取消
D.替换
[单项选择]用于获得字符串S从第3个字符开始的2个字符的函数是( )。
A. Mid(S,3,2)
B. Middle(S,3,2)
C. Left(S,3,2)
D. Right(S,3,2)
[单项选择]用于获得字符串Str从第2个字符开始的3个字符的函数是( )。
A. Mid(Str,2,3)
B. Middle(Str,2,3)
C. Right(Str,2,3)
D. Left(Str,2,3
[单项选择]在Excel中输入字符串时,若该字符串的长度超过单元格的显示宽度,则超过的部分最有可能( )。
A. 被截断删除
B. 继续超格显示
C. 给出错误提示
D. 作为另一个字符串存入右侧相邻单元
[单项选择]用于获得字符串S最左边4个字符的函数是
A. Left(S,4)
B. Left(1,4)
C. Leftstr(S)
D. Leftstr(3,4)
[简答题]函数fun的功能是将s所指字符串中下标为偶数同时ASCII值为奇数的字符删除,s所指串中剩余的字符形成的新串放在t所指的数组中。
例如,若s所指字符串中的内容为“ABCDEFG12345”,其中,字符C的ASCII码值为奇数,在数组中的下标为偶数,因此必须删除;而字符1的ASCII码值为奇数,在数组中的下标也为奇数,因此不应当删除,其他依此类推。最后t所指的数组中的内容应是“BDF12345”。
注意:部分源程序存在文件PROG1.C中。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入编写的若干语句。
给定源程序如下。
#include<stdio.h>
#include<string.h>
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);
}
[填空题]请补充函数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);
[简答题]下列程序的功能是:把s字符串中所有的字符左移一个位置,串中的第一个字符移到最后。请编制函数chg(char*s)实现程序要求,最后调用函数readwriteDat( )把结果输出到out61.dat文件中。
例如:s字符串中原有内容为Mn,123xyZ,则调用该函数后,结果为n,123xyZM。
注意:部分源程序已给出。
请勿改动主函数main( )和输入输出函数readwriteDAT( )的内容。
[试题程序]
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#defiRe N 81
void readwriteDAT( );
void chg(char*s)
voidmain( )
char a[N];
system("CLS");
printf("Enter a string:");
gets(a);
printf("The original string is:");
puts(a);
chg(a);
print f("The string after modi fied:");
puts(a);
readwriteDAT( );
void readwriteDAT( )
int i;
char a[N];
unsigned char*P;
FILE*rf,*wf;
rf=fopen("in61.dat","r");
wf=fopen("out61.dat","w");
for(i=0;i<10;i++)
fgets(a,80,rf);
P=strchr(a,’/n’);
if(P) *P=0;
chg(a);
fprintf(wf,"%s/n’,a);
fclose(rf);
fclose(wf);
[单项选择]在Excel 2003中,若A1单元格中的字符串是“四川师范大学”,A2单元格的字符串是“计算机系”,希望在A3单元格中显示“四川师范大学计算机系招生情况表”,则应在A3单元格中键入的公式为______。
A. =A1&A2&"招生情况表"
B. =A2&A1&"招生情况表"
C. =A1+A2+"招生情况表"
D. =A1-A2-"招生情况表"
[简答题]给定程序中,函数fun的功能是将参数给定的字符串、整数、浮点数写到文本文件中,再用字符串方式从此文本文件中逐个读入,并调用库函数atoi和atof将字符串转换成相应的整数、浮点数,然后将其显示在屏幕上。
请在程序的下划线处填入正确的内容并把下划线删除, 使程序得出正确的结果。
注意:源程序存放在考生文件夹下的BLANK1.C中。不得增行或删行,也不得更改程序的结构!
给定源程序:
#include
#include
void fun(char *s, int a, double f)
{
/**********found**********/
__1__ fp;
char str[100], str1[100], str2[100];
int a1; double f1;
fp = fopen("file1.txt", "w");
fprintf(fp, "%s %d %f/n", s, a, f);
/**********found**********/
__2__ ;
fp = fopen("file1.txt", "r");
/**********found**********/
fscanf(__3__,"%s%s%s", str, str1, str2);
fclose(fp);
a1 = atoi(str1);
f1 = atof(str2);
printf("/nThe result :/n/n%s %d %f/n", str, a1, f1);
}
main( )
{ char a[10]="Hello!"; int b=12345;
double c= 98.76;
fun(a,b,c);
}