Find Common Elements Between Two Arrays Using STL in C++

Ayush Gupta
Updated on 25-Feb-2020 07:59:32

287 Views

In this tutorial, we will be discussing a program to understand how to find common elements between two arrays using STL in C++.To find the common elements between two given arrays we will be using the set_intersetion() method.Example Live Demo#include using namespace std; int main(){    //defining the array    int arr1[] = { 1, 45, 54, 71, 76, 12 };    int arr2[] = { 1, 7, 5, 4, 6, 12 };    int n1 = sizeof(arr1) / sizeof(arr1[0]);    int n2 = sizeof(arr2) / sizeof(arr2[0]);    sort(arr1, arr1 + n1);    sort(arr2, arr2 + n2);    cout

Draw Circle in HTML Page

Smita Kapse
Updated on 25-Feb-2020 07:51:53

10K+ Views

To draw a circle in HTML page, use SVG or canvas. You can also draw it using CSS, with the border-radius property.ExampleYou can try to run the following code to learn how to draw a circle in HTMLLive Demo                    #circle {             width: 50px;             height: 50px;             -webkit-border-radius: 25px;             -moz-border-radius: 25px;             border-radius: 25px;             background: blue;          }                        

Work with Scalable Vector Graphics (SVG) in HTML5

Nishtha Thakur
Updated on 25-Feb-2020 07:50:58

374 Views

SVG stands for Scalable Vector Graphics and it is a language for describing 2D-graphics and graphical applications in XML and the XML is then rendered by an SVG viewer.SVG is mostly useful for vector type diagrams like Pie charts, Two-dimensional graphs in an X, Y coordinate system etc.To work with Scalable Vector Graphics (SVG) in HTML5, embed SVG directly using ... tags with the following syntax −Syntax    ... To draw a shape in HTML5 SVG, use element to draw a circle. element to draw a rectangle. element to draw a line. element to draw and ellipse. element to draw ... Read More

Create Unordered Set of User-Defined Class or Struct in C++

Ayush Gupta
Updated on 25-Feb-2020 07:49:36

823 Views

In this tutorial, we will be discussing a program to understand how to create an unordered set of user defined class or struct in C++.For this we will create a structure type and then compare two structure types with the function defined by the user to store the hash function.Example#include using namespace std; //defined structure struct Test {    int id;    bool operator==(const Test& t) const{       return (this->id == t.id);    } }; //defined class for hash function class MyHashFunction {    public:       size_t operator()(const Test& t) const{         ... Read More

Play Sound File in a Web Page in the Background

Smita Kapse
Updated on 25-Feb-2020 07:37:38

26K+ Views

The HTML element is used to add audio to web page. To play sound file in the background on a web page, use the … element. Also, use the autoplay attribute. This will run music in the background whenever the page loads.Set the width and height in a way the player hides on the web page. The loop attribute is added to specify whether the audio will start over again.You can try to run the following code to play a sound file in a web page in the backgroundExampleLive Demo           HTML background music ... Read More

Create Unordered Map of User-Defined Class in C++

Ayush Gupta
Updated on 25-Feb-2020 07:36:24

633 Views

In this tutorial, we will be discussing a program to understand how to create an unordered map of user defined class in C++.To create an unordered map from a user defined class, we will pass the hash function as the class method being the third argument.Example Live Demo#include using namespace std; //objects of class to be used as key values struct Person {    string first, last;    Person(string f, string l){       first = f;       last = l;    }    bool operator==(const Person& p) const{       return first == p.first && ... Read More

Create Unordered Map of Pairs in C++

Ayush Gupta
Updated on 25-Feb-2020 07:31:23

978 Views

In this tutorial, we will be discussing a program to understand how to create an unordered map of pairs in C++.Unordered maps are the ones that don't contain hash function for the pairs by default. If we want a hash value for a particular pair, it needs to be passed on explicitly.Example Live Demo#include using namespace std; //to hash any given pair struct hash_pair {    template    size_t operator()(const pair& p) const{       auto hash1 = hash{}(p.first);       auto hash2 = hash{}(p.second);       return hash1 ^ hash2;    } }; int main(){ ... Read More

Limit Input Text Length Using CSS3

Vikyath Ram
Updated on 25-Feb-2020 07:28:19

1K+ Views

With HTML, you can easily limit input length. However, with CSS3, it will not be possible, since CSS can’t be used to limit the number of input characters. This will cause a functional restriction.CSS deals with presentation i.e. how your web page will look. This is done with HTML attribute malength, since it’s for behavior.Let’s see how to do it in HTML −ExampleYou can try to run the following code to limit input text lengthLive Demo           HTML maxlength attribute                        Student Name                    

Create a List with Constructor in C++ STL

Ayush Gupta
Updated on 25-Feb-2020 07:28:17

268 Views

In this tutorial, we will be discussing a program to understand how to create a List with constructor in C++ STL.List are data structures to store elements in memory in a non-contiguous fashion. They are insertion and deletion quick as compared to vectors.Example Live Demo#include #include using namespace std; //printing the list void print_list(list mylist){    list::iterator it;    //printing all the elements    for (it = mylist.begin(); it != mylist.end(); ++it)       cout

Use Splash Vector Graphics on Your Responsive Site

Rishi Raj
Updated on 25-Feb-2020 07:27:10

245 Views

Graphics for your responsive site can make it slower, but balancing it with vector graphics can help in minimizing the bandwidth. Through this, amazing graphics work great on mobile site too. Generally, canvas and SVG is used for this purpose.Use HTML5 Scalable Vector Graphics (SVG) to create a design for multiple screen sizes, since it handles it perfectly. Easily present vector based line drawings and do not worry about the pixels on your device since the graphics created with SVG are resolution independent. It scales the result and looks great in the browser.Here, we will look how to work with ... Read More

Advertisements