Coding | Mcqs | Multiple choice questions | Informative | Computer Science | Engineering | Aptitude | Quants | Verbal

INFEED

3 rd neha

 NOTE : 2 TEST CASES PASS



#include<stdio.h>
int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    int arr[a];
    int d,e;int count;
    for(int i=0;i<a;i++)
    scanf("%d",&arr[i]);
    for(int i=0;i<b;i++)
    { count=0;
        scanf("%d%d",&d,&e);
        for(int j=d-1;j<e-1;j++)
        { for (int k=j+1;k<e;k++)
            {if(arr[j]>arr[k])
            count+=1; }
    }
printf("%d\n",count);}
}


C compiler

Post a Comment

Previous Post Next Post