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

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

以下算法在什么情况会出现怎样的错误?举例说明。怎样改正? //将串中所有与pattern匹配的子串替换为str void MyString::replaceAll(MyString &pattern, MyString &str) { int start=search(pattern); while (start!=-1) { remove(start, pattern.n); insert(start, str); start = search(pattern, start); } }


参考答案和解析
可靠性
更多 “以下算法在什么情况会出现怎样的错误?举例说明。怎样改正? //将串中所有与pattern匹配的子串替换为str void MyString::replaceAll(MyString pattern, MyString str) { int start=search(pattern); while (start!=-1) { remove(start, pattern.n); insert(start, str); start = search(pattern, start); } }” 相关考题
考题 【问题3】(5 分)该网站购物车模块负面脚本语言是JavaScript,用户订购信息临时存在cookie中,下面是购物车页面中读取cookie值的函数,请完成该程序。script. language="javascript”>……function readCookie(name){var cookieValue = ””;var search= (8) +”=”;if(document.cookie.(9) 0){start= document.cookie.indexOf(search);if(start!=-1){start += search.length;end = document.cookie.indexOf(";”,start);if(end = = -1)end=document.cookie.length;cookieValue = document.cookie.substring((10), (11))}}return(12);……/script

考题 请编写一个函数int pattern_index(char substr[],char str[]),该函数执行含通配符“?”的字符串的查找时,该通配符可以与任一个字符匹配成功。当子串substr在str中匹配查找成功时,返回子串substr在str中的位置,否则返回值为0。要求使用 for循环实现。输出结果如下:子串起始位置:5注意:部分源程序已存在文件test20_2.cpp中。请勿修改主函数main和其他函数中的任何内容,仅在函数pattern_index的花括号中填写若干语句。文件test20_2.cpp的内容如下:include<iostream.h>int pattern_index(char substr[],char str[]){}void main ( ){char *substring,*string;int same;substring="???gram";string="this program return index of substring";same=pattern_index(substring, string);if(same)cout<<"子串起始位置: "<<same<<end1;elsecout<<"匹配不成功" <<end1;}

考题 本题统计字符串str中字母a出现的次数,其中str为“(7amp;asdfasdf873eat687al(4a”,字母a存储在字符变量c中,最后打印输出结果。public class javal{public static void main(String[]args){String str=(*amp;7asdf adf873eat687al(4a;char c;int sum=0;int i=0:do{c= ;if( )sum++:i++:}while( );System.out.println(sum=+sum);}}

考题 ( 28 )阅读下面程序1 public class Try extends Thread{2 public static void main(String args[ ]){3 Try t = new Try( );4 t.start( );5 }67 public void run( int j){8 int i = 0;9 while(i5){10 System.out.println(" 祝你成功! ");11 i++;12 }13 }14 }该程序要求打印 5 行 “ 祝你成功! ” ,必须改正程序中的某行代码,程序才能完成。选择正确的修改是A )将第 1 行的 extends Thread 改为 implements RunnableB )将第 3 行的 new Try() 改为 new Thread()C )将第 4 行 t.start() 改为 start(t)D )将第 7 行的 public void run( int j) 改为 public void run()

考题 ( 24 )请阅读下面程序public class ThreadTest {public static void main ( String args[ ]){Thread t1 = new Thread ( new Hello ()):Thread t2 = new Thread ( new Hello ()):t l .start ():t2.start ();}}class Hello implements Runnable {int i ;public void run (){while ( true ) {System.out.println ( "Hello"+i++ ) ;if ( i=5 ) break :}}}该程序创建线程使用的方法是()A )继承 Thread 类B )实现 Runnable 接口C ) t l.start ()D ) t2.start ()

考题 试题二(共15分)阅读下列说明,回答问题1至问题3,将解答填入答题纸的对应栏内。【说明】逻辑覆盖法是设计白盒测试用例的主要方法之一,它是通过对程序逻辑结构的遍历实现程序的覆盖。针对以下由C语言编写的程序,按要求回答问题。struct _ProtobufCIntRange{int start_value;unsigned orig_index;};typedef struct _ProtobufCIntRange ProtobufCIntRange;int int_range_lookup (unsigned n_ranges, const ProtobufCIntRange *ranges, int value){unsigned start,n; ∥1start=0;n=n_ranges;while(n1){ //2unsigned mid= start+ n/2;if(value ranges[mid].start_value){ //3n=mid-start; //4}else if(value=ranges[mid].start value+(int)(ranges[mid+1].orig_index-ranges[mid].orig_index){ //5unsigned new_start= mid+1; //6n=start+n-new_start,start = new_start;}else //7return (value - ranges[mid].start_value)+ ranges[mid],orig_index;}if(n0){ //8unsigned start_orig_index= ranges[start].orig_index;unsigned range_size=ranges[start+1].orig_index - start_orig_index;if (ranges[start].start_value=value value (int)(ranges[start].start_value+ range_size》 //9, 10return (value - ranges[start].start_value)+start_orig_index; //11}retum -1, //12} //13【问题1】(5分)请给出满足100%DC(判定覆盖)所需的逻辑条件。【问题2】 (7分)请画出上述程序的控制流图,并计算其控制流图的环路复杂度V(G)。【问题3】(3分)请给出【问题2】中控制流图的线性无关路径。

考题 请阅读下面程序 public class ThreadTest{ public static void main(String args[]) ( Thread t1=new Thread(new Hello()); Thread t2=new Thread(new Hello()); t1.start(); t2.start(); } } class Hello implements Runnable { int i; public void run() { while(true) { System.out.prinfin("Hello"+i++); if(i=5) break; } } } 该程序创建线程使用的方法是A.继承Thread类B.实现Runnable接口C.t1.start()D.t2.start()

考题 有以下程序include void WriteStr(char*fn,char*str){FILE*fp; fp=fopen(fn,"w");fpu 有以下程序 #include <stdio.h> void WriteStr(char *fn, char *str) { FILE *fp; fp=fopen(fn,"w"); fputs(str,fp);fclose(fp); } main() { WriteStr("t1.dat","start"); WriteStr("t1.dat","end"); } 程序运行后,文件t1.dat中的内容是A.startB.endC.startendD.endrt

考题 函数f_str(char *str,char del)的功能是;将非申字符串str分割成若干个子字符串并输出,del表示分割时的标志字符。例如,若str的值为“66981636666257”,del的值为“6”,调用此函数后,将输出3个子字符串,分别为“981”、“3”和“257”。请将函数f_str中(6)~(8)空缺处的内容填写完整。[函数]void f_str(char *str,char del){ int i,j,len;len = strlen(str);i = 0;while (i<len) {while ( (6) )i++; /* 忽略连续的标志字符 *//* 寻找从srt[i]开始直到标志字符出现的一个子字符串 */j = i+1;while (str[j] !=del str[j] !='\0')j++;(7)="\0"; /* 给找到的字符序列置字符串结束标志 */printf (" %s\t", str [i]);(8);}}

考题 有以下程序 #include void WriteStr(char*fn,char*str) { FILE*fp; fp=fopen(fn,"w");fputs (str,fp);fclose(fp); } main() { WriteStr("t1.dat","start"); WriteStr("t1.dat","end"); } 程序运行后,文件t1.dat中的内容是______。A.startB.endC.startendD.endrt

考题 在匹配器(Marcher)类中,用于输入字符串与模式串比较的方法是( )。A.static boolean matches()B.boolean matcher.find()C.int matcher.start()D.int matcher.end()

考题 有以下程序includevoid WriteStr(char*fn,char*str){FILE*fp; fp=fopen(fn,"w");fputs 有以下程序 #include<stdio.h> void WriteStr(char*fn,char*str) { FILE*fp; fp=fopen(fn,"w");fputs(str,fp);fclose(fp); } main() { writeStr("t1.dat","start"); WriteStr("t1.dat","end"); } 程序运行后,文件t1.dat中的内容是A.startB.endC.startendD.endrt

考题 阅读下面程序 1 public class Try extends Thread { 2 public static void main(String args[]) { 3 Try t=new Try(); 4 t.start(); 5 } 6 7 public void run(int j) { 8 int i=0; 9 while(i<5) { 10 System.out.println("祝你成功!"); 11 i++: 12 } 13 } 14 } 该程序若能打印5行“祝你成功!”,必须改正程序中的某行代码,选择正确的修改是A.将第1行的extends Thread改为implements RunnableB.将第3行的new Try()改为new Thread()C.将第4行的t.start()改为start(t)D.将第7行的public void run(int j)改为public void run()

考题 本程序的功能是,根据用户输入的文件名,在相应的文件内容中查找匹配给定模式的字符串,并将这些字符串显示出来。模式串为“href="…"”。请填写横线处的内容。注意:请勿改动main()主方法和其他已有语句内容,仅在横线处填入适当语句。import java.io.*;import java.util.regex.*;import javax.swing.*;public class Example2_10{public static void main(String [] argv){final String patternString ="href\\s*=\\s*(\"[^\"]*\"|[^\\s>])\\s*;String fileName ;try{System. out. print ( "请输入html 文件的文件名: ");InputStreamReader in = new InputStreamReader(System.in);BufferedReader imput = new BufferedReader(in);fileName = imput.readLine();if(fileName.equals(" "))return;StringBuffer buffer = new StringBuffer();File file = new File(fileName);FileInputStream readfile = new FileInputStream(file);for(int c = 0; (c = readfile.read()) != -1; )buffer.append((char)c);Pattern pattern = Pattern.compile(_____________ Pattern.CASE_INSENSITIVE);Matcher matcher =________;while (marcher. find ()){int start = matcher.start();int end = matcher.end();String match = buffer.substring(start, end);System.out.println (match);}}catch (Exception excption){System. out.println (excption. getMessage ());}System.exit(O);}}

考题 有以下程序: #includestdio.1l void WriteStr(char*fn.char*str) { FILE*fp; fp=fopen(fn,"w");fputs(str,fp);fclose(fp);} main { WriteStr("tl.dat","start"); WriteStr("t1.dat","end");) 程序运行后,文件t1.dat中的内容是( )。A. startB.endC.startendD.endrt

考题 Which of the following is the correct path a technician could follow to find the Services Snap-inconsole inside of Windows?() A. Start Settings Control Panel Administrative ToolsB. Start Settings Control Panel Add or Remove ProgramsC. Start Settings Control Panel SystemD. Start Settings Control Panel Scheduled Tasks

考题 在匹配器(Matcher)类中,用于输入字符串与模式串比较的方法是A.static boolean matches()B.boolean matcher,find()C.int matcher,start()D.int matcher,end()

考题 Which tanker discharge pattern would be the safest and most efficient ________.A.Empty the forward tanks and start working aft,emptying each tank in sequenceB.Start discharging with most of the discharge coming from forward,but include some from midships and after tanksC.Start pumping from forward,midships,and aft with the discharge distributed equally among the tanksD.Start pumping from midships and then work forward and aft simultaneously as the midships tank is emptied

考题 [说明] 逻辑覆盖法是设计白盒测试用例的主要方法之一,它是通过对程序逻辑结构的遍历实现程序的覆盖。针对以下由C语言编写的程序,按要求回答问题。 Struct_ProtobufCIntRange{ Int start_value; Unsigned orig_index; }; typedef struct_ProtobufCIntRange ProtobufCIntRange; in tint_range_lookup(unsigned n_ranges,const ProtobufCIntRange*ranges,int value) { unsigned start,n; //1 start=0; n=n_ranges; while (n>1) { //2 unsigned mid=start+n/2; if(value n=mid-start; //4 } else if (value>=ranges[mid].start_value+ (int)(ranges[mid+1].orig_index-ranges[mid].orig_index)) { //5 unsigned new_start=mid+1; //6 n=start+n-new_start; start=new_start; } else //7 return(value-ranges[mid].start_value)+ranges[mid].orig_index; } if(n>0){ //8 unsigned start_orig_index=ranges[start].orig_index; unsigned range_size=ranges[start+1].orig_index-start_orig_index; if (ranges[start].start_valuereturn(value-ranges[start].start_value)+start_orig_index; //11 } return -1; //12 } //13 5、[问题1] 请给出满足100%DC(判定覆盖)所需的逻辑条件。(6分)6、[问题2] 请画出上述程序的控制流图,并计算其控制流图的环路复杂度VG.。(6分) 7、[问题3] 请给出[问题2]中控制流图的线性无关路径。(4分)

考题 在Windows操作系统中,返回桌面的快捷组合键是()A、Start+LB、Start+EC、Start+DD、Start+R

考题 Which of the following is the correct path a technician could follow to find the Services Snap-inconsole inside of Windows?()A、Start Settings Control Panel Administrative ToolsB、Start Settings Control Panel Add or Remove ProgramsC、Start Settings Control Panel SystemD、Start Settings Control Panel Scheduled Tasks

考题 Which method must be defined by a class implementing the java.lang.Runnable interface? () A、 void run()B、 public void run()C、 public void start()D、 void run(int priority)E、 public void run(int priority)F、 public void start(int priority)

考题 Which two code fragments will execute the method doStuff() in a separate thread?()A、new Thread() {public void run() { doStuff(); }};B、new Thread() {public void start() { doStuff(); }};C、new Thread() {public void start() { doStuff(); }}.run();D、new Thread() {public void run() { doStuff(); }}.start();E、new Thread(new Runnable() {public void run() { doStuff(); }}).start();

考题 单选题Which method must be defined by a class implementing the java.lang.Runnable interface? ()A  void run()B  public void run()C  public void start()D  void run(int priority)E  public void run(int priority)F  public void start(int priority)

考题 单选题Visual Basic.NET中,字符串处理函数中返回Str字符串的长度的是()。A Mid(Str,Start,Lengh)B Len(Str)C Instr(Star,String1,String2,Compare)D Ltrim(Str)

考题 多选题Which two code fragments will execute the method doStuff() in a separate thread?()Anew Thread() {public void run() { doStuff(); }};Bnew Thread() {public void start() { doStuff(); }};Cnew Thread() {public void start() { doStuff(); }}.run();Dnew Thread() {public void run() { doStuff(); }}.start();Enew Thread(new Runnable() {public void run() { doStuff(); }}).start();

考题 单选题Which of the following problems may occur if the opening pressure of a fuel injection nozzle is greater than specified by the engine manufacturer?()A The amount of fuel injected will be increasedB The start of injection will be retardedC The nozzle will permit fuel to dribbleD The spray pattern will be distorted

考题 多选题Which two code fragments will execute the method doStuff() in a separate thread?()Anew Thread() { public void run() { doStuff(); } }Bnew Thread() { public void start() { doStuff(); } }Cnew Thread() { public void start() { doStuff(); } } .run();Dnew Thread() { public void run() { doStuff(); } } .start();Enew Thread(new Runnable() { public void run() { doStuff(); } } ).run();Fnew Thread(new Runnable() { public void run() { doStuff(); } }).start();