}"); var s = "123-4567-89"; var m = r.Match(s); foreach (Group g in m.Groups) Console.WriteLine($"group {g.Index} : {g.Value}"); r = new Regex(@"\d+"); s = r.Replace(s, m2 => { var arr = m2.Groups[0].Value.ToCharArray(); Array.Reverse(arr); return new string(arr); }); Console.WriteLine(s); r = new Regex("%(?:begin|next|end)%");
In Java, the common way to traverse a set is as follows:Iterator iter = List. iterator ();
While (ITER. hasnext ()){
Object item = ITER. Next ();
}
You can also useFor (iterator iter = List. iterator (); ITER. hasnext ()){
Object item = ITER. Next ();
}
Enhanced for syntax introduced by JDK 1.5List list =
For (integer item: List ){
}
In C #, the way to traverse the set is as follows:Foreach (Object item in
LeetCode 21 Merge Two Sorted Lists (C, C ++, Java, Python), leetcodesortedProblem: Merge two sorted linked lists and return it as a new list. The new list shoshould be made by splicing together the nodes of the first two lists.Solution: two ordered linked lists. Each time the smallest element in the header is taken, this element is removed from the original linke
Problem:Given a Roman numeral, convert it to an integer.Input is guaranteed to being within the range from 1 to 3999.Solution: Time complexity O (n) topic: In contrast to 12, give a Roman numeral, ask to convert to decimal number problem solving idea:Java source code (spents 749ms):public class Solution {public int romantoint (String s) { int index=0,num=0,temp=0; while (IndexC Language Source code (spents 18ms):int Romantoint (char* s) { int num=0,temp=0; while (*s) {
Problem:Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If Such arrangement is not a possible, it must rearrange it as the lowest possible order (ie, sorted in ascending order).The replacement must is in-place, do not allocate extra memory.Here is some examples. Inputs is in the left-hand column and its corresponding outputs is in the right-hand column.1,2,3→1,3,23,2,1→1,2,31,1,5→1,5,1Solution: In reverse lookup method, find the
Constructors in Java cannot be decorated with static, whereas in C #,static constructors are used to initialize any static data, or to perform specific operations that need to be performed only once. Static constructors are used to initialize any static data, or to perform specific operations that need to be performed only once.Java foreign class cannot be modified with static,
I. Introduction
As we all know, C ++ and Java are two mainstream object-oriented languages today. Each person has their own opinions on the advantages and disadvantages of these two languages, the consensus is that C ++ is a compilation-type high-level language while Java is interpreted. Therefore,
for I in range (length)] for i in range (length): If s[i]== ' (': str_stack[top]= ' (' pos_stack[top]=i top+=1 Else: if top>0 and str_stack[ top-1]== ' (': top-=1 tmp=i+1 if top==0 else i-pos_stack[top-1] Max=max if max>tmp else tmp else: str_stack[top]= ') ' pos_stack[top]=i top+
Use C #. NET calls the WebService developed by Java, first encapsulate the object with the int attribute on the client. When the object is uploaded to the server, the server can obtain the string type attribute value, however, the int, double, and DateTime values cannot be obtained (all values obtained on the server are null). Solution: VS2005 encapsulates WebService references.
Use
Problem:Divide-integers without using multiplication, division and mod operator.If It is overflow, return max_int.Solution: Can not be multiplication on the line, but one problem is that the addition and subtraction may be too slow, so need to convert, because any number can be expressed as binary, so there are dividend=divisor* (a*2^1 + b*2^2 + ... + m*2^k)So just calculate all the divisor*2^k, then subtract.Topic: Given two integers, requires no multiplication method and modulo operation, the
Problem:Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would is if it were inserted in order.Assume no duplicates in the array.here is few examples. [1,3,5,6" , 5→2[1,3,5,6" , 2→1[1,3,5,6" , 7→4[1,3,5,6" , 0→0 Solution: Binary lookup, when not found l=r+1, so according to the last change of L and R to determine the position should be inserted, if the last time is l=mid+1, the location should be inserted into the mid+1, if the l
{
Console.WriteLine ("This directory does not exist!");
}
Timing over
Console.WriteLine ("End Time": "+ DateTime.Now.ToString" ("HH:mm:ss"));
Console.readkey ();}}
Run Effect chart:
Second, language: C + +
Development environment: vs 2013
Total Code: 50 lines
Time consuming: 36 seconds
Code:
#include
Run Effect chart:
Third, language: PHP
Development environment: Phpstorm
Total Code: 32 Lines
Time consuming: 13 seconds
Co
"As a C + + programmer, we have already mastered the basic concept of object-oriented programming, and Java syntax is undoubtedly very familiar." In fact, Java is originally derived from C + +. ”
However, there are still some notable differences between C + + and
Preface Java groups are expanding every day, including some of the world's largest ISVs, it also includes the company's CIOs, information technology personnel, system analysts, C/S developers, programmers, multimedia designers, marketing staff, educators, managers, Video Producers and even amateurs.. Traditionally, it is rare for such people to work effectively together. When talking about open systems, we
An online "C # and Java comparison" (or "Java and C # comparison") is very good written, today suddenly search.I have just contacted C #, also involuntarily at any time to take the contrast with Java, so on the whim of the origina
The comparison between Java and C # has never stopped since the birth of C. In fact, Java and C # are better than Apple-to-apple. I think it is more accurate to say that Java and. NET are compared, while
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.