Count All Palindrome Sub-Strings in a String in C++

Ayush Gupta
Updated on 10-Feb-2020 11:13:53

221 Views

In this tutorial, we will be discussing a program to find the number of palindrome sub strings in a string.For this we will be given a string. Our task is to count the number of palindrome sub strings in the given string with length greater than 3.Example#include using namespace std; //counting palindrome strings int count_pstr(char str[], int n){    int dp[n][n];    memset(dp, 0, sizeof(dp));    bool P[n][n];    memset(P, false , sizeof(P));    for (int i= 0; i< n; i++)       P[i][i] = true;    for (int i=0; i

Get Started with C++ Programming

Daniol Thomas
Updated on 10-Feb-2020 11:12:51

665 Views

So you've decided to learn how to program in C++ but don't know where to start. Here's a brief overview of how you can get started.Get a C++ CompilerThis is the first step you'd want to do before starting learning to program in C++. There are good free C++ compilers available for all major OS platforms. Download one that suits your platform or you can use the tutorialspoint.com's online compiler on https://www.tutorialspoint.com/compile_cpp_online.phpGCC − GCC is the GNU Compiler chain that is basically a collection of a bunch of different compilers created by GNU. You can download and install this compiler ... Read More

Add JButton to JTable Cell in Java

raja
Updated on 10-Feb-2020 11:10:47

8K+ Views

A JTable is a subclass of JComponent class and it can be used to create a table with information displayed in multiple rows and columns. When a value is selected from a JTable, a TableModelEvent is generated, which is handled by implementing a TableModelListener interface. We can add or insert a JButton to JTable cell by customizing the code either in DefaultTableModel or AbstractTableModel and we can also customize the code by implementing TableCellRenderer interface and need to override getTableCellRendererComponent() method.Exampleimport java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.table.*; public class JTableButtonTest extends JFrame {    private JTable table;    private JScrollPane scrollPane;    public JTableButtonTest() {     ... Read More

Count All Pairs with Given XOR in C++

Ayush Gupta
Updated on 10-Feb-2020 11:07:13

255 Views

In this tutorial, we will be discussing a program to find the number of pairs with the given XOR.For this we will be provided with an array and a value. Our task is to find the number of pairs whose XOR is equal to the given value.Example#include using namespace std; //returning the number of pairs //having XOR equal to given value int count_pair(int arr[], int n, int x){    int result = 0;    //managing with duplicate values    unordered_map m;    for (int i=0; i

Applications of C++ Programming

Krantik Chavan
Updated on 10-Feb-2020 11:05:19

2K+ Views

C++ is a widely used programming language that is used for writing large-scale commercial applications for end-users. Some of the major applications built using C++ by major software vendors and giants are −Google − Google file system, Google Chromium browser, and MapReduce large cluster data processing are all written in C++.Mozilla − Mozilla Firefox and Thunderbird email chat client are both written using C++.MySQL − MySQL, an open source DBMS is written using C++.Microsoft − Many windows apps that you regularly use are written in C++.Rockstar Games − Almost all major game companies use C++ due to its sheer speed ... Read More

What is Object Oriented Programming (OOP)

Moumita
Updated on 10-Feb-2020 11:00:45

16K+ Views

Object-oriented programming (OOP) is a programming paradigm based on the concept of "objects", which may contain data, in the form of fields, often known as attributes; and code, in the form of procedures, often known as methods. For example, a person is an object which has certain properties such as height, gender, age, etc. It also has certain methods such as move, talk, and so on.ObjectThis is the basic unit of object-oriented programming. That is both data and function that operate on data are bundled as a unit called an object.ClassWhen you define a class, you define a blueprint for ... Read More

What is C++ Programming Language

Paul Richard
Updated on 10-Feb-2020 10:58:50

5K+ Views

C++ is a programming language developed by Bjarne Stroustrup in 1979 at Bell Labs. C++ is regarded as a middle-level language, as it comprises a combination of both high-level and low-level language features. It is a superset of C, and that virtually any legal C program is a legal C++ program. C++ runs on a variety of platforms, such as Windows, Mac OS, and the various versions of UNIX.It is a language that is − Statically typed − A programming language is claimed to use static typing when type checking is performed during compile-time as opposed to run-time. Compiled − A compiled ... Read More

Implement Search Functionality of a JTable in Java

raja
Updated on 10-Feb-2020 10:57:34

3K+ Views

A JTable is a subclass of JComponent for displaying complex data structures. A JTable component can follow the Model View Controller (MVC) design pattern for displaying the data in rows and columns. A JTable can generate TableModelListener, TableColumnModelListener, ListSelectionListener, CellEditorListener, RowSorterListener interfaces. We can implement the search functionality of a JTable by input a string in the JTextField, it can search for a string available in a JTable. If the string matches it can only display the corresponding value in a JTable. We can use the DocumentListener interface of a JTextField to implement it.Exampleimport java.awt.*; import javax.swing.*; import javax.swing.event.*; import javax.swing.table.*; public ... Read More

Count All Pairs of an Array Differing in K Bits in C++

Ayush Gupta
Updated on 10-Feb-2020 10:55:19

191 Views

In this tutorial, we will be discussing a program to find the number of pairs of an array which differ in K bits.For this we will be provided with an array and an integer K. Our task is to find the number of pairs who differ by K bits in their binary representation.Example#include using namespace std; //counting number of bits in //binary representation int count_bit(int n){    int count = 0;    while (n) {       if (n & 1)          ++count;       n >>= 1;    }    return count; } ... Read More

Call C++ Functions from Java

varun
Updated on 10-Feb-2020 10:51:32

2K+ Views

Following are the steps to use native methods.Create a header file (.h file) for a CPP program.Create CPP fileCreate a DLLIn java code, declare the method as native, load the DLL using System.loadLibrary() method and call the method.

Advertisements