更多"为一个字符序列,序列由字符0和1组成。请补充函数proc( ),该函数"的相关试题:
[填空题]为一个字符序列,序列由字符0和1组成。请补充函数proc( ),该函数的功能是:查找该字符序列中0字符连续出现的最长长度(即0字符的个数),如果有几个0字符串长度相同,只记录最后一个0字符串的相关信息。通过m和返回最长0字符串的长度和最后0字符的下标。例如,如果输入“01000010000”,结果为,字符串最长长度为4,起始和结尾下标依次为2、5。
注意:部分源程序已给出。
请勿改动主函数main和其他函数中的任何内容。
试题程序:
#iinclude<stdlib.h>
#iinclude<stdio.h>
#iinclude<conio.h>
#define M 80
void proc ( (1) )
int i, j=0;
int bb[M];
char *p=str:
*m=0;
*k=0;
for(i=0; i<M; i++)
bb[i]=0;
i=0;
while(*(p+i))
if(*(p+i)==’0’)
(2) ;
i++;
else
j++;
i++;
if( (3) )
*m=bb[j];
*k=i-1;
void main( )
char str[M];
int m, k;
system("CLS");
printf("***input the original string***/n");
gets(str);
printf("***The Original string***/n");
puts(str);
proc(str, &m, &k);
printf("/nThe length of ’0’ is: %d/n", m);
printf("***The suffix of character*
[填空题]str为一个字符序列,序列由字符0和1组成。请补充函数 fun( ),该函数的功能是:查找该字符序列中0字符连续出现的最长长度(即0字符的个数),如果有几个0字符串长度相同,只记录最后一个0字符串的相关信息。通过m和k返回最长0字符串的长度和最后0字符的下标。例如,如果输入“01001000”,结果为:0字符串最长长度为3,起始和结尾下标依次为5、7。
注意:部分源程序给出如下.
请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<conio.h>
#define N 80
void fun ( 【1】 )
{
int i, j=0;
int bb[N];
char *p=str;
*m=0;
*k=0;
for(i=0;i<N;i++)
bb[i]=0;
i=0;
while(*(p+i))
{
if(*(p+i)=’0’)
{
【2】
i++;
}
else
{
j++;
i++;
}
if ( 【3】 )
{
*m=bb[j];
*k=i-1;
}
}
}
main( )
{
char str[N];
int m,n,k;
clrscr( );
printf("***input the original string
***/n");
gets(str);
printf("***The Original string ***/n");
puts(str);
fun(str,&m,&k);
printf("/nThe length of ’0’ is :
%d/n",m);
printf("*** The suffix of character
***/n");
printf(" %d,%d",k-m+1,k);
}
[填空题]请补充main( )函数,该函数的功能是:把一个二维字符数组每行字符串中最大的字符复制到字符数组s中。
例如,如果arr[3]="hoih", "yufui", "xgf",则str="oyx"。
注意:部分源程序已给出。
请勿改动主函数main和其他函数中的任何内容。
试题程序:
#include<stdlib.h>
#include<stdio.h>
void main( )
int i=0;
char *arr[3]="hoih", "yufui", "xgf";
char **p;
char str[8];
system("CLS");
(1) ;
for(i=0; i<3; i++)
str[i]= *p[i];
while(* p[i])
if (str[i]<*p[i])
str[i]=*p[i];
(2) ;
(3) ;
printf("new string/n");
puts(str);
[填空题]请补充main函数,该函数的功能是:把一个字符串中的所有小写字母字符全部转换成大写字母字符,其他字符不变,结果保存原来的字符串中。
例如:当str[N]“123 abcdef ABCDEF!”,结果输出:
“123ABCDEFABCDEF!”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#define N 80
void main( )
int j;
char str[N]="123abcdef ABCDEF!";
char *pf=str;
clrscr( );
printf("*** original string ***/n");
puts(str);
【1】 ;
while(*(pf+j)).
if(*(pf+j)>=’a’&&* (pf+j)<=’z’)
*(pf+j)= 【2】 ;
j++;
else
【3】 ;
printf("****** new string ******/n");
puts(str);
system("pause");
[填空题]请补充main函数,该函数的功能是:从键盘输入一个字符串及一个指定字符,然后把这个字符及其后面的所有字符全部删除。结果仍然保存在原串中。
例如,输入“abcdef”,指定字符为‘e’,则输出“abcd”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include <stdio. h>
#define N 80
main ( )
{
int i=0;
char str [N];
char ch;
clrscr ( );
printf{"/n Input a string:/n");
gets (str);
printf("kn Input a charator;/n");
scanf ("%c", &ch);
while (str [i] !=’/0’)
{
if (str [i]==ch)
【1】
【2】 ;
}
str[i]= 【3】 ;
printf{"/n*** display string ***/n");
puts (str);
}
[填空题]str是一个由数字和字母字符组成的字符串,由变量num传入字符串长度。请补充函数fun( ),该函数的功能是:把字符串str中的数字字符转换成数字并存放到整型数组bb中,函数返回数组bb的长度。
例如:str=“Bcdl23e456hui890”,结果为:123456890。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#define N 80
int bb[N];
int fun(char s[ ],int bb[ ],int num)
{
int i,n=0;
for(i=0;i<num;i++)
{
if( 【1】 )
{
bb[n]= 【2】 ;
n++;
}
}
return 【3】 ;
}
main( )
{
char str[N];
int num=0,n,i;
printf("Enter a string:/n");
gets(str);
while(str[num])
num++;
n=fun(str,bb,num);
printf("/nbb=");
for(i=0;i<n;i++)
printf("%d",bb[i]);
}
[填空题]请补充函数fun( ),该函数的功能是:把从主函数中输入的由数字字符组成的字符串转换成—个无符号长整数,并且逆序输出。结果由函数返回。
例如,输入: 1 2 3 4 5 6,结果输出:6 5 4 3 2 1。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
#include<conio.h>
#include<stdio.h>
#include<string.h>
unsigned long fun(char *s)
unsigned long t=0;
int k;
int i=0;
i=strlen(s);
for( 【1】 ;i>=0;i--)
k= 【2】 ;
t= 【3】 ;
return t;
main( )
char str[8];
clrscr( );
printf("Enter a string made up of’0’to
’9’digital character:/n");
gets(str);
printf("The string iS:%S/n",str);
if(strlen(str)>8)
printf("The string is too long!");
else
printf("The result:%lu/n",
fun(str));
[简答题]填空题
请补充main函数,该函数的功能是:把一个字符串中的所有小写字母字符全部转换成大写字母字符,其他字符不变,结果保存原来的字符串中。
例如:当str[N]=“123 abcdef ABCDEF!”,结果输出:“123 ABCDEF ABCDEF!”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的横线上填入所编写的若干表达式或语句。
试题程序:
#include
#include
#include
#define N 80
void main( )
{
int j;
char str[N]=" 123abcdef ABCDEF!";
char *pf=str;
clrscr( );
printf("***original string ***/n");
puts(str);
【1】;
while(*(pf+j))
{
if(*(pf+j)>=’’a’’&&*(pf+j)<=’’z’’)
{
*(pf+j)=【2】;
j++;
}
else
【3】;
}
printf("******new string******/n");
puts(str);
system("pause");
}
[填空题]请补充main函数,改函数的功能是,把一个二维字符数组每行字符串最大的字符拷贝到字符数组s中。
例如,如果str[3]={"efjh","cfimls","owys"},则s;"hsy"。
注意:部分源程序给出如下.
请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
#inc lude<stdio, h>
main( )
{
int i=0;
char *str [3] ={ "efjh", "efknls",
"owys" };
char **p;
char s [8];
clrscr 0;
【1】;
for (i=O; i<3; i++)
{
s [i] =*p [i];
while (*p [i] )
{
if (S [i] <*p [i] )
s [i] =*p[i];
【2】;
}
}
【3】;
printf(" new string /n");
puts (s);
}
[多项选择]填空题
请补充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