[Solved] C++ homework (while loop termination)

[ad_1] Instead of reading val1 and val2 directly from stdin, read a line of text. If the line does not start with |, extract the numbers from the line using sscanf or istringstream. If the line starts with |, break out of the while loop. #include <stdio.h> #include <iostream> using namespace std; const int LINE_SIZE … Read more

[Solved] How can i sort array: string[]?

[ad_1] You can try the following string[] strarr = new string[] { @”c:\temp\newimages\Changed_Resolution_By_10\SecondProcess_-Width = 502 Height = 502\animated502x502.gif”, @”c:\temp\newimages\Changed_Resolution_By_10\SecondProcess_-Width = 492 Height = 492\animated492x492.gif”, @”c:\temp\newimages\Changed_Resolution_By_10\SecondProcess_-Width = 2 Height = 2\animated2x2.gif” }; IEnumerable<string> strTest = strarr.OrderByDescending(p => p.Substring(p.IndexOf(“x”), p.Length – p.IndexOf(“.”))); [ad_2] solved How can i sort array: string[]?

[Solved] Using boost to generate random numbers between 1 and 9999 [closed]

[ad_1] Did you try googling for “boost random number” first? Here’s the relevant part of their documentation generating boost random numbers in a range You want something like this: #include <time.h> #include <boost/random/mersenne_twister.hpp> #include <boost/random/uniform_int_distribution.hpp> std::time(0) gen; int random_number(start, end) { boost::random::uniform_int_distribution<> dist(start, end); return dist(gen); } edit: this related question probably will answer most … Read more

[Solved] char array length c++

[ad_1] you can use vector #include <vector> … int n; cin >> n; vector<int> vec(n); … int size_of_vector = vec.size(); … [ad_2] solved char array length c++

[Solved] C# Methods in console Based [closed]

[ad_1] As several people have indicated in the comments, the indiscriminate use of out and ref is a bad practice. With that said, your first major problem is that the code as written doesn’t compile because you’re passing parameters in in the wrong order. For example: CalculateCostMeth(ref numberOfDrawers, ref cost, ref deskWoodType); should actually be … Read more

[Solved] Usage of uint_8, uint_16 and uint_32

[ad_1] In your 3 cases, before the printf statement, the 4 first bytes of the arr array (in hexadecimal format) are: FF D8 FF E0, which corresponds to 255 216 255 224. Here are explanations of each case: arr[0] has uint8_t type, so its 1-byte value is 0xFF, so printf(“%i”, arr[0]); prints 255, which corresponds … Read more

[Solved] How to send multiple emails in the background? [closed]

[ad_1] Don’t send the e-mails from the ASP.Net application, because that costs time, as you’ve noticed yourself. I would create a database table named Emails. The ASP.Net application would only generate rows, but not send the e-mails itself. Create a console application, whose sole purpose is generating e-mails from the Emails-table. Use the Windows Taskscheduler … Read more

[Solved] Generic class of one type to another type in auto mapper

[ad_1] For Mapper.Map<PagedList<CasteModel>>(result);, you need to initialize Mapper like below in Startup.cs public void ConfigureServices(IServiceCollection services) { Mapper.Initialize(cfg => { cfg.AddProfile<AppProfile>(); }); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); } But, it it recommended to use Dependence Injection to resolve Mapper. Install Package AutoMapper.Extensions.Microsoft.DependencyInjection Startup.cs public void ConfigureServices(IServiceCollection services) { services.AddAutoMapper(typeof(Startup)); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); } UseCase public class ValuesController : ControllerBase { private … Read more

[Solved] Convert non-async Linq Extension method to Async [closed]

[ad_1] This is an XY problem. What you’re trying to achieve isn’t the same thing as what your question is asking. Your desired syntax wouldn’t work, even if you made this method async: var courses = await ids.ToChunks(1000) .Select(chunk => Courses.Where(c => chunk.Contains(c.CourseID))) .SelectMany(x => x).ToListAsync(); And the result you really want is just as … Read more

[Solved] bug in the code below in terms of synthax, design? [closed]

[ad_1] In the current form all the methods are private. You can make getAverage() and addElement() public by: class Elements { int nbValues; int values[MAX]; double coefs[MAX]; Element(){} public: // all the members & methods below will be public double getAverage() { int sum; for(int i =1; i<= MAX; i++) { sum = sum+values[i]*coefs[i]; } … Read more

[Solved] Windows form button displays textbox and enter name to create new button [closed]

[ad_1] Unfortunately there is no InputMessageBox in C#. But you can reference “Microsoft.VisualBasic” and dann using the Interaction.InputBox. using Microsoft.VisualBasic; // Click-Event private void btn_GetName_Click(object sender, EventArgs e) { string btnTxt = Interaction.InputBox(“Title”, “Message”, “defaultValue”, 10, 10); Button button1 = new Button(); button1.Location = new Point(20, 10); button1.Text = btnTxt; this.Controls.Add(button1); } This is a … Read more