网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)

使用void setLength(int length)设置字符串长度时,如果length大于原字符串长度,那么将会在字符串后面补上()

  • A、字符‘/u0000’
  • B、不做任何操作
  • C、任意字符
  • D、补0

参考答案

更多 “使用void setLength(int length)设置字符串长度时,如果length大于原字符串长度,那么将会在字符串后面补上()A、字符‘/u0000’B、不做任何操作C、任意字符D、补0” 相关考题
考题 试题四(共 15分)阅读以下说明和C函数,将解答填入答题纸的对应栏内。【说明】函数del_substr(S,T)的功能是从头至尾扫描字符串 S, 删除其中与字符串T相同的所有子串,其处理过程为:首先从串 S 的第一个字符开始查找子串 T,若找到,则将后面的字符向前移动将子串T覆盖掉,然后继续查找子串T,否则从串S的第二个字符开始查找,依此类推,重复该过程,直到串S的结尾为止。该函数中字符串的存储类型 SString定义如下:typedef struct {char *ch; /*串空间的首地址*/int length; /*串长*/}SString;【C函数】void del_substr(SString *S, SString T){int i, j;if ( S-length 1 || T.length 1 || S-length T.length )return;i = 0; /* i为串S中字符的下标 */for ( ; ; ) {j = 0; /* j为串T中字符的下标 */while ( i S-length j T.length ) { /* 在串S中查找与T相同的子串 */if ( S-ch[i]==T.ch[j] ) {i++; j++;}else {i = (1) ; j = 0; /* i值回退,为继续查找T做准备 */}}if ( (2) ) { /* 在S中找到与T相同的子串 */i = (3) ; /* 计算S中子串T的起始下标 */for(k = i+T.length; kS-length; k++) /* 通过覆盖子串T进行删除 */S-ch[ (4) ] = S-ch[k];S-length = (5) ; /* 更新S的长度 */}else break; /* 串S中不存在子串T*/}}

考题 使用voidsetLength(intlength)设置字符串长度时,如果length大于原字符串长度,那么将会在字符串后面补上()。 A.字符‘\u0000’B.不做任何操作C.任意字符D.补0

考题 阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内。【说明】字符串在程序设计中扮演着重要角色。现需要设计字符串基类string,包含设置字 符串、返回字符串长度及内容等功能。另有一个具有编辑功能的串类edlt_string,派生于string,在其中设置一个光标,使其能支持在光标处的插入、删除操作。【程序】include <iostream.h>include <stdio.h>include <string.h>class string{int length;char *data;public:int get_length() {return length;}char *get_data() {return data;}~string() {delete data;}int set data(int in_length, char *in_data);int set_data(char *data);void print() {cout<<data<<endl;}};class edit_string: public string{int cursor;public:int get_cursor() {return cursor;}void move_cursor(int dis) {cursor=dis;}int add_data(string *new_data);void delete_data(int num);};int string::set_data(int in_length,char *in_data){length=in_length;if(!data)delete data;(1)strcpy(data,in_data);return length;}int string::set data(char *in_data){(2)if(!data)delete data;(1)strcpy(data,in_data);return length;}int edit_string::add_data(string *new_data){int n,k,m;char *cp,*pt;n=new_data->get_length();pt=new_data->get_data();cp=this->get_data();m=this->get_length();char *news=new char[n+m+1];for(int i=0; i<cursor; i++)news[i]=cp[i];k=i;for(int j=0; j<n; i++,j++)news[i]=pt[j];cursor=i;for(j=k; j<m; j++,i++)(3)news[i]='\0';(4)delete news;return cursor;}void edit string::delete_data( int num){int m;char *cp;cp=this->get_data();m=this->get_length();for(int i=cursor; i<m; i++)(5)cp[i]='\0';}

考题 请使用VC6或使用【答题】菜单打开考生目录proj3下的工程文件proj3,此工程中包含一个源程序文件proj3.cpp,补充编制c++程序proj3.cpp,其功能是读取文本文件in.dat中的全部内容,将文本存放到doc类的对象myDoc中。然后将myDoc中的字符序列反转,并输出到文件out.dat中。文件in.dat的长度不大于1000字节。 要求: 补充编制的内容写在“//**********”与“//**********”两行之间。实现将myDoc中的字符序列反转,并将反转后的序列在屏幕上输出。不得修改程序的其他部分。 注意:程序最后已将结果输出到文件0ut.dat中,输出函数writeToFile已经给出并且调用。 //proj3.cpp includeiostream includefstream includecatting using namespace std;class doc { private: char*sir;//文本字符串首地址 int length;//文本字符个数 public: //构造函数,读取文件内容,用于初始化新对象,filename是文件名字符串首地址 doc(char*filename); void reverse;//将字符序列反转 一doc; void writeToFile(char*filename); }; doc::doc(char}filename) { ifstream myFile(filename); int len=1001,tmp; atr=new char[1en]; length=0; while((trap=myFile.get)!=EOF) { str[1ength++]=trap; } str[1ength]=‘\0’; myFile.close; } void doc::reverse{ //将数组atr中的length个字符中的第一个字符与最后一个字符交换,第二个字符与倒数第二个 //字符交换…… //*************333*************//*************666*************} doc::~doe { delete[]str; } void doc::writeToFile(char*filename) { Ofstream outFile(filename); outFilestr; outFile.close; } void main { doc myDoc(”in.dat”); myDoc.reveme; myDoc.writeToFile(”out.dat”); }

考题 顺序执行下面的语句后,输出的结果是______。public class exl6{public static void main(String[] args){int i;int a[] = new int[10];for(i = O; i < a.length; i++)a[i] = i * 10 + j;for(i = 1; i < a.length; i++)if(a[i]%5 == O)System,out.println(a[i]);}}

考题 下面程序运行时输出结果为______。 include include class Rect { public: Rect(int 下面程序运行时输出结果为______。include<iostream.h>includeclass Rect{public:Rect(int l, int w){length=l; width=w;)void Print(){cout<<"Area:"<<length*width<<end1;}void operator delete(void*p){free(p);}private:int length, width;};void main(){Rect *p;p=new Rect(5, 4);p->Print();delete p;}

考题 指出下面程序段中的错误,并说明出错原因【 】。class Location {int X, Y=20;protected:int zeroX, zeroY;int SetZero(int ZeroX, iht ZeroY);private:int length, height;public:float radius;void init(int initX,int initY);int GetX();Int GetY();};

考题 Youarecreatingaservletthatgeneratesstockmarketgraphs.Youwanttoprovidethewebbrowserwithpreciseinformationabouttheamountofdatabeingsentintheresponsestream.WhichtwoHttpServletResponsemethodswillyouusetoprovidethisinformation?()A.response.setLength(numberOfBytes);B.response.setContentLength(numberOfBytes);C.response.setHeader(Length,numberOfBytes);D.response.setIntHeader(Length,numberOfBytes);E.response.setHeader(Content-Length,numberOfBytes);F.response.setIntHeader(Content-Length,numberOfBytes);

考题 下面程序运行时输出结果为【】。 include include class Rect { public: Rec 下面程序运行时输出结果为【 】。include<iostream.h>include<malloc.h>class Rect{public:Rect(int1,int w)(length=1;width=w;)void Print(){cout<<"Area:"<<length *width<<endl;)void *operator new(size-t size){return malloc(size);}void operator delete(void *p){free(p)private:int length,width;};void main(){Rect*p;p=new Rect(5,4);p->Print();delete p;}

考题 阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内。[说明]下面程序输出一个矩形面积,以及矩形区域上的假想的作物产量。[C++程序]include <iostream.h>class crop_assessment{int actual_crop;int ideal_crop;public:void set(int in_actual,int in_ideal){actual crop=in_actual;ideal_crop=in_ideal;}int get_actual_crop(void){ (1) ;}int get_ideal_crop(void){ (2) ;)};Class lot_size{int length;int width;(3) crop;public:void set(int 1,int w,int a,int i){length=1;width=w;crop.set(a,i);}int get_area(void){return length*width;}int get_data(void){return (4) ;}int get_data2(void)freturn (5) ;}}int main(){Los_size small,medium;small.set(5,5,5,25);medium.set(10,10,10,50);cout<<"For a small lot of area"<<smallget_area()<<“\n”;cout<<"the actual crops are$"<<small.get_data2()<<"\n";cout<<"and ideal crops are$”<<small.get_data()<<"\n";cout<<"For a medium Lot of area"<<medium.get area()<<:\n”;cout<<"the actual crops are$"<<medium.get_data2()<<"\n";cout<<"and ideal crops are$"<<medium.get_data()<<"\n";return 0;}

考题 阅读下列程序说明和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);}

考题 函数ReadDat()的功能是实现从文件IN74.DAT中读取一篇英文文章存入到字符串数组XX中。请编制函数StrCharJL(),该函数的功能是:以行为单位把字符串中的所有字符的ASCⅡ值左移4位,如果左移后,其字符的ASCⅡ值小于等于32或大于100,则原字符保持不变,否则就把左移后的字符ASCⅡ值再加-上原字符的ASCⅡ值,得到的新字符仍存入到原字符串对应的位置。最后把已处理的字符串仍按行重新存入字符串数组XX中,最后调用函数WriteDat()把结果xx输出到文件OUT74.DAT中。注意:部分源程序已给出。原始数据文件存放的格式是:每行的宽度均小于80个字符,含标点符号和空格。请勿改动主函数main()、读函数ReadDat()和写函数WriteDat()的内容。试题程序:include<stdio.h>include<string.h>include<conio.h>char xx[50][80];int maxline=0;int ReadDat(void);void WriteDat(void);void StrCharJL(void){}void main()clrscr();if(ReadDat()){printf ("数据文件 IN74.DAT 不能打开\n\007");return;}StrCharJL();WriteDat();}int ReadDat (void){FILE *fp;int i=0;char *p;if((fp=fopen("IN74.DAT","r"))==NULL) return 1;while (fgets(xx[i],80,fp)!=NULL){p=strchr(xx[i],'\n');if(p) *p=0;i++;}maxline=i;fclose(fp);return 0;}void WriteDat (void ){FILE *fp;int i;clrscr();fp=fopen("OUT74.DAT","w");for(i=0;i<maxline;i++){printf("%s\n",xx[i]);fprintf(fp, "%s\n", xx[i]);}fclose(fp);}

考题 public class Something {void doSomething () {private String s = "";int l = s.length();}}有错吗?

考题 有以下程序:include using namespace std;class A{private: int x,y;public: void se 有以下程序: #include <iostream> using namespace std; class A { private: int x,y; public: void set (int i,int j) { x=i; y=j; } int get_y() { return y; } }; class box { private: int length,width; A label; public: void set(int 1,int w, int s,int p) { length=1; width=w; label.set(s,p); } int get_area() { return length*width; } }; int main() { box small; small.set(2,4,1,35); cout<<small.get_area()<<end1; return 0; } 运行后的输出结果是( )。A.8B.4C.35D.70

考题 在下面的函数声明中,存在语法错误的是______ 。A.void BC (int a,int)B.void BD (int,int)C.void BE (int,int =5)D.void BF (int x;int y)

考题 在下面程序运行includeint func(char s[]){ int length=0; while(*(s+length))leng 在下面程序运行 #include<iostream.h> int func(char s[]){ int length=0; while(*(s+length))length++; return length; } void main(){ char a[10], *ptr=a; cin>>ptr; cout<<fune(ptr)<<end1; } 如果输入字符串Hello!并回车,则输出结果为 ______。A.4B.7C.6D.5

考题 根据下面函数原型编写一个函数,求出并返回由字符指针a所指向的字符串中包含的字符’a’和’A’的总个数。int void fun(char* a);

考题 当使用setLength(int length)时,如果length的长度小于原字符串的长度,那么进行setLength操作后当前字符串的长度为length,且后面的字符被删除

考题 int intArray[]={0,2,4,6,8}; int length=int Array.length()。

考题 Which code fragments will succeed in printing the last argument given on the command line to the standard output, and exit gracefully with no output if no arguments are given?()   CODE FRAGMENT a:   public static void main(String args[]) {   if (args.length != 0)   System.out.println(args[args.length-1]);   }   CODE FRAGMENT b:   public static void main(String args[]) {   try { System.out.println(args[args.length]); }   catch (ArrayIndexOutOfBoundsException e) {}   }   CODE FRAGMENT c:   public static void main(String args[]) {   int ix = args.length;   String last = args[ix];   if (ix != 0) System.out.println(last);   }   CODE FRAGMENT d:   public static void main(String args[]) {   int ix = args.length-1;   if (ix  0) System.out.println(args[ix]);   }   CODE FRAGMENT e:   public static void main(String args[]) {   try { System.out.println(args[args.length-1]);  }catch (NullPointerException e) {}   }  A、Code fragment a.B、Code fragment b.C、Code fragment c.D、Code fragment d.E、Code fragment e.

考题 单选题Which code fragments will succeed in printing the last argument given on the command line to the standard output, and exit gracefully with no output if no arguments are given?()   CODE FRAGMENT a:   public static void main(String args[]) {   if (args.length != 0)   System.out.println(args[args.length-1]);   }   CODE FRAGMENT b:   public static void main(String args[]) {   try { System.out.println(args[args.length]); }   catch (ArrayIndexOutOfBoundsException e) {}   }   CODE FRAGMENT c:   public static void main(String args[]) {   int ix = args.length;   String last = args[ix];   if (ix != 0) System.out.println(last);   }   CODE FRAGMENT d:   public static void main(String args[]) {   int ix = args.length-1;   if (ix  0) System.out.println(args[ix]);   }   CODE FRAGMENT e:   public static void main(String args[]) {   try { System.out.println(args[args.length-1]);  }catch (NullPointerException e) {}   }A Code fragment a.B Code fragment b.C Code fragment c.D Code fragment d.E Code fragment e.

考题 单选题使用void setLength(int length)设置字符串长度时,如果length大于原字符串长度,那么将会在字符串后面补上()A 字符‘/u0000’B 不做任何操作C 任意字符D 补0

考题 单选题MAX_LENGTH是int型public成员变量,变量值保持为常量100,其定义是()。A final public int MAX_LENGTH=100;B public int MAX_LENGTH=100;C public final int MAX_LENGTH=100;D final int MAX_LENGTH=100;

考题 判断题当使用setLength(int length)时,如果length的长度小于原字符串的长度,那么进行setLength操作后当前字符串的长度为length,且后面的字符被删除A 对B 错

考题 单选题A public member vairable called MAX_LENGTH which is int type, the value of the variable remains constant value 100. Use a short statement to define the variable.()A  public int MAX_LENGTH=100;B  final int MAX_LENGTH=100;C  final public int MAX_LENGTH=100;D  public final int MAX_LENGTH=100;

考题 多选题MAX_LENGTH是int型public成员变量, 变量值保持为常量100,用简短语句定义这个变量。()Apublic int MAX_LENGTH=100;Bfinal int MAX_LENGTH=100;Cfinal public int MAX_LENGTH=100;Dpublic final int MAX_LENGTH=100.

考题 判断题int intArray[]={0,2,4,6,8}; int length=int Array.length()。A 对B 错