函数String(n,"strsdfsdfsdf")的功能是()A、把数值型数据转换为字符串B、返回由n个"s"字符C、从字符串"strsdfsdfsdf")中取出前n个字符D、从字符串中第n个字符的位置开始取子字符串

函数String(n,"strsdfsdfsdf")的功能是()

  • A、把数值型数据转换为字符串
  • B、返回由n个"s"字符
  • C、从字符串"strsdfsdfsdf")中取出前n个字符
  • D、从字符串中第n个字符的位置开始取子字符串

相关考题:

●试题三请补充函数fun(),该函数的功能是:只保留字符串中的大写字母,删除其他字符,结果仍保存在原来的字符串中,由全局变量m对删除后字符串的长度进行保存。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。试题程序:#includestdio.h#includeconio.hint m;void fun(char *s){int i=0,j=0;char *p=s;while(*(p+i)){if(*(p+i)=′A′*(p+i)=′Z′){(1) ;}(2) ;}s[j]=′\0′;(3) ;}main(){char str[80];clrscr();printf("\nEnter a string:");gets(str);printf("\n\nThe string is:\%s\n",str);fun(str);printf("\n\nThe string of changingis:\%s\n",str);printf("\n\nThe length of changed stringis:\%d\n",m);}

请补充函数fun(),该函数的功能是:依次取出字符串中所有的小写字母以形成新的字符串,并取代原字符串。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。试题程序:include<stdio.h>include<conio.h>void fun(char *s){int i=0;char *p=s;while(【 】){if (*p>='a'*p<='z'){s[i]=*p;【 】;}p++;}s[i]=【 】;}main(){char str[80];clrscr();printf("\nEnter a string:");gets(str);printf("\n\nThe string is:\%s\n",str);fun(str);printf("\n\nThe string of changingis:\%s\n",str);}

请编写函数fun(),该函数的功能是:统计一行字符串中单词的个数,作为函数值返回。一行字符串在主函数中输入,规定所有单词由小写字母组成,单词之间有若干个空格隔开,一行的开始没有空格。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。试题程序:include<string. h>include<stdio, h>define N 80int fun (char *s){}main ( ){char line [N];int num=0;printf ("Enter a string: \n ");gets (line);num=fun (line);printf ("The number of word is: %d\n\n ",num);}

请补充main函数,该函数的功能是:把字符串str中的字符向前移动一位,原来的第一个字符移动到字符串尾,结果仍然保存在原字符串中。例如,输入“how do you do?”,则结果输出“ow do you do?h”。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。试题程序:include <stdio. h>define N 80main(){char str[N], ch;int i;clrscr ();printf("\n Input a string:In");gets (str);printf("\n*** original string ***In");puts (str);ch=str [0];for (i=0;【 】; i++)str [i]=str [i+1];【 】;printf("\n *** new string ***\n");puts (str);}

函数Rdata()实现从文件IN.dat中读取一篇英文文章存入字符串数组string中,请编写函数SortCharA(),其功能是:以行为单位对字符按从小到大的顺序进行排序,排序后的结果仍按行重新存入字爷串数组string中。最后调用函数Wdata(),把结果string输出到OUT.dat文件中。例如,原文:dAe, BfC.CcbbAA结果:,. ABCdefAACbbc原始数据文件存放的格式是:每行的宽度均小于80个字符(含标点符号和空格)。注意:部分源程序已经给出。请勿改动主函数main()、读数据函数Rdata()和输出数据函数Wdata()的内容。include <stdio.h>include <string.h>include <conio.h>char string [50] [80];int maxline = 0; /* 文章的总行数 */int Rdata (void);void Wdata (void);void SortCharA(void){}void main (){ if (Rdata ()){ printf("数据文件 IN. dat 不能打开! \n\007");return;}SortCharA ();Wdata ( );}int Rdata (void){ FILE *fp;int i = 0;char *p;if ((fp = fopen("IN. dat", "r")) == NULL)return 1;while (fgets(string[i], 80, fp) != NULL){ p = strchr(string[i], '\n');if (p)*p = 0;i++;}maxline = i;fclose (fp);return 0;}void Wdata (void){ FILE *fp;int i;fp = fopen("OUT. dat", "w");for (i=0; i<maxline; i++){ printf("%s\n", string[i]);fprintf(fp, "%s\n", string[i]);}fclose (fp);}

请补充函数fun(),该函数的功能是:返回字符数组中指定子符的个数,指定字符从键盘输入。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。试题程序:include <stdio.h>define N 80int fun (char s[],char ch){int i=0, n=0;while(【 】){if(【 】)n++;i++;}【 】;}main ( ){int n;char str[N], ch;clrscr ();printf ("\nInput a string: \n");gets (str);printf ("\nInput a charactor: \n" ;scanf ("%c", ch);n=fun (str, ch);printf("\nnumber of %c:%d", ch, n);}

请编写函数fun(),该函数的功能是:移动字符串中的内容,移动的规则是把第1到第m个字符,平移到字符串的最后,把第m+1到最后的字符移到字符串的前部。例如,字符串中原有的内容为ABCDEFGHIJK,m的值为 3,移动后,字符串中的内容应该是DEFGHIJKABC。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。试题程序:include <stdio. h>include <string.h>define N 80void fun (char *w, int m){}main ( ){char a[N]= "ABCDEFGHIJK";int m;printf ("The origina string : \n");puts (a);printf("\n\nEnter m: ");scanf ("%d", m);fun (a, m);printf (" \nThe string after moving : \n");puts (a);printf ("\n\n");}

请补充函数fun(),该函数的功能是:把字符串str中的字符按字符的ASCⅡ码降序排列,处理后的字符串仍然保存在原串中,字符串及其长度作为函数参数传入。例如,如果输入“cdefgh”,则输出为“hgfedc”。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。试题程序:include <stdio.h>define N 80void fun (char s [], int n){int i, j;char ch;for (i=0; i<n; i++)for(j=【 】;j<n;j++)if (s[i]<s [j]){ch=s [j];【 】;s [i] =ch;}main ( ){int i=0, strlen=0;char str [N];clrscr ();printf ("\nInput a string: \n");gets (str);while (str [i] !=' \0'){strlen++;i++;}fun (str, strlen);printf ("\n***display string ***\n");puts (str);}

请补充main函数,该函数的功能是:从键盘输入一组字符串,以‘*’结束输入,并显示出这个字符串。例如,输入abcdefghi*,结果显示adcdefghi。注意:部分源程序给出如下.请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。试题程序:include<stdio. h>define N 80main (){iht i=-l, j=0;char str IN];clrscr ();printf("\n Input a string \n");do{i++;scanf(【 】);}while(【 】);printf ("\n**display the string** \n");while (j<i){printf (【 】);j++;}}

下列给定程序中,函数fun()的功能是:从N个字符串中找出最长的那个中,并将其地址作为函数值返回。各字符串在主函数中输入,并放入一个字符串数组中。请改正程序中的错误,使它能得出正确的结果。注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。试题程序:include <string.h>include <stdio.h>define N 5define M 81/*************found**************/fun(char (*sq) [N]){int i; char *sp;sp=sq[0];for{i=0;i<N;i++)if(strlen(sp)<strlen(sq[i]))sp=sq[i];/*************found**************/return sq;}main (){char str[N][M], *longest; int i;printf("Enter %d lines:\n ",N);for(i=0;i<N;i++) gets(str[i]);printf("\nThe %d string :\n ",N);for(i=0;i<N;i++) puts(str[i]);longest=fun(str);printf("\nThe longest string :\n ");puts(longest);}

下列给定程序中,函数fun()的功能是:在字符串的最前端加入n个*号,形成新串,并且覆盖原串。注意:字符串的长度最长允许79。请改正函数fun()中的错误,使它能得出正确的结果。注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。试题程序;include <stdio.h>include <strzng.h>include <conio.h>/*****************found***************/void fun(char s[], int n){char a[80],*p;int i;/*****************found***************/s=p;for(i=0; i<n; i++) a[i]='*';do{a[i]=*p;/*****************found***************/i++;}while(*p);a[i]=0;strcpy(s,a);}main(){ int n;char s[80];clrscr();printf("\nEnter a string:");gets(s);printf("\nThe string\%s\n",s);printf("\nEnter n(number of*):");scanf ("%d",n);fun(s,n);printf("\nThe string after inster: \%s\n",s);}

请编写一个函数char *fun(char *s,int n)。函数fun()的功能是将字符串s中的字符“循环左移”n位。例如,输入“ABCDE”,则循环左移2位应输出“CDEAB”,输入“1234567”,循环左移3位应输出“4567123”。注意:部分源程序已存在文件PROC13.cpp中。请勿修改主函数和其他函数中的任何内容,仅在函数fun()的花括号中填写若干语句。文件PROC13.cpp的内容如下://PROC13.cppinclude <iostream>include <string>using namespace std;char *fun(char *s,int n);int main(){char str[81];int n;cout<<"Enter a string(less than 80 char)\n”;cin>>str;cout<<"\n Enter n:";cin>>n;if(n>strlen(str)){cout<<"\n Data overflow";return 0;}cout<<"The result is: "<<fun(str,n)<<end1;return 0;}char *fun(char*s,int n){//* * * * * *}

编写函数fun(),函数的功能是:根据以下公式计算s,计算结果作为函数值返回;n通过形参传入。S=1+1/(1+2)+1/(1+2+3)+…+1/(1+2+3+…+n)例如:若n的值为11时,函数的值为1.833333。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。试题程序:include <conio.h>include <stdio.h>include <string.h>float fun(int n){}main(){int n;float s;clrscr();printf("\nPlease enter N: ");scanf("%d",n);s=fun(n);printf("The result is:%f\n " , s);}

阅读下列程序说明和C++程序,把应填入其中(n)处的字句,写对应栏内。【说明】下面的程序实现了类String的构造函数、析构函数和赋值函数。已知类String的原型为:class String{public:String(coust char * str = NULL); //普通构造函数String( const String other); //拷贝构造函数~String(void); //析构函数String perate =(const String other); //赋值函数private:char * m_data; // 用于保存字符串};//String 的析构函数String:: ~String (void){(1);}//String 的普通构造函数String: :String( const char * str){if (2){m_data = new char[1];*m_data = '\0';}else{int length = strlen(str);m_data = new ehar[ length + 1 ];strepy(m_data, str);}}//拷贝的构造函数String:: String( const String other){ int length = strlen(other. m_data);m_data = new char[ length + 1 ];strepy(m_data, other, m_data); //赋值函数String String::operate = (eonst String other) //{if (3)return * this;delete [] m_clara; //释放原有的内存资源int length = strlen( other, m_data);m_data = new chart length + 1 ];(4);return (5);}

请补充函数fun(),该函数的功能是;删除字符数组中小于等于指定字符的字符,指定字符从键盘输入,结果仍保存例如,输入“abcdefghij”,指定字符为‘d’,则结果输出“defghij”。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。试题程序:include <stdio. h>define N 80void fun (char s[], char ch){int i=0, j=0;while (s [i] ){if (s Iii<ch)【 】;else{【 】i++;}}【 】}main (){char str [N], ch;clrscr ();printf("\n Input a string:\n");gets (str);printf("\n*** original string ***\n");puts (str);printf("\n Input a character:\n");scanf ("%c", ch);fun(str, ch);printf("\n*** new string ***\n");puts (str);}

请补充函数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(【 】;i>=0;i--){k=【 】;t=【 】;}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!");elseprintf("The result:%lu\n",fun(str));}

请编写一个函数fun(),它的功能是将一个数字字符串转换为一个整数(不得调用C语言提供的将字符串转为整数的函数)。例如,若输入字符串“-1234”,则函数把它转换为整数值 -1234。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。试题程序:include <stdio.h>include <string.h>long fun(char *p){}main ( ){char s[6];long n;printf("Enter a string:\n");gets(s);n=fun(s);printf("%ld\n",n);}

已知String类定义如下:class String{public:String(const char *str = NULL); // 通用构造函数String(const String another); // 拷贝构造函数~ String(); // 析构函数String perater =(const String rhs); // 赋值函数private:char *m_data; // 用于保存字符串};尝试写出类的成员函数实现。

已知类 String 的原型为class string{public:string(const char *str=null);//普通构造函数string(const string other);//拷贝构造函数---string(void);string operate=(const string other);//赋值函数private:char * m-data;//用于保存字符串};请编写 string 的上述4 个函数

编写类 String 的构造函数、析构函数和赋值函数已知类 String的原型为:class String{public:String(const char *str = NULL); // 普通构造函数String(const String other); // 拷贝构造函数~ String(void); // 析构函数String perate =(const String other); // 赋值函数private:char *m_data; // 用于保存字符串};请编写 String的上述 4 个函数。

数组str全由大小写字母字符组成。请补充函数fun(),该函数的功能是:把str中的字母转换成紧接着的下一个字母,如果原来的字母为‘z’或‘Z’,则相应地转换成‘a’或‘A’,结果仍保存在原数组中。例如,输入“StudentZz”,则输出“TuvefouAa”。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。试题程序:include<stdio.h>define N 80void fun(char s[]){int i;for(i=0;【 】;i++){if(s[i]=='z'||s[i]='Z')s[i]-=【 】;elses[i]+=【 】;}}main(){char str[N];clrscr();printf("\n Input a string:\n");gets(str);printf("\n*** original string***\n");puts(str);fun(str);printf("\n*** new string***\n");puts(str);}

字符串str由数字字符‘0’和‘1’组成(长度不超过8个字符),可看作二进制数,请补充函数fun(),该函数的功能是:把str字符串转换成十进制数,结果由函数返回。例如,输入“1001”,结果输出:9。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。试题程序:include<stdio.h>include<stdlib.h>include<string.h>int fun(char *str){int n;char *p=str;【 】;p++;while (*p){n=【 】;p++;}return【 】;}main(){char str[9];int i;int n;printf ("Enter a string made up of '0' and'1' digital character:");gets (str);if (strlen(str)>8){printf ("Error:string too longer!please input again !\n\n");exit(0);}for(i=0;str[i];i++)if(str[i]<'0'||str[i]>'1'){printf("Error:%c not is '0'and'1' digital character !\n\n",str[i]);exit(0);}printf("The original string:");puts(str);n=fun(str);printf("\n%s is convered to decimalnumber:%d\n\n",str,n);}

请补充函数fun(char *s),该函数的功能是把字符串中的内容逆置。例如:字符串中原有的字符串为abcde,则调用该函数后,串中的内容变为edcba。注意;部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。试题程序:$include<string.h>include<conio.h>include<stdio.h>define N 81void fun(char*s){int i=0,t,n=strlen(s);for(;【 】;i++){t=*(s+i);【 】;【 】;}}main(){char a[N];clrscr();printf("Enter a string:");gets(a);printf("The original string is:");puts(a);fun(a);printf("\n");printf("The string after modified:");puts(a);}

函数过程如下: FUNCTION FUN( N AS STRING)AS STRING DIM N1 AS STRING FOR I=1 TO LEN(N) N1 =UCASE(MID(N,I, 1)) + N1 NEXT I FUN: N1 END FUNCTION 则S=FUN("uvwxyz")的输出结果为( )。A.uvwxyzB.zyxwvuC.UVWXYZD.ZYXWVU

C语言标准库函数""fgets(string,n,fp)""的功能是()。A、从文件fp中读取长度为n的字符串存入指针string指向的内存B、从文件fp中读取长度为n-1的字符串存入指针string指向的内存C、从文件fp中读取n个字符串存入指针string指向的内存D、从文件fp中读取长度不超过长度为n-1的字符串存入指针string指向的内存

单选题C语言标准库函数""fgets(string,n,fp)""的功能是()。A从文件fp中读取长度为n的字符串存入指针string指向的内存B从文件fp中读取长度为n-1的字符串存入指针string指向的内存C从文件fp中读取n个字符串存入指针string指向的内存D从文件fp中读取长度不超过长度为n-1的字符串存入指针string指向的内存

单选题函数String(n,"strsdfsdfsdf")的功能是()A把数值型数据转换为字符串B返回由n个s字符C从字符串strsdfsdfsdf)中取出前n个字符D从字符串中第n个字符的位置开始取子字符串