[Solved] Structured Data: Nesting Triangles using structs and calculating

[ad_1] I think what you’re trying to do is this: float cal_area(triangle aTriangle) { float Area; Area = (aTriangle.vertices[1].x – aTriangle.vertices[0].x) * (aTriangle.vertices[2].y – aTriangle.vertices[1].y) – (aTriangle.vertices[1].y – aTriangle.vertices[0].y) * (aTriangle.vertices[2].x – aTriangle.vertices[1].x); if (Area < 0.0f) { return -Area / 2.0f; } else { return Area / 2.0f; } } [ad_2] solved Structured Data: … Read more

[Solved] Email and mobile number validation on same html5 textbox with button

[ad_1] here is the simple javascript code which will validate both email and phone number. <html> <head> <script src=”https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js”></script> <script> function ValidateEmail(mail) { var mailformat = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/; // if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(myForm.emailAddr.value)) if(mail.match(mailformat)) { alert(mail); return (true) } alert(“You have entered an invalid email address!”) return (false) } function validate() { var data=document.getElementById(“email”).value; checkNumberorEmail(); } function phonenumber(inputtxt) … Read more

[Solved] Find String in ArrayList Containing Phrase

[ad_1] public static void main(String[] args) { List<String> data = new ArrayList<String>(); String yourRequiredString = “dessert”; data.add(“apple fruit”); data.add(“carrot vegetable”); data.add(“cake dessert”); for (int i = 0; i < data.size(); i++) { if (data.get(i).contains(yourRequiredString)) { System.out.println(i); } } } Hope this helps… [ad_2] solved Find String in ArrayList Containing Phrase

[Solved] How should I calculate the average speed by road segment for multiple segments?

[ad_1] When averaging speeds, the harmonic mean is in need. The straight forward AVG() approach is wrong, the arithmetic mean yields the wrong result for average velocity. There is no predefined function for the harmonic mean, but it could be achieved with this query: SELECT segment, COUNT(*)/SUM(1e0/speed) AS avg_speed FROM T GROUP BY segment SQL … Read more

[Solved] List with numbers and text

[ad_1] There are many options, I describe some of them for you use Dictionary<int, string>Pros: very fast lookupCons: you can not have two string with same number, you don’t have a List var list2d = new Dictionary<int, string>(); list2d[1] = “hello”; list2d[2] = “world!”; foreach (var item in list2d) { Console.WriteLine(string.Format(“{0}: {1}”, item.Key, item.Value); } … Read more

[Solved] Java Variable Substitution

[ad_1] This is normally solved with just a String#replaceAll, but since you have a custom, dynamic replacement string, you can to use a Matcher to efficiently and concisely do the string replacement. public static String parse(String command, String… args) { StringBuffer sb = new StringBuffer(); Matcher m = Pattern.compile(“\\$(\\d+)”).matcher(command); while (m.find()) { int num = … Read more

[Solved] Split calculator expression with binary and unary operations [closed]

[ad_1] I found easy solution. You could just write it instead of complain that there is no code in the question. string expression;//my calculator expression string[] operators;//array that contains both unary and binary operators. for(int i=0;i<operators.length;i++) { expression = expression.replace(operators[i],” “+operators[i]+ ” “); } string[] Values= expression.split(” “); [ad_2] solved Split calculator expression with binary … Read more

[Solved] i have stored array in database as a string how can retrieve that array?

[ad_1] use JSON_ENCODE first before saving the array to DB ,then use JSON_DECODE if you want to get again the contents $arr = array( “item_number1” => “1”, “payment_date” => “04:21:34 Dec 06, 2014 PST”, “payment_status” => “Completed”, “first_name” => “sdfsd”, “last_name” => “parsdfsdandekar”, “quantity1” => “1” ); echo json_encode($arr); Result after JSON_ENCODE (Array to JSON … Read more