Face Test 1 how to intercept a stringQuestions and Answerswrite a function that intercepts a string, enter it as a string and number of bytes, and output a string that is truncated by bytes. But to ensure that the Chinese character is not truncated half, such as " i ABC" 4, should be cut to " i AB", Enter " i ABC han D
Package com.abuge;
Import Java.util.Iterator;
Import Java.util.LinkedHashSet;
Import Org.junit.Test; /** * A string of lowercase letters (A~Z) entered through the keyboard.
Write a string filter that filters out characters that are not the first occurrence if there are multiple identical characters in the string.
For example, the
use of string comparison X "$variable" in Shell
This article refers to StackOverflow why does shell script comparisons often use X$var = Xyes? do not use double quotes "", do not use prefix x do not use double quotes "", use prefix x use double quotation marks "" without using prefix x use the double quotation mark "", using the prefix x
Shell string comparison xvariable using double quotation marks withou
file Testing (-f,-d,-r,-r,...)
[-f/root/file.txt],[-d/root/mydir]
[[-f/root/file.txt]]File testing aspects [[]] same as []
string comparison (-z,-n,!=,==,...)
[-Z "${str}"],["${str}"! = "${str}"],[!-n "${str}"][] can only be used for character comparisons and cannot be used for pattern matching
[-Z "${STR}"]],[[! -N "${str}"]
[[$a = = z*]] # if $ A starts with "Z" (pattern match) then true[[Hello = = hell?]] # pattern Match [
order to see the effect more intuitively, I did some more loops). It is conceivable that this one-step operation consumes me more than a second time, plus other code time consumption, the entire script block execution time is unbearable. Is there any plan to optimize it? Is there any other way? The answer is certainly yes, otherwise I write this article is nonsense.
The quicker way to do this is to use an array, instead of stitching it into a string
/** STD: String Detailed Description * Visual Studio 2008sp1, use Ctrl + F5 to start debugging */# include
Output result
Appending the C-string cstra to string stra gives: Hello C-stringhello C-stringsoinput a character stringlong long ago, there is girl, she's name is Little RedHat .. before line: Long long ago, there is girl, she's name is Little RedHat .. qu
-1SYSTEM.OUT.PRINTLN (subindex), int lastindex=demostring.lastindexof ("i");//Find the substring at index of the last occurrence of the string, Returns -1SYSTEM.OUT.PRINTLN (LastIndex) If it is not found; System.out.println (Demostring.touppercase ());//The words in the string all become uppercase System.out.println (Demostring.tolowercase ());//The words in the string
1.There are no zzTest.txt files at this time1 Public classTtest2 {3 Public Static voidFilewrite_overwrite (String _strfullfilename)throwsException4 {5File File =NewFile (_strfullfilename);6 if(!file.exists ())7 {8 file.createnewfile ();9System.out.println (file + "created! ");Ten } One AString strcontent = "Test"; - -randomaccessfile mm =NewRandomaccessfile (file,
A field in the database is spliced with commas (,). Each field is the primary key of another table. You need to query the child element or delete the element for the field spliced with commas, there will be more complex string parsing.
Therefore, the split method provided by string is tested first.
As you can see, all the commas before the element are considered as delimiters and are split into a
Test Questions
// Write a function to flip the string. The flip method is as follows: "I am a student" is reversed to "student a am I" without any library function.
It is said that this question was frequently used in a written test or interview. I just saw this question in my book, and I saw it again in the blog Garden ("Publish a typical interview
".Example: Enter "We are happy"Output "We%20are%20happy"Implementation Method 2.0Consider moving backwards from one tail to the next, traversing the string, counting the number of spaces, because of the calculation of the new string length (each replacing a space, length +2), encountering a space to replace, time complexity O (n), using the array subscript can be used to implement the character movement#inc
To: gotesting software testing Alliance Forum http://www.78test.com
Public class testcharacter {Final Static int time = 50000; // number of cycles
Public testcharacter (){
}
Public void test (string s ){
Long begin = system. currenttimemillis ();
For (INT I = 0; I
S + = "add ";
}
Long over = system. currenttimemillis ();
System. Out. println ("operation" + S. getclass (). getname () + "type:"
Bash three test integer file strings (String)String test= = Note The test must have a space on both sides of the equal sign, and a space in the brackets to test whether the string is eq
Input:
The input is a line of 9-or 11-digit strings. The format is shown in the preceding figure.
Output:
Number in decimal format
Sample input:
0w564
Sample output:
675
Answer:
I implemented this question in Java, because the 9-and 11-digit strings have certain rules, so I want to use regular expressions for matching. The 9-digit regular expression is ^ 0 [v | V] [0-8] * $, the Regular Expression in decimal format is ^ 0 [w | w
(); tend = new Date (); document.write ("
Perhaps you have guessed, StringBuffer is faster than +, in the end how much faster? My test results:JS CodeFF3.0.10Original method plus concatenation of 10,000 strings takes time: 3 Hao secondsStringBuffer stitching 10,000 Strings takes time: 8 Hao secondsIE7Original method plus concatenation of 10,000 strings takes time: 15 Hao secondsStringBuffer stitching 10,000 strings takes time: 16 Hao sec
This is often asked or tested during an interview or written test.
The prototype for the known class string is:
Class string
{public
:
string (const char *STR = NULL);//Normal constructor
string (const string other); Copy c
First, the title description (60 points):Enter a string of lowercase letters (A~Z) through the keyboard. Write a string filter to filter out characters that are not the first occurrence if multiple identical characters appear in the string.For example, the string "ABACACDE" filter result is "ABCDE".Required implementation function: void Stringfilter (const char *
There are many shell operators, relational operators, arithmetic operators, Boolean operators, string operators, and file test operators1, arithmetic operatorsAcoustic Bash does not support simple arithmetic operations, and you can use the Expr toolTwo points Note:
There are spaces between the expression and the operator, such as the 2 + 2, which is different from most of the programming languages
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.