更多"InputBox函数可以产生输入对话框。执行下列语句: St$=In"的相关试题:
[单项选择]可以用InputBox函数产生“输入对话框”。执行语句sf$=(InputBox(“请输出字符串”,“字符串对话框”,“字符串”)),当用户输出完毕,按OK按钮后,st$变量的内容是( )。
A. 字符串
B. 请输入字符串
C. 字符串对话框
D. 用户输出的内容
[单项选择]执行下列语句:
strInput=InputBox("请输入字符串","字符串对话框","字符串")
将显示输入对话框。此时如果直接单击“确定”按钮,则变量strInput的内容是( )
A. "请输入字符串"
B. "字符串对话框"
C. "字符串"
D. 空字符串
[单项选择]执行下列语句:
strInput=InputBox("请输入字符串", "字符串对话框", "字符串")
将显示输入对话框。此时如果直接单击“确定”按钮,则变量strInput的内容是( )。
A. "请输入字符串" B) "字符串对话框"
B. "字符串"
C. 空字符串
[简答题]常用字符串函数strcat(s1,s2)可将字符串s2添加到字符串s1的末端,但其使用必须保证字符串s1足够大,以便保存它自己的内容和字符串s2中的内容。请编写一个函数char*append(char*s1,char*s2),其可将字符串s2添加到字符串s1的末端,而且不受s1空间大小的限制。请利用常用字符串函数实现。
常用字符串函数说明:
strcpy(to,form):将form字符串复制到to字符串;
strcat(s1,s2):将字符串s2添加到字符串s1的末端,但必须保证字符串s1足够大;
strlen(s):返回字符串s的长度;
注意:部分源程序已存在文件test4_2.cpp中。
请勿修改主函数main和其他函数中的任何内容,仅在函数append的花括号中填写若干语句。
输出结果如下:
this is a string.
文件test4_2.cpp的内容如下:
#include<iostream.h>
#include<string.h>
char *append(char *s1,char *s2)
void main( )
char *s,*s1,*s2;
s1="this is ";
s2=",a string.";
s=append(s1,s2);
cout<<s<<endl;
[单项选择]从字符串s中的第2个字符开始获得4个字符的子字符串函数是( )。
A. Mid$(s,2,4)
B. Left$(s,2,4)
C. Rigth(s,4)
D. Left$(s,4)
[填空题]在Visual Basic 6.0中,InputBox函数用于产生一个______对话框。
[单项选择]用InputBox函数设计的对话框,其功能是( )
A. 只能接收用户输入的数据,但不会返回任何信息
B. 能接收用户输入的数据,并能返回用户输入的信息
C. 既能用于接收用户输入的信息,又能用于输出信息
D. 专门用于输出信息
[简答题]编写一个函数,用该函数可以统计一个长度为3的字符串在另一个字符串中出现的次数。例如,假定输入字符串“the abcthe they have theren”,子字符串为“the”,则应输出4。
注意:部分源程序在文件PROC2.CPP中。
请勿改动主函数和其他函数中的任何内容,仅在fun( )的花括号中填入编写的若干语句。
部分源程序如下:
//PROC2.CPP
#include <iostream>
using namespace std;
#define MAX 100
int fun(char *str,char *substr);
int main( ){
char str[MAX],substr[3];
int n;
cout<<"Please Input the source String/n";
cin>>str;
cout<<"Please Input the subString/n";
cin>>substr;
n=fun(str, substr);
cout<<"The counter is: "<<n<<end1;
return 0;
}
int fun(char *str,char *substr)
{
//******
}
[单项选择]有以下程序(strcpy为字符串复制函数,strcat为字符串连接函数):
# include <stdio.h>
# include <string.h>
main( )
char a[10]="abc", b[10]="012", c[10]="xyz";
strcpy(a+1, b+2);
puts(strcat(a, c+1));
程序运行后的输出结果是( )。
A. a12xyz
B. 12yz
C. a2yz
D. bc2yz
[简答题]编写一个函数,输入n个字符串,串与串之间以回车键分隔,找出最短字符串中第一个字符串,传回该串地址(用一个新串“*”作为结束输入的标志)。
注意:部分源程序已给出。
请勿改动主函数main和其他函数中的任何内容,仅在函数proc的花括号中填入所编写的若干语句。
试题程序:
#include<stdio.h>
#include<string.h>
#include<conio.h>
char*fun(char(*s)[100],int num)
main( )
char str[10][100],*min;
int n,i=0;
FILE*out:printf("input strings with’*’asend:");
gets(str[i]);
strcpy(str[3],"some");
strcpy(str[4],"tool!";
fprintf(out,"%s",fun(str,5));
puts(str[i]);
while(!strcmp(str[i],"*")==0)
i++;
gets(str[i]);
puts(str[i]);
n=1;
min=fun(str,n);
printf("/nmin=%s/n",min);
out=open("outfile.dat","w");
strepy(str[0],"just,");
strcpy(str[1],"a");
strcpy(str[2],"test");
fclose(out);
[单项选择]以键盘上输入一个实数nu,利用字符串函数对该数进行处理,如果输出的内容不是字符End,则程序输出的内容是( )。
nu:InputBox("nu=")
n $=Str$(nu)
p=InStr(n$,“ . “)
if p>0 Then
Print Mid$(n$.p)
Else
Print“END”
End If
A. 用字符方式输出数据nu
B. 输出数据的整数部分
C. 输出数据的小数部分
D. 只去掉数据中的小数点,保留所有数字输出
[填空题]请补充函数fun( ),该函数可以统计一个长度为n的字符串在另一个字符串中出现的次数。例如,假定输入的字符串为: asd ascasdfg asd as asd mlosd,子字符串为asd,则应输出4。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<string.h>
#include<conio.h>
int fun(char *str,char *substr)
int n;
char *p,*r;
【1】 ;
while(*str)
p=str;
r=substr;
while(*r)
if( 【2】 )
r++;
p++;
else
break;
if( 【3】 )
n++;
str++;
return n;
main( )
char str[81],substr[3];
int n;
clrscr( );
printf("输入主字符串: ");
gets(str);
printf("输入子字符串:");
gets(substr);
puts(str);
puts(substr);
n=fun(str,substr);
printf("n=%d/n",n);
[填空题]以下程序的功能是将字符串s中的数字字符放人d数组中,最后输出d中的字符串。例如,输入字符串abc123edf456gh,执行程序后输出123456。请填空。
# include<stdio. h>
# include<ctype. h>
main( )
char s[80], d[80]; int i, j;
gets(s);
for(i=j=0; s[i]!=’/0’; i++)
if( 【6】 ) d[j]=s[i]; j++;)
d[j]=’/0’;
puts(D) ;
[填空题]以下程序的功能是将字符串s中的数字字符放入d数组中,最后输出d中的字符串。
例如,输入字符串:abc123edf456gh,执行程序后输出:123456。请填空。
#include <stdio.h>
#include <ctype.h>
main( )
char s[80],d[80]; int i,j;
gets(s);
for(i=j=0;s[i]! =’/0’;i++)
if( 【9】 ) d[j]=s[i]; j++;
d[j]=’/0’;
puts(d);