"program to swap max and min in matrix" Code Answer's

You're definitely familiar with the best coding language C++ that developers use to develop their projects and they get all their queries like "program to swap max and min in matrix" answered properly. Developers are finding an appropriate answer about program to swap max and min in matrix related to the C++ coding language. By visiting this online portal developers get answers concerning C++ codes question like program to swap max and min in matrix. Enter your desired code related query in the search bar and get every piece of information about C++ code related question on program to swap max and min in matrix. 

program to swap max and min in matrix

By Nutty NarwhalNutty Narwhal on Jan 02, 2021
#include <stdio.h>

int main(void)
{
    int rows, cols;
    do
    {
          printf("Give me the number of rows :");
          scanf("%d",&rows);
    }while(rows<1);
    do
    {
          printf("Give me the number of cols :");
          scanf("%d",&cols);
    }while(cols<1);
    int arr[rows][cols];
    printf("\nThe filling of the Matrix :\n");
    for (int i = 0; i < rows; i++)
    {
        for (int j = 0; j < cols; j++)
        {
            scanf("%d", &arr[i][j]);
        }
    }
    int i_max = 0,j_max=0;
    int i_min = 0,j_min=0;
    int max=arr[0][0];
    int min=arr[0][0];
    for (int i = 0; i < rows; i++)
    {
        for (int j = 0; j < cols; j++)
        {
            if (arr[i][j]>max)
            {
                max=arr[i][j];
                i_max=i;// i_max mean's the index i of the maximum element
                j_max=j;// j_max mean's the index j of the maximum element
            }
            if(arr[i][j]<min)
            {
                min=arr[i][j];
                i_min=i;// i_max mean's the index i of the minimum element
                j_min=j;// j_max mean's the index j of the minimum element
            }
        }
    }
    printf("\nDisplay of the Matrix before the swap :\n");
    for (int i = 0; i < rows; i++)
    {printf("\n");
        for (int j = 0; j < cols; j++)
        {
             printf("[%d]", arr[i][j]);
        }
    }

    int temp=arr[i_min][j_min];
    arr[i_min][j_min]=arr[i_max][j_max];
    arr[i_max][j_max]=temp;

    printf("\n\nDisplay of the Matrix after the swap :\n");

    for (int i = 0; i < rows; i++)
    {printf("\n");
        for (int j = 0; j < cols; j++)
        {
            printf("[%d]", arr[i][j]);
        }
    }
    return 0;
}

Source: stackoverflow.com

Add Comment

0

All those coders who are working on the C++ based application and are stuck on program to swap max and min in matrix can get a collection of related answers to their query. Programmers need to enter their query on program to swap max and min in matrix related to C++ code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about program to swap max and min in matrix for the programmers working on C++ code while coding their module. Coders are also allowed to rectify already present answers of program to swap max and min in matrix while working on the C++ language code. Developers can add up suggestions if they deem fit any other answer relating to "program to swap max and min in matrix". Visit this developer's friendly online web community, CodeProZone, and get your queries like program to swap max and min in matrix resolved professionally and stay updated to the latest C++ updates. 

C++ answers related to "program to swap max and min in matrix"

View All C++ queries

C++ queries related to "program to swap max and min in matrix"

program to swap max and min in matrix Given bigger NxN matrix and a smaller MxM matrix print TRUE if the smaller matrix can be found in the bigger matrix else print FALSE max and min of vector c++ get min and max element index from vector c++ find min and max in array c++ min and max heap in cpp c++ max and min of vector "how we write a program for" time swap" in c plus plus only with string" can we compare a long long int with int in c++ using max or min functions what is require to run min max function on linux in cpp c++ program for matrix addition c ++ Program for addition of two matrix in diagonal using pointers swap first and last character of string in c++ Write a program to sort an array 100,200,20, 75,89.198, 345,56,34,35 using Bubble Sort. The program should be able to display total number of passes used for sorted data in given data set. Write a C++ program using class and objects. You have to define multiple-member functions outside class and all those functions will be the same name write a c++ program that reads ten strings and store them in array of strings, sort them and finally print the sorted strings swap values in array c++ what is time complexity of swap function swap in cpp C++ Vector swap syntax cuda atomic swap what did swap method return in c++ swap function in cpp c++ swap function delete and search edge in adjacency matrix of a graph heap sort heapify and max heap in binary tree min heap in c++ min in vector c++ c++ min min heap priority queue c++ integer min value c++ min array c++ c++ min int min heap priority queue with pair how to store pair in min heap in c++ Priority Queue using Min Heap in c++ min heap c++ stl priority queue min heap Min heap stl Write a program that inputs test scores of a student and display his grade c++ program to input and print text using Dynamic Memory Allocation.loop c++ program that calculates the distance covered by a vehicle given the speed and time. Write a program that inputs time in seconds and converts it into hh-mm-ss format Write a c++ program that reads a sentence (including spaces) and a word, then print out the number of occurrences of the word in the sentence simple program for sign in and sign up in c++ a bag1 contains red blue and green balls and bag2 contains red blue and green balls in c++ matrix multiplication in c++ add two matrix matrix multipliction in c++ matrix class in c++ transpose matrix eigen c++ matrix multiplication c++ eigen size of a matrix using vector c++ graph using djacency matrix c++ eigenvalue of matrix c++ using Eigen matrix eigen c++ example print matrix c++ transpose of a matrix in c++ create matrix cpp inverse of a matrix 3x3 c++ adjacency matrix of a directed graph 3x3 matrix multiplication in c++ matrix transpose tiling size of a matrix c++ import matrix from excel to matlab store matrix in c++ matrix in vector c++ the statement vector vector int matrix(100 vector int (50 100) ) declares Specific Pair in Matrix matrix 4x4 look at c++ Specific pair in matrix c++ max three values c++ double max value c++ max of a vector c++ max element in vector c++ flake8 max line length c++ max of array max heap in c++ max element in array c++ stl max in c++ max c++ int max in c++ max heap c++ stl; max pooling in c++ max heap c++ max value of double c++ max array c++ max two numbers c++ SFML texture from file max size how to find the max b=etween 3number in cpp what is max rand in C++ find max value in array c++ c program to add two numbers sfml base program Name one example of a “decider” program that you regularly encounter in real life. sfml basic program binary search program c++ c++ program for addition of two numbers using functions c++ calculator program using switch case program to calculate factorial of number in c++ polymorphism-program.cpp compile c++ program tower of hanoi program in c Write a program to find the sum of all sub-arrays of a given integer array. write a program to implement stack using array sfml default program c++ object program infix to postfix program in c++ if else program in c ++ run c++ program in mac terminal program to know if a number is prime running a c++ program in visual studio code cannot edit in read only editor Write a program to print following pattern; 1 1 2 1 2 3 1 2 3 4 insertion sort in c++ program c++ prime number program c++ program to reverse an array all pair shortest path algorithm in c with program c++ hello world program cpp program to find average of n numbers how to end a c++ program early c++ input from terminal when program is called Application of c++ in youtube program c++ program to find gcd of 3 numbers c++ program to generate prime numbers run program until ctrl-d c++ fcfs preemptive scheduling program in c++ infix to prefix using cpp linked list program Write a c++ program to print number triangle. menu driven program to delete in linked list how to type a vertical stack program c++ c++ program to count number of characters of words in a file using stringstream cpp program to temove space from string write a program that simulates the rolling of two dice in c++ c++ program to print fibonacci series malloc c++ program set keybinding for compiling c++ program in neovim c++ program how to let the user choose different game modes Write a program to implement Liang-Bersky line clipping algorithm Create a program that finds the minimum value in these numbers bubble sort program in c++ how to run a c++ program in the background hello world program in c++ c++ how to create a program that stores details Dfs program in c++ how to make a c++ iostream program restart when finished Write a program in C++ to find post-order predecessor of a node in a Binary Tree bracket balancing program in java c program to convert infix to postfix how to make sure the user inputs a int and not anything else c++ unordered_map of pair and int c++ random number between 1 and 10 random number generator c++ between 0 and 1 what is difference between ciel and floor how to compile and run cpp code in terminal how to add and read a file in c++ in visual studio what is difference between single inverted and double inverted in programming languages how to get the player view point location and rotation in ue4 c++ how to speed up cin and cout what is the meaning of life and everything in the universe set and get in c++ even and odd in c++ remove or erase first and last character of string c++ map of int and vector syntax how to ensure the user inouts a int and not anything else c++ how to read and write in a file c++ what is difffrence between s.length() and s.size() How to find the suarray with maximum sum using divide and conquer difference between unsigned and signed int c++ C++ and endl std::cout and cout declare and define exception c++ Enter a key and display it's ascii value in c++ write and read string binary file c++ concatenation cpp int and stirng c++ forbids comparison between pointer and integer prints all the keys and values in a map c++ get first and last character of string c++ tellg and seekg c++ life the universe and everything solution c++ print pattern and space in cpp apple and orange hackerrank solution in c++ Dynamically allocate a string object and save the address in the pointer variable p. Split a number and store it in vector sweetalert2 email and password c++ stack and queue and c++ primitive and non primitive data types in c++ late binding and early binding in c++ difference between unsigned and signed c++ c++ sorting and keeping track of indexes how to declare string in c++ and taking the input buy and sell stock gfg working with char and string c++ using of and || c++ Write a c++ loop to read n characters from the keyboard and store them in the vector v. insertion and extraction operator overloading in c++ Write a loop to read n strings (containing no white space) from the keyboard and store them in the vector v. array and for loop in c++

Browse Other Code Languages

CodeProZone