[Solved] CodeChef Small factorial Solution

The problem, as M Oehm has pointed out in the comments, is with the data type that you are using for fact. It is too small to store the factorial of numbers like 100, which contain around 157 digits. You need to use an array to store the digits. Here is my approach to the … Read more

[Solved] fstream read behavior upon hitting eof

From the documentation: If the input sequence runs out of characters to extract (i.e., the end-of-file is reached) before n characters have been successfully read, the array pointed to by s contains all the characters read until that point, and both the eofbit and failbit flags are set for the stream. … The number of … Read more

[Solved] How can we serialize or deserialize the object of a class in c++.Is there any predefined library? [closed]

There is no serialization library defined as part of the C++ standard. You will have to use a third party library (and requests for recommendations are off-topic for Stack Overflow), or you will have to write your own (and “how should I write a serialization library?” is probably “too broad”). solved How can we serialize … Read more

[Solved] That TextBox should retain the same value even after closing the form? [closed]

You might want to use User Settings. They’re different from Application Settings because they can be read and write between different sessions of the same applications. You can create a new setting at design time: Solution Explorer > Properties Double-click on the .settings file (this creates a new set in the default settings). Set name … Read more

[Solved] C: Weird conditional printf behavior [closed]

There is one semicolon after the if statement that is causing the problem. if (i!=0); { //this will always execute } change it to if (i!=0) { //this will execute if i != 0 } The compiler does not warn you because the first statement is syntactically valid. solved C: Weird conditional printf behavior [closed]

[Solved] if(checkbox.Checked){} issues [duplicate]

Checked is an event (that’s why an exception is being thrown when your code looks for an handler subscription, MSDN reference), IsChecked is a Boolean and it’s probably the property you are looking for (MSDN reference). Your code should look like this: private void button_Click(object sender, RoutedEventArgs e) { if ((bool)checkBox1.IsChecked) Console.Write(“Checked”); } 5 solved … Read more

[Solved] Unknown C++ statement

It’s a declaration of several variables in one line. Without obfuscation, it is equivalent to this: Mat gray; Mat smallImg( cvRound (img.rows/scale), cvRound(img.cols/scale), CV_8UC1 ); which shouldn’t need any further explanation. (In Ancient Times, when storage was sparse and terminals showed 24 lines of code, if you were lucky, using multiple-variable declarations made more sense … Read more

[Solved] How to select n numbers from n sets of different size?

You can use cartesian product on sets in Java by the use of com.google.common.collect.Sets. FOR EXAMPLE Set<Integer> s1=new HashSet<Integer>(); s1.add(1);s1.add(4);s1.add(5); Set<Integer> s2=new HashSet<Integer>(); s2.add(2);s2.add(3);s2.add(6); Set<Integer> s3=new HashSet<Integer>(); s3.add(7);s3.add(8);s3.add(8); Set<List<Integer>> set=Sets.cartesianProduct(s1,s2,s3); //Give type safety warning for(List<Integer> l:set){ System.out.println(l); } OUTPUT [1, 2, 7] [1, 2, 8] [1, 3, 7] [1, 3, 8] …. NOTE If you … Read more

[Solved] How can I make this work? (C)

if (moduleChoice == 1, gradeTestMain()); should be changed to if (moduleChoice == 1) gradeTestMain(); Likewise for other ifs. You need to close brackets – otherwise it means if (moduleChoice == 1, gradeTestMain()); which means if (moduleChoice == 1, gradeTestMain()) { ; } which means. evaluate moduleChoice == 1, throw away the result, then evalutate gradeTestMain(). … Read more

[Solved] Does this code block the file? [closed]

Depending on what you want you could add a fourth parameter to the File.Open method. To open the file with read only access and allow subsequent opening of the file for reading: private Stream GetFileStream(String path) { return !File.Exists(path) ? null : File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read); } This allows read and write: private Stream GetFileStream(String … Read more