[Solved] how to sort 5 strings according to their length and print it out

[ad_1] As suggested you can use sort #include <iostream> #include <vector> #include <algorithm> using namespace std; int main () { std::vector<string> vec={“abc”,”defsf”,”a”,”c”}; cout<<“Unsorted string”<<endl; for(auto s: vec) { cout<<s<<” “; } std::sort(vec.begin(),vec.end(),[](const string& a,const string& b) { return a.size()<b.size(); }); cout<<endl<<“Sorted string”<<endl; for(auto s: vec) { cout<<s<<” “; } return 0; } [ad_2] solved how … Read more

[Solved] How to separate words from a sentence (only using character arrays and no built-in c++ functions)? [closed]

[ad_1] I think you’d like to separate all of the words in this sentence, so you can’t make loop stop when it meet first blank. #include<iostream> using namespace std; int main() { char sentence[100]={‘\0’}, word[100]={‘ ‘}; cin.getline(sentence,100); for(int i = 0; sentence[i] != ‘\0’; i++) { word[i]=sentence[i]; } cout << word; } Above code may … Read more

[Solved] Add one to C# reference number

[ad_1] Homework or not, here’s one way to do it. It’s heavily influensed by stemas answer. It uses Regex to split the alphabetical from the numeric. And PadLeft to maintain the right number of leading zeroes. Tim Schmelters answer is much more elegant, but this will work for other types of product-numbers as well, and … Read more

[Solved] How to send mail using C# with html format [closed]

[ad_1] Setting isBodyHtml to true allows you to use HTML tags in the message body: SmtpClient sc = new SmtpClient(“mail address”); MailMessage msg = null; try { msg = new MailMessage(“[email protected]”, “[email protected]”, “Message from PSSP System”, “This email sent by the PSSP system<br />” + “<b>this is bold text!</b>”); msg.IsBodyHtml = true; sc.Send(msg); } catch … Read more

[Solved] How to tackle my JavaScript homework? [closed]

[ad_1] You could transform your list of words by a list of their length with map() and sort them from the longest to the shortest then just keep the first : var list = [“pain”, “poire”, “banane”, “kiwi”, “pomme”, “raisin”] var result = list.map(x => x.length).sort((a,b) => a < b)[0]; console.log(result); Or if you don’t … Read more

[Solved] MySQL Query issue with select [closed]

[ad_1] Another approach to “join” two tables: SELECT proposal.proposalID, client.name FROM client, proposal WHERE proposal.clientID = client.id; Warning: I didn’t test this. In order to understand what’s going on, I suggest you learn more about SQL Joins. Some links to get you started: http://www.w3schools.com/sql/sql_join.asp http://en.wikipedia.org/wiki/Join_%28SQL%29 https://www.google.com/search?q=sql+join 2 [ad_2] solved MySQL Query issue with select [closed]

[Solved] Validate that connection string is for Sql Server 2008 [closed]

[ad_1] I don’t know why you need to validate or users are entering a connection string but you can find connections strings for sql 2008 from below link. http://www.connectionstrings.com/sql-server-2008 Standard Security Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword; Use serverName\instanceName as Data Source to connect to a specific SQL Server instance. Are you using SQL Server 2008 Express? … Read more

[Solved] Basic Auth in metro app using C# [closed]

[ad_1] I assume you’re talking about Basic Http Authentication, if you’re using HttpClient to make your web service calls then you can enable set a Basic authentication header with the following code. var request = new HttpRequestMessage(HttpMethod.Get, uri); var token = Convert.ToBase64String(Encoding.UTF8.GetBytes(String.Format(“{0}:{1}”, username, password))); request.Headers.Authorization = new AuthenticationHeaderValue(“Basic”, token); The simplest (and cleanest) way, however: … Read more

[Solved] Change data.frame into array [closed]

[ad_1] This is a really unusual thing to do. No, it’s worse than unusual. It’s probably just bad. Matrices and arrays are useful, appropriate and very fast if all of the data is of a single class. If you have mixed classes, then work with data frames instead. But here you go. In the first … Read more

[Solved] what is difference between object value and object hashCode value [closed]

[ad_1] You did not override toString and hashValue, so the implementations from Object are used. toString() returns a String consisting of the class name (RefDem) and the memory location in hexadecimal form (1e5e2c3) seperated by “@”. “d :” + d is equivalent to “d :” + d.toString() so you get “d :RefDem@1e5e2c3” The hashCode implementation … Read more

[Solved] How to handle an exception without closing application? [closed]

[ad_1] How I went about in solving my issue: bool success = false; try { //try to send the message smtpmail.Send(message); success = true;//everything is good } catch (Exception err) { //error with sending the message errorMsg.Text = (“Unable to send mail at this time. Please try again later.”); //log the error errorLog.Log(err); //note errorLog … Read more