更多"函数String(n,'str')的功能是"的相关试题:
[填空题]请补充函数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);
[填空题]请补充函数proc( ),该函数的功能是比较字符串str1和str2的大小,并返回比较的结果。
例如,当str1="abcd",str2="abcc"时,函数proc( )返回“>”,比较结果为“str1>str2”。
注意:部分源程序给出如下。
请勿改动main( )函数和其他函数中的任何内容,仅在函数proc( )的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
#define M 80
char*proc(char*str1,char*str2)
{
char*p1=str1,*p2=str2;
while(*p1&&*p2)
{
if(______)
return"<";
if(______)
return">";
p1++;
p2++;
}
if("p1==*p2)
return"==";
if(*p1==______)
return"<";
else
return">";
}
void main( )
{
char str1[M],str2[M];
system("CLS");
printf("Input str1:/n");
gets(str1);
printf("Input str2:/n");
gets(str2);
printf("/n****the result****/n");
printf("/nstr1%s str2",proc(str1,str2));
}
[填空题]请补充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",______);
}
[填空题]mystrlen函数的功能是计算str所指字符串的长度,并作为函数值返回。请填空。
int mystrlen(char*str)
int i;
for(i=0;______!=’/0’;i++);
return(i);
[填空题]mystrlen函数的功能是计算str所指字符串的长度,并作为函数值返回。请填空。
int mystrlen(char*str)
int i
for(i=0;______!=’/0’;i++);
return(i);
[填空题]请补充main函数,该函数的功能是:从字符串str中取出所有数字字符,并分别计数,然后把结果保存在数组b中并输出,把其他字符保存在N[10]中。
例如:当str1=“ab123456789cde090”时,结果为:
0: 2 1: 1 2: 1 3: 1 4: 1 5: 1 6: 1 7: 1 8: 1 9:2 other charactor:5
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
#include <stdio.h>
#include <conio.h>
main( )
int i,b[11];
char *str="abl23456789cde090";
char *p=str;
clrscr( );
printf("***the origial data ***/n");
puts(str);
for(i=0;i<11;i++)
b[i]=0;
while(*p)
switch( 【1】 )
case ’0’:b[0]++;break;
case ’1’:b[1]++;break;
case ’2’:b[2]++;break;
case ’3’:b[3]++;break;
case ’4’:b[4]++;break;
case ’5’:b[5]++;break;
case ’6’:b[6]++;break;
case ’7’:b[7]++;break;
case ’8’:b[8]++;break;
case ’9’:b[9]++;break;
[多项选择]填空题
请补充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
[填空题]从键盘输入一组小写字母,并保存在字符数组str中。请补充函数fun( ),该函数的功能是:把字符数组str中ASCII码为奇数的小写字母转换成对应的大写字母,结果仍保存在原数组中。
例如,输入“abcdefg”,输出“AbCdEfG”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#define N 80
void fun(char s[])
int i;
for( 【1】 ; 【2】 ;i++)
if( 【3】 )
s[i]-=32;
main( )
char str[N];
clrscr( );
printf("/n lnput a string:/n");
gets(str);
printf("/n*** original string ***/n");
puts (str);
fun (str);
printf("/n*** new string ***/n");
puts (str);
[填空题]请补充函数proc( ),该函数的功能是:把一个整数转换成字符串,并倒序保存在字符数组str中。例如,当n=12345时,str="54021"。
注意:部分源程序给出如下。
请勿改动main( )函数和其他函数中的任何内容,仅在函数proc( )的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
#define M 100
char str[M];
void proc(long int n)
{
int i=0;
while(______)
{
str[i]=______;
n/=10;
i++;
}
______;
}
void main( )
{
long int n=12345;
system("CLS");
printf("***the origial data***/n");
printf("n=%1d",n);
proc(n);
printf("/n%s",str);
}
[单项选择]有如下程序段:
Dim str As String*10
Dim i
Str1="abcdefg"
i=12
len1=Len(i)
str2=Right(str1, 4)
执行后,len1和str2的返回值分别是______。
A. 12,abcd
B. 10,bcde
C. 2,defg
D. 0,cdef
[简答题]请编写函数proc( ),该函数的功能是:计算n门课程的平均分,计算结果作为函数值返回。
例如,有6门课程的成绩是90.5,72,80,61.5,55,60,则函数的值为69.83。
注意:部分源程序给出如下。
请勿改动main( )函数和其他函数中的任何内容,仅在函数proc( )的花括号中填入所编写的若干语句。
试题程序:
#include<stdio.h>
float proc(float*a,int n)
{
}
void main( )
{
float score[30]={90.5,72,80,61.5,55,60},
aver;
aver=proc(score,6);
printf("/nAverage score is:%5.2f/n",aver);
}
[简答题]下列程序定义了N×N的二维数组,并在主函数中赋值。请编写函数fun( ),函数的功能是:求出数组周边元素的平均值并作为函数值返回给主函数中的s。例如:若a数组中的值为
a= 0 1 2 7 9
1 9 7 4 5
2 3 8 3 1
4 5 6 8 2
5 9 1 4 1
则返回土程序后s的值应为3.375。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的仟何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include <stdio.h>
#include<conio.h>
#include<stdlib.h>
#define N 5
double fun (int w[] [N])
{
}
main( )
{
int a[N] [N]={0,1,2,7,9,1,9,7,4,5,2,
3,8,3,1,4,5,6,8,2,5,9,1,4,1};
int i, j;
double s;
clrscr( );
printf("*****The array*****/n ");
for (i=0; i<N; i++)
{ for (j=0;j<N;i++)
{printf("%4d ",a[i] [j]);}
printf("/n ");
}
s=fun(a);
printf("*****THE RESULT*****/n ");
printf("The sum is : %lf/n ",s);
}
[单项选择]假定有以下函数过程: Function Fun(S As String) As String Dim s1 As String For i=1 To Len(S) s1=UCase(Mid(S,i,1))+s1 Next i Fun=S1 End Function 在窗体上画一个命令按钮,然后编写如下事件过程: Private Sub Command1_Click( ) Dim Str1 As String,Str2 As String Str1=Input Box(“请输入一个字符串”) Str2=Fun(Str1) Print Str2 End Sub 程序运行后,单击命令按钮,如果在输入对话框中输入字符串“abcdefg”,则单击“确定”按钮后在窗体上的输出结果为
A. abederg
B. ABCDEFG
C. gfedcba
D. GFEDCBA
[判断题]COUNT函数和COUNTIF函数功能一样,可以任意使用。()
[单项选择]有以下程序,其中函数f的功能是将多个字符串按字典顺序排序:
#include<string.h>
void f(char *p[],int n)
{char *t;int i,j;
for(i=O;i<n-1;i++)
for(j=i+1;j<n;j++)
if strcmp(p[i],p[j])>0{t=p[i] p[i]=p[j]; p[j]=t; }
}
main( )
{char* p[5]=("abc","aabdfg","abbd","dcdbe","cd"};
f(p,5);
printf("%d/n",strlen(p[1]));
}
程序运行后的输出结果是【 】。
A. 2
B. 3
C. 6
D. 4
[填空题]请补充函数fun( ),该函数的功能是:从键盘输入一个下标n,把数组aa中比元素aa[n]小的元素放在它的左边,比它大的元素放在它的右边,排列成的新数组仍然保存在原数组中。
例如,数组aa=33,67,42,58,25,76,85,16,41, 56,输入3。
结果输出“33,42,25,16,41,56,58,67,76,85”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仪在函数fun( )的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#define N 10
void fun(int aa[],int n)
int i,j=0,k=0,t;
int bb[N];
t=aa[n];
for(i=0;i<N;i++)
if(aa[i]>t)
bb[j++]=aa[i];
if(aa[i]<t)
aa[k++]=aa[i];
【1】 ;
for(i=0; 【2】 ;i++, k++)
aa[k]=bb[i];
main( )
int i,n;
int aa[N]=33,67,42,58,25,76,85,16,41,56;
clrscr( );
printf("/n*** original list ***/n");
for(i=0;i<N;i++)
printf("%4d"/aa[i]);
printf("/n suffix n/n");
scanf("%d",&n);
fun(aa,n);
printf("/n*** new list ***/n");
for (i=0;i<N; i++)
printf("%4d", aa[i]);
[简答题]请编写函数fun( ),该函数的功能是:移动一维数组中的内容,若数组中有n个整数,要求把下标从p到n-1(p≤n-1)的数组元素平移到数组的前面。
例如,一维数组中的原始内容为1,2,3,4,5,6,7, 8,9,10,11,12,13,14,15,p的值为6。移动后,一维数组中的内容应为7,8,9,10,11,12,13,14,15,1,2,3,4,5,6。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include<stdio.h>
#define N 80
void fun(int *w,int p,int n)
main( )
int a[N]=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15;
int i,p,n=15;
printf("The original data:/n");
for(i=0;i<n;i++)
printf("%3d",a[i]);
printf("/n/nEnter p:");
scanf("%d",&p);
fun(a,p,n);
printf("/nThe data after moving:/n");
for(i=0;i<n;i++)
printf("%3d",a[i]);
printf("/n/n");
[填空题]下列给定的程序中,函数fun( )的功能是:判断字符ch是否与str所指字符串中的某个字符相同;若相同,则什么也不做,若相同,则将其插在申的最后。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include <conio.h>
#include <stdio.h>
#include <string.h>
/*************found**************/
void fun (char str,char ch)
{while (*str &&*str !=ch) str++;
/*************found**************/
if(*str==ch)
{ str[0]=ch;
/*************found**************/
str[1]=’0’;
}
}
main( )
{char s[81],c;
clrscr( );
printf("/nPlease enter a strzng : ");
gets(s);
printf("/n Please enter the character to
search : ");
c=getchar( );
fun(s,c);
printf("/nThe result is %s/n",s);
}