Comparing two arrays in C, element by element

后端 未结 5 941
孤城傲影
孤城傲影 2020-12-20 20:30

I have been cracking my head at achieving something very simple in C in order to make my one of the programs (not written by me) in our computational physics project more dy

5条回答
  •  感情败类
    2020-12-20 21:19

    Today i came across same kind of problem statement,i googled for solution for an hour and end up with no solution,the above all approaches are not correct solutions for the stated problem

    The Better way to resolve above Problem is

    Sort the two arrays either in ascending or descending order, Then compare both the arrays.

    #include
     void sort_it(int a[], int size)
          {
           int i,j,temp=0;
           for(i=0;ia[j])
                    {
                    temp=a[i];
                    a[i]=a[j];
                    a[j]=temp;
                    }
            }
        }
    };
    
    int compare(int size,int a[],int b[])
    { 
        int i,j,is_equal;
        for(i=0;i

提交回复
热议问题