Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

hwo to change and remove the value of array(2 dimention

+1 vote
asked Nov 24, 2019 by 王浩 (170 points)

#include <stdio.h>
int fb(int m,int a[][2]);
int main() {
    int m=4;
    int a[4][2]={{3,19},{11,33},{18,80},{80,100}};
    return 0;
int fb(int m,int a[][2]) {
    int i,j,tem;
            if (a[i]>a[i+1]){



output i want:

2, 10, 17, 19, 33, 79, 80, 100

3 Answers

+1 vote
answered Nov 25, 2019 by gameforcer (2,990 points)
selected Jan 4, 2020 by 王浩
Best answer
1. You can't swap rows of the 2D array with pointers. That's not how it works.

2. You can't compare entire rows of a 2D array (which is basically comparing two 1D arrays...).

3. Using "m*2-1" doesn't mean your 2D array magically gets bigger. Your array is exactly [2][4] and trying to print out a number (or actually a row in this case?) at a position "a[7]" (which is result of "4*2 - 1") doesn't help.

4. If you're trying to sort a 2D array then in my opinion flattening it to 1D, sorting it and then putting it back into 2D is your best bet. https://onlinegdb.com/HJWptKOnB - here's an example. Quick sort (which is the name of 1 of the most popular sorting methods) implementation is not mine as I was too lazy to write it myself.
0 votes
answered Nov 24, 2019 by RAGE MONSTER rocks (570 points)
can you please elaborate your code ,

i cant just understand the working or objective of this code

first , what you want to to.  (aim of the code)

second , give your input values.

third , what are the expected outputs ?
0 votes
answered Nov 25, 2019 by rohan ag (1,310 points)
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.