VC MSFLEXGrid Basic use

2022-12-30   ES  

simulate a method of consistent trim function. Remove the blank ends at both ends of the string

1. Define two variables

A variable as a corner label to judge the string space from scratch. Continuous ++

A variable as an corner label to judge the string space from the end. Continuous–

2. Determine that it is not a space, just take the string between the head and tail. (Take the skewers)

package stringd.emo; 

 public class stringtrim { 

 Public Static void main (string [] args) { 
 String s = "ab c"; 
 s = mytrim (s); 
 System.out.println ("-"+s+"-"); 
 } 

 Public Static String Mytrim (String S) {{ 
 int Start = 0, end = s.Length ()-1; 
 // char, return according to the position 
 While (start <= end &&charat (start) == '') { 
 Start ++; 
 } 
 // 
 While (start <= end &&charat (end) == '') { 
 End--; 
 } 
 
 Return s.substring (start, end+1); 
 } 

 }

source

Related Posts

Detailed explanation list list in Python

10.31 NOIP simulation race (Morning)

[docker] Two docker-compose.xml sharing a network

sqlite database visualization tool -DB.BROWSER installation instructions

VC MSFLEXGrid Basic use

Random Posts

WINDOWS 64 cannot be installed Mysql-Python

react-native Error when starting when starting: Unable to load script.makeour you’re either running a metro server or that …

Eclipse CDT Introduce the C/C ++ project built by Makefile

C ++ open source cross-platform log library GLOG learning research (2)-macro use

Linux installation SSH and starting the SSH service Linux server how to access remote access through SSH