Generate All Possible Subsets with Exactly K Elements in C++

Samual Sam
Updated on 30-Jul-2019 22:30:26

378 Views

This is a C++ program to generate all possible subsets with exactly k elements in each subset.AlgorithmsBegin    function PossibleSubSet(char a[], int reqLen, int s, int currLen, bool check[], int l):    If currLen > reqLen    Return    Else if currLen = reqLen       Then print the new generated sequence.    If s = l       Then return no further element is left.       For every index there are two options:          either proceed with a start as ‘true’ and recursively call PossibleSubSet()          with incremented value ... Read More

Java ResultSet Relative Method with Example

Rishi Raj
Updated on 30-Jul-2019 22:30:26

1K+ Views

When we execute certain SQL queries (SELECT query in general) they return tabular data.The java.sql.ResultSet interface represents such tabular data returned by the SQL statements.i.e. the ResultSet object holds the tabular data returned by the methods that execute the statements which quires the database (executeQuery() method of the Statement interface in general).The ResultSet object has a cursor/pointer which points to the current row. Initially this cursor is positioned before first row.The relative() method of the ResultSet interface moves the ResultSet pointer/cursor n number of rows from the current position.This method returns an integer value representing the current row number to which the ResultSet pointer ... Read More

Use Result from MongoDB in Shell Script

Smita Kapse
Updated on 30-Jul-2019 22:30:26

570 Views

Let us first create a collection with a document −>db.useResultDemo.insertOne({"StudentFirstName":"Robert"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cda70f5b50a6c6dd317adcd") }Display all documents from a collection with the help of find() method −> db.useResultDemo.find();Following is the output −{ "_id" : ObjectId("5cda70f5b50a6c6dd317adcd"), "StudentFirstName" : "Robert" }Here is the query to use result from MongoDB in shell script with var keyword −> var studentName=db.useResultDemo.findOne({},{_id:0}); > studentNameFollowing is the output −{ "StudentFirstName" : "Robert" }

Use Enum Type with a Constructor in Java

raja
Updated on 30-Jul-2019 22:30:26

304 Views

Enum type can have a private constructor that can be used to initialize instance fields. The EnumDemo class demonstrates this. It features a Food enum type with four constants: HAMBURGER, FRIES, HOTDOG, and ARTICHOKE. Notice that after each constant value is present in parentheses. This calls the constructor for that member to initialize the price field for that member. We iterate over the Food values in the for loop in the main() method. In this method, we first display the name of the food constant. Next, we examine the price for that food item and display whether the price is expensive or ... Read More

HTML Area Hreflang Attribute

Chandu yadav
Updated on 30-Jul-2019 22:30:26

241 Views

The hreflang attribute of the element is used to set the language of the url in the area. Following is the syntax −Above, code is the ISO language code set for the language, for example, en for English, fr for French, js for Japanese, etc. Let us now see an example to implement the hreflang attribute for the element −Example Live Demo Learning Learn these technologies with ease....             OutputIn the above example, we have set the map on the following image −Now, we have set the map and ... Read More

Stop C++ Console Application from Exiting Immediately

Anvi Jain
Updated on 30-Jul-2019 22:30:26

1K+ Views

Sometimes we have noticed that the console is being closed immediately after displaying the result. So we cannot see the result properly. Here we will see how we can stop the console from closing.The idea is very simple. We can use the getchar() function at the end. This will wait for one character. If one character is pressed, the console will exit.Example Live Demo#include using namespace std; int main() {    cout

Use of Object.is() Method in JavaScript

vineeth.mariserla
Updated on 30-Jul-2019 22:30:26

211 Views

Object.is()Object.is() is used to check whether two values are same or not. Two values are same when they have the following criteria. Either both the values are undefined or null .Either both are true or false.Both strings should be of same length, same characters and in same order.The polarities of both the values should be equal.Both the values can be NaN and should be equal.syntaxObject.is(val1, val2);It accepts two parameters and scrutinize whether they are equal or not. If equal gives out true as output else false as output.There is a small difference between Object.is() and "==" that is when comparing +0 and -0, the former results false whereas the latter results true. ... Read More

Get Data Associated with Maximum ID in MySQL Table

Kumar Varma
Updated on 30-Jul-2019 22:30:26

151 Views

We will first order by DESC and then fetch the value associated with maximum id −select *from yourTableName order by yourColumnName DESC LIMIT 1, 1;Let us first create a table −mysql> create table DemoTable    -> (    -> Alldata int    -> ); Query OK, 0 rows affected (0.63 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(303); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values(560); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values(100); Query OK, 1 row affected (0.13 sec) mysql> insert ... Read More

HTML DOM History Length Property

Sharon Christine
Updated on 30-Jul-2019 22:30:26

150 Views

The HTML DOM History length property returns of URLs in the History list of current window.SyntaxFollowing is the syntax −history.lengthExampleLet us see an example of HTML DOM History length property − Live Demo    body{       text-align:center;    }    .btn{       background-color:lightblue;       border:none;       height:2rem;       border-radius:50px;       width:60%;       margin:1rem auto;    }    .show{       font-size:2rem;       font-weight:bold;       color:orange;    } History length Property Example Click me to get History length    function getHistoryLength(){       var historyLength=history.length;       document.querySelector(".show").innerHTML = historyLength;    } OutputThis will produce the following output −Click on the “blue” button to see the history length of current browser window.

HTML DOM label for Property

AmitDiwan
Updated on 30-Jul-2019 22:30:26

214 Views

The HTML DOM Label htmlFor property returns/sets the value of for attribute.SyntaxFollowing is the syntax −Returning value of for attribute −labelObject.htmlForExampleLet us see an example for Label htmlForproperty − Live Demo Label htmlFor    form {       width:70%;       margin: 0 auto;       text-align: center;    }    * {       padding: 2px;       margin:5px;    }    input[type="button"] {       border-radius: 10px;    } Label-htmlFor Current Editor: Label for attribute set as editor two ... Read More

Advertisements