Print a 2D Array or Matrix in Java

George John
Updated on 14-Sep-2023 01:39:23

32K+ Views

In this post we will try to print an array or matrix of numbers at console in same manner as we generally write on paper.For this the logic is to access each element of array one by one and make them print separated by a space and when row get to end in matrix then we will also change the row.Example Live Demopublic class Print2DArray {    public static void main(String[] args) {       final int[][] matrix = {          { 1, 2, 3 },          { 4, 5, 6 },          { 7, 8, 9 }       };       for (int i = 0; i

Substitution Techniques in Information Security

Ginni
Updated on 14-Sep-2023 01:37:03

51K+ Views

Substitution technique is a classical encryption approach where the characters present in the initial message are restored by the other characters or numbers or by symbols. If the plain text (original message) is treated as the string of bits, thus the substitution technique would restore bit pattern of plain text with the bit pattern of cipher text.There are various types of substitution ciphers which are as follows −Monoalphabetic Cipher − In monoalphabetic substitution cipher, a character in a plaintext is always restored or changed to the similar character in the ciphertext indifferent of its position in the text.For instance, if ... Read More

C++ Program to Implement Stack Using Linked List

George John
Updated on 14-Sep-2023 01:28:41

49K+ Views

A stack is an abstract data structure that contains a collection of elements. Stack implements the LIFO mechanism i.e. the element that is pushed at the end is popped out first. Some of the principle operations in the stack are −Push - This adds a data value to the top of the stack.Pop - This removes the data value on top of the stack.Peek - This returns the top data value of the stack.A program that implements a stack using linked list is given as follows.Example#include using namespace std; struct Node {    int data;    struct Node *next; ... Read More

Get Next Auto Increment ID in MySQL

Arjun Thakur
Updated on 14-Sep-2023 01:25:33

34K+ Views

MySQL has the AUTO_INCREMENT keyword to perform auto-increment. The starting value for AUTO_INCREMENT is 1, which is the default. It will get increment by 1 for each new record. To get the next auto increment id in MySQL, we can use the function last_insert_id() from MySQL or auto_increment with SELECT. Creating a table, with "d" as auto-increment. mysql> create table NextIdDemo -> ( -> id int auto_increment, -> primary key(id) -> ); Query OK, 0 rows affected (1.31 sec) Inserting records into the table. mysql> insert into NextIdDemo ... Read More

Get Value from Cell of a Pandas DataFrame

Rishikesh Kumar Rishi
Updated on 14-Sep-2023 01:23:02

37K+ Views

To get a value from the cell of a DataFrame, we can use the index and col variables.StepsCreate a two-dimensional, size-mutable, potentially heterogeneous tabular data, df.Print the input DataFrame, df.Initialize the index variable.Initialize the col variable.Get the cell value corresponding to index and col variable.Print the cell value.Example Live Demoimport pandas as pd df = pd.DataFrame(    {       "x": [5, 2, 1, 9],       "y": [4, 1, 5, 10],       "z": [4, 1, 5, 0]    } ) print("Input DataFrame is:", df) index = 2 col = "y" cell_val = df.iloc[index][col] print ... Read More

Difference Between Electric Circuit and Magnetic Circuit

Manish Kumar Saini
Updated on 14-Sep-2023 01:22:09

44K+ Views

A circuit is a type of network having a closed path for the flow of either electric current or magnetic flux. A circuit mainly consists of three major parts viz. source, path or conductor and load. In simple words, the term circuit can be used to represent any fixed path through which electricity, data, single or magnetic flux can flow.Depending on the type of quantity (electric current or magnetic flux), the circuits can be of two types as −Electric circuitMagnetic circuitIn this article, we are going to see the differences between electric circuit and magnetic circuit. Also, we have added ... Read More

Resize an Image Using Tkinter

Dev Prakash Sharma
Updated on 14-Sep-2023 01:11:33

40K+ Views

To process images with Tkinter and other Python packages, we generally use the Pillow Package (or PIL) in Python. It provides a way to load, process, manipulate, convert, and helps to resize the images. The package can be installed by using the command pip install Pillow. Once the package is installed, we can import it using the 'from PIL import Image, ImageTk' command.To resize an image using the PIL package, we have to follow these steps −Install Pillow Package or PIL in the local machine.Open the Image using Open(image_location) method.Resize the given image using resize((w, h), Image.ANTIALIAS) method where ANTIALIAS removes ... Read More

Roman to Integer in Python

Arnab Chakraborty
Updated on 14-Sep-2023 01:09:07

37K+ Views

Suppose we have Roman literals; we have to convert them into an integer. As we know the Roman numerals represent in some different symbols as below −NumeralValueI1V5X10L50C100D500M1000If we see the roman numbers closely, it is like suppose the numeral is 'II', so this is 2, there are two 'I's are added together. For XII, it is 12, so this is actually X + II = 10 + 2 = 12. The roman numerals of 4 are not IIII, it is IV. This is a little tricky.I can be used before V(5) and X(10) to make it 4 and 9 respectivelyX ... Read More

Differences Between Virtual Circuits and Datagram Networks

Kiran Kumar Panigrahi
Updated on 13-Sep-2023 16:16:37

34K+ Views

Both Virtual Circuits and Datagram Networks are the types of connection services which are used for transmission of information from a sender to a receiver. The most basic difference between the two is that the virtual circuits are connection oriented services that require resources like buffers, CPU, bandwidth, etc., for a data transfer session, while the datagram networks are connectionless services where no such resources are required for data transmission. There are many other key differences between virtual circuits and datagram networks, which we will discuss in this article. What are Virtual Circuits? Virtual Circuit is a connection oriented service ... Read More

Discuss I/O Interface in Computer Architecture

Ginni
Updated on 13-Sep-2023 15:57:15

40K+ Views

The I/O interface supports a method by which data is transferred between internal storage and external I/O devices. All the peripherals connected to a computer require special communication connections for interfacing them with the CPU.I/O Bus and Interface ModulesThe I/O bus is the route used for peripheral devices to interact with the computer processor. A typical connection of the I/O bus to I/O devices is shown in the figure.The I/O bus includes data lines, address lines, and control lines. In any general-purpose computer, the magnetic disk, printer, and keyboard, and display terminal are commonly employed. Each peripheral unit has an ... Read More

Advertisements