题目详情
当前位置:首页 > 计算机考试 > 初级程序员
题目详情:
发布时间:2024-05-25 00:38:23

[单项选择]设S是一个长度为5的字符串,其中的字符各不相同,则计算S中互异的非平凡子串(非空且不同于S本身)数目的算式为()
A. 5+4+3+2+1
B. 5+4+3+2
C. 4+3+2+1+1
D. 4+3+2+1

更多"设S是一个长度为5的字符串,其中的字符各不相同,则计算S中互异的非平凡"的相关试题:

[单项选择]设S是一个长度为5的字符串,其中的字符各不相同,则计算S中互异的非平凡子串(非空且不同于S本身)数目的算式为()
A. 5+4+3+2+1
B. 5+4+3+2
C. 4+3+2+1+1
D. 4+3+2+1
[填空题]创建一个教师表(JS.dbf),其中有字段gh(工号,字符型,长度为6)、xm(工号,字符型,长度为10)、xb(性别,字符型,长度为2)、csrq(出生日期,日期型)、JL(教师简历,备注型,且允许为空值)。 CREATE TABLE JS(gh c(6),xm C(10),xb c(2),csrq D,jl M ___( )___)
[简答题]编写一个函数,用该函数可以统计一个长度为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) { //****** }
[简答题]设有一个长度为s的字符串,其字符顺序存放在一个一维数组的第1至第s个单元中(每个单元存放一个字符)。现要求从此字符串的第m个字符以后删除长度为t的子串,m<s,t<(s-m),并将删除后的结果复制在该数组的第s单元以后的单元中,试设计此删除算法。
[简答题]设有一个长度为S的字符串,其字符顺序存放在一个一维数组的第1至第s个单元中(每个单元存放一个字符)。现要求从此字符串的第m个字符以后删除长度为t的子串,m<s,t<(s-m),并将删除后的结果复制在该数组的第s单元以后的单元中,试设计此删除算法。
[多项选择]填空题 请补充main函数,该函数的功能是:从一个字符串中截取前面若干个给定长度的子字符串。其中,str1指向原字符串,截取后的字符存放在str2所指的字符数组中,n中存放需截取的字符个数。 例如:当str1=“cdefghij”,然后输入4,则str2=“cdef”。 注意:部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。 试题程序: #include #include #define LEN 80 main( ) { char str1[LEN],str2[LEN]; int n,i; clrscr( ); printf("Enter the string:/n"); gets(str1); printf("Enter the position of the string deleted:"); scanf(【1】); for(i=0;i
[填空题]请补充main函数,该函数的功能是:从一个字符串中截取前面若干个给定长度的子字符串。其中,str1指向原字符串,截取后的字符存放在str2所指的字符数组中,n中存放需截取的字符个数。
例如:当str1=“cdefghij”,然后输入4,则str2=“cdef”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<conio.h>
  #define LEN 80
main( )

char str1[LEN],str2[LEN];
int n,i;
clrscr( );
printf("Enter the string:/n");
gets(str1);
printf "Enter the position of the string deleted:");
scanf( 【1】 );
for(i=0;i<n;i++)
【2】
str2[i]=‘/0’;
printf("The new string is:%s/n", 【3】 );

[简答题]编写一个函数findStr( ),该函数统计一个长度为2的子字符串在另一个字符串中出现的次数。例如,假定输入的字符串为"asd asasdfg asd as zx67 asd mklo",子字符串为"as",函数返回值是6。
函数ReadWrite( )实现从文件in.dat中读取两个字符串并调用函数findStr( ),最后把结果输出到文件out.dat中。
注意:部分程序已经给出。
请勿改动主函数main( )和其他函数中的任何内容,仅在函数findStr( )的花括号中填入你编写的若干语句。
#include <stdio.h>
#include <string.h>
#include <conio.h>
int findStr(char *str,char *substr)


main( )

char str[81],substr[3];
int n;
clrscr( );
printf("输入原字符串");
gets(str) ;
printf("输入子字符串:");
gets(substr);
puts(str);
puts(substr);
n=findStr(str, substr);
printf("n=%d/n", n);
ReadWrite( );

ReadWrite( )

char str[81],substr[3],ch;
int n, len,i=0;
FILE *rf, *wf;
rf=fopen("in.dat", "r");
wf=fopen("out.dat", "w");
while(i<25)

fgets(str, 80, rf);
fgets(substr, 10, rf);
len=strlen(substr)-1;
ch=substr[l
[单项选择]若字符串s的长度为n(n>1),且其中的字符互不相同,则s的长度为2的子串有()个。
A. n
B. n-1
C. n-2
D. 2
[多项选择]编写函数fun,其功能是:删除一个字符串中指定下标的字符。其中,a指向原字符串,删除指定字符后的字符串存放在b所指的数组中,n放指定的下标。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入你编写的若干语句。
试题程序:
#include<stdio.h>
#include<conio.h>
#define LEN 20
void fun(char a[], char b[], int n)


void main( )
char str1[LEN], str2[LEN];
int n;
printf("Enter the string:/n");
gets(str1);
printf("Enter the position of the string deleted:");
scanf("%d",&n);
fun(str1, str2, n);
printf("The new string is:%s/n", str2);

[填空题]请补充函数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);
[简答题]函数fun的功能是:读入一个字符串(长度<20),将该字符串中的所有字符按ASCII码升序排序后输出。
例如,若输入:edcba,则应输出:abcde。
请改正程序中的错误,使它能得到正确结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
[试题源程序]
#include<stdio.h>
void fun(char t[])

Char c;
int i,j;
/**********found***********/
for(i=strlen(t);i;i--)
for(j=0;j<i;j++)
/**********found***********/
if(t[j]<t[j+1])

c=[j];
t[j]=t[j+1];
t[j+1]=c;


main( )

char s[81];
printf("/nPlease enter a character string:");
gets(s);
printf("/n/nBefore sorting:n/"%s/"",s);
fun(s);
printf("/nAfter sorting decendingly:/n/"%s/"",s);

[填空题]下列给定程序中,函数fun( )的功能是:读入一个字符串 (长度<20),将该字符串中的所有字符按ASCII码降序排序后输出。
例如:输入dafhc,则应输出hfdca。
请改正程序中的错误,使它能得到正确结果。
注意:不要改动main函数,不得增行或删行,敢不得更改程序的结构。
试题程序:
#include <conio.h>
#include <stdio.h>
/*************found**************/
int fun(char t[ ])

char c;
int i,j;
for(i=0;i<strlen(t)-1;i++)
for(j=i+1;i<strlen(t);j++)
if(t[i]<t[j])

c=t[j];
/*************found**************/
t[i]=t[i++];
t[i]=c;

main( )

char s[81];
clrscr( );
printf("/nPlease enter a character
string:");
gets(s);
printf("/n/nBefore sorting:/n%S",s);
fun(s);
printf("/nAfter sorting decendingly:/n
%s",s);

[填空题]下列给定程序中,函数fun( )的功能是:读人一个字符串(长度<20),将该字符串中的所有字符按ASCⅡ码降序排序后输出。
#include<stdio.h>
void fun(char t[])

char c;
int i,j;
for(i=0;______;i++)/*第一空*/
for(j=i+1;j<=strlen(t);j++)
if(______)/*第二空*/

c=t[j];
t[j]=t[i];
t[i]=c;


main( )

char s[81];
printf("Please enter a character string:/n");
gets(s);
printf("/n/nBefore sorting:/n%s",s);
______;/*第三空*/
printf("/nAfter sorting decreasingly:/n%s/n",s);

我来回答:

购买搜题卡查看答案
[会员特权] 开通VIP, 查看 全部题目答案
[会员特权] 享免全部广告特权
推荐91天
¥36.8
¥80元
31天
¥20.8
¥40元
365天
¥88.8
¥188元
请选择支付方式
  • 微信支付
  • 支付宝支付
点击支付即表示同意并接受了《购买须知》
立即支付 系统将自动为您注册账号
请使用微信扫码支付

订单号:

请不要关闭本页面,支付完成后请点击【支付完成】按钮
恭喜您,购买搜题卡成功
重要提示:请拍照或截图保存账号密码!
我要搜题网官网:https://www.woyaosouti.com
我已记住账号密码