String str="abcedf"; int length=str.length。

String str="abcedf"; int length=str.length。


相关考题:

阅读以下说明和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';}

若输入bcdefgh、m、abcdefg,以下程序的输出结果为()。includeincludemain(){i 若输入bcdefgh、m、abcdefg,以下程序的输出结果为( )。 #include<stdio.h> #include<string.h> main() { int i; char string[20],str[3][20]; for(i=0;i<3;i++)gets(str[i]); if(strcmp(str[0],str[1])>0) strcpy(string,str[0]); else strcpy(string,str[1]); if(strcmp(str[2],string)>0) strcpy(string,str[2]); printf("%s",string); }A.bcdefghB.mC.abcdefgD.bcdefgh或abcdefg

已知String str=new String ("Luck");,则下列关于str的操作中不合法的是( )。A.String s=str. toUpperCase()B.int i=Str. length;C.char s=str. charAt(2);D.String s="Good" +str;

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

先阅读下面的程序片段:String str="abccdefcdh";String[] arr=str.split"c";System.out.println(arr.length);程序执行后,打印的结果是( )。 A、2个B、3个C、4个D、5个

阅读下列程序,当运行函数时,输入asd af aa z67,则输出为includeincludeinc 阅读下列程序,当运行函数时,输入asd af aa z67,则输出为 #include<stdio.h> #include<ctype.h> #include<string.h> int fun(char*str) { int i,j=0; for(i=0;str[i]!='\0';i++) if(str[i]!='')str[j++]=str[i]; str[j]='\0'; } main() { char str[81]; int n; clrscr(); printf("Input a string:"); gets(str); puts(str); fun(str); printf("%s\n",str); }A.asdafaaz67B.asdafaaz67C.asdD.z67

4 . 写出程序的输出结果class Class1 {private string str = "Class1.str";private int i = 0;static void StringConvert(string str) {str = "string being converted.";}static void StringConvert(Class1 c) {c.str = "string being converted.";}static void Add(int i) {i++;}static void AddWithRef(ref int i) {i++;}static void Main() {int i1 = 10;int i2 = 20;string str = "str";Class1 c = new Class1();Add(i1);AddWithRef(ref i2);Add(c.i);StringConvert(str);StringConvert(c);Console.WriteLine(i1);Console.WriteLine(i2);Console.WriteLine(c.i);Console.WriteLine(str);Console.WriteLine(c.str);}}

执行下面代码后:String strTemp =”abcdefg 某某某”;Int i System.Text.Encoding.Default.GetBytes(strTemp).Length;Int j = strTemp.Length;问:i=(14 ) ;j=(11 )

以下( )表达式是不合法的。A.String x="Sky";int y=5;x + =y:B.String x="Sky":int y=5:if(x==y){}C.String x="Sky":int y=5:x=x+y:D.String x=null:int y=(x!=null) (x.length( )>0)?x.length:0

阅读下列程序,当运行函数时,输入asd af aa z67,则输出为#include stdio.h#include ctype.h#include string.hint fun (char *str){ int i,j=0;for(i=0;str[i]!=′ \0′;i++)if(str[i]!=′ ′)str[j++]=str[i];str[j]= ′\0′;}main(){char str[81];int n;printf("Input a string : ");gets(str);puts(str);fun(str);printf("%s\n",str);}A.asdafaaz67B.asd af aa z67C.asdD.z67

以下( )表达式是不合法的。A.string x="hello";int y=9;x+=y;B.string x="hello";int y=9;if(x=y){}C.string x="hello";int y=9;x=x+y;D.string x=null;inty=(x!=null)(x.length()>0)?x.length():0;

public static void main(String[] args) {  String str = “null‟;  if (str == null) {  System.out.println(”null”);  } else (str.length() == 0) {  System.out.println(”zero”);  } else {  System.out.println(”some”);  }  }  What is the result?()A、 nullB、 zeroC、 someD、 Compilation fails.E、 An exception is thrown at runtime.

String str; System.out.println(str.length()); 以上语句运行的结果是显示0 。

设有定义:String s=“World”;,下列语句错误的是()。A、int m=s.indexOf(‘r’);B、char c=s.charAt(0);C、int n=s.length();D、String str=s.append(‘2’);

下面哪项不是response对象的方法()A、set Content Type(String contentTypestr)B、set Header(String headername,String headervalue)C、get Parameter(String str)D、send Error(int errorcode)

String date="Today is Sunday.";String str2=data.CharAt(s.length( )-1);则str2为()A、yB、.C、nullD、false

Given the following code fragment:      1) String str = null;  2) if ((str != null)  (str.length()  10)) {     3) System.out.println("more than 10");     4) }  5) else if ((str != null)  (str.length()  5)) {     6) System.out.println("less than 5");     7) }  8) else { System.out.println("end"); }   Which line will cause error?()    A、 line 1B、 line 2C、 line 5D、 line 8

java中 String str = "hello world"下列语句错误的是()。A、str+=’ a’B、int strlen = str.lengthC、str=100D、str=str+100

public static void main(String[]args){ String str="null"; if(str==null){ System.out.println("null"); }else(str.length()==0){ System.out.println("zero"); }else{ System.out.println("some"); } } What is the result?()A、nullB、zeroC、someD、Compilationfails.E、Anexceptionisthrownatruntime.

public static void test(String str) { int check = 4;  if (check = str.length()) {  System.out.print(str.charAt(check -= 1) +“, “);  } else {  System.out.print(str.charAt(0) + “, “);  }  }  and the invocation:  test(”four”);  test(”tee”); test(”to”);  What is the result?() A、 r, t, t,B、 r, e, o,C、 Compilation fails.D、 An exception is thrown at runtime.

判断题String str="abcedf"; int length=str.length。A对B错

单选题下面哪个方法设置MIME类型?()AsetHeader(String headerName,String headerValue)BsetContentType(String mimeType)CsetContentLength(int length)DaddCookie(Cookie c)EaddHeader(String name,String value)

单选题String date="Today is Sunday.";String str2=data.CharAt(s.length( )-1);则str2为()AyB.CnullDfalse

单选题public static void test(String str) { int check = 4;  if (check = str.length()) {  System.out.print(str.charAt(check -= 1) +“, “);  } else {  System.out.print(str.charAt(0) + “, “);  }  }  and the invocation:  test(”four”);  test(”tee”); test(”to”);  What is the result?()A r, t, t,B r, e, o,C Compilation fails.D An exception is thrown at runtime.

判断题String str; System.out.println(str.length()); 以上语句运行的结果是显示0 。A对B错

单选题public static void main(String[] args) {  String str = “null‟;  if (str == null) {  System.out.println(”null”);  } else (str.length() == 0) {  System.out.println(”zero”);  } else {  System.out.println(”some”);  }  }  What is the result?()A nullB zeroC someD Compilation fails.E An exception is thrown at runtime.

单选题public static void main(String[]args){ String str="null"; if(str==null){ System.out.println("null"); }else(str.length()==0){ System.out.println("zero"); }else{ System.out.println("some"); } } What is the result?()AnullBzeroCsomeDCompilationfails.EAnexceptionisthrownatruntime.