[Solved] C++, twenty numbers not random? [closed]

You need to call rand() each time you want a random number. As you have it now you’re generating one random number, then incrementing it and printing it out 20 times so you’re going to get 20 sequential numbers. Try something like srand(time(NULL)); // Seeding the random number generator for(int i=0; i<20; ++i) { cout … Read more

[Solved] How can I install a github plugin into my xamarin forms solution? (VS Mac 2017)

Example using Connectivity Plugin by James Montemagno Github Plugin : ConnectivityPlugin Open your Project and right click on Packages and select add package If you are using .NET 2 you can do it this way Search for Xam.Plugin.Connectivity I found the name here (plugins normally have a link on their github branch) Nuget : Xam.Plugin.Connectivity … Read more

[Solved] Most efficient way to concatenate list within list without a loop

List<int> theInts = unicorns.SelectMany(unicorn => unicorn.Numbers).ToList(); Without measuring, the only thing in here that gives me pause from a performance perspective is the .ToList If there are a TON of numbers, it’s possible that ToList may repeatedly re-allocate its backing array. In order to escape this behavior, you have to have some idea about how … Read more

[Solved] c#: (True==True) returning False [closed]

I can see two possibilities: useaction.Postcondition[goalneeds] and current[goalneeds] return something other than a bool. They return an object of a class that has a ToString() method which sometimes returns the string “True”. The specific objects returned in your case both generate “True” but are not the same object, so == is false (or the type … Read more

[Solved] Find the Shortest Cycle in Graph

If You’re looking for a complete answer, then just check other answers – there are tons of questions regarding used algorithms and I’ve also found an answer with code ported to many different programming languages (Cpp version is also there) Algorithm explanation C++ version I’d strongly recommend though, that You take a look at algorithms … Read more

[Solved] Replace string value in C#? [closed]

You should not redeclare the variable twice but only modify its value: for (int i = 0; i < Model.Items.Count; i++) { string SelectedEvent = “event selected”; if (i > 1) { SelectedEvent = “event”; } // here you can use the SelectedEventVariable // its value will be “event selected” on the first and second … Read more

[Solved] Cannot understand Behaviour of Static In C and C++ [closed]

This has nothing to do with statics whatsoever. Your problem can be reproduced with a much smaller piece of code that has no static variables in it at all. The compilation error is very clear: main.cpp: In function ‘int main()’: main.cpp:12:1: error: jump to label ‘b’ [-fpermissive] b: ^ main.cpp:9:10: error: from here [-fpermissive] goto … Read more

[Solved] pointer being freed was not allocated in C

You assigned outputMessage, which is an array and is converted to a pointer to the first element of the array, to messagePtr, so messagePtr no longer points at what is allcated via malloc() or its family. Passing what is not NULL and is not allocated via memory management functions such as malloc() invokes undefined behavior. … Read more

[Solved] Two format specifiers but only one argument [closed]

This is enough I suppose for explaining whatever you have shown. And the behavior you see can be anything given that it is undefined. From standard The fprintf function writes output to the stream pointed to by stream, under control of the string pointed to by format that specifies how subsequent arguments are converted for … Read more

[Solved] What are the following notations pointing to?

int arr[4][3][2] means arr is 3D array, consists four 2D array, each 2D array having three 1D array and each 1D array having two-two elements. Let’s Have a pictorial representation of arr : Assume arr base address is 0x100. arr[0][0][0] arr[1][0][0] arr[2][0][0] arr[3][0][0] 0x100 0x104 0x108 0x112 0x116 0x120 0x124 0x128 0x132 0x136 0x140 0x144 … Read more

[Solved] string equal doesn’t work c++

I suggest adding some debugging output to your program: while (!fileEn.eof()){ getline(fileEn,line); // Debugging output std::cout << “en[” << i << “] = ‘” << line << “‘” << std::endl; en[i]=line; i++; } and for(int i = 0; i < 100; ++i){ Matn >> matn[i]; // Debugging output std::cout << “matn[” << i << “] … Read more

[Solved] graphics in c and c++ [closed]

In addition to the backslash issue in the path, it’s extremely unlikely that you are using a 3270 compatible display. Why don’t you pass in the address of a with a=0. ab must be set to a requested mode unless you set the driver to autodetect, which will then select the highest available mode. See … Read more