Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22113

Is there any solution of the error of sorting user input array using STL?

$
0
0

My code is:

#include<bits/stdc++.h>#include<stdio.h>using namespace std;struct Interval{    int init,last;};bool compare(Interval a,Interval b){    return (a.init < b.init);}int main(){        int t,i,j;        int a[1000];        cin >> t;        for( j=0;j<t;++j){          for(i=0;i<t;i++)          {               cin >> a[i];                  }          }        sort(a,a+t,compare);       for( j=0;j<t;++j)       for(i=0;i<t;i++)        {          cout<<a[i]<<"";       }       cout<<"\n";       return 0;}

What is the solution of the below line?

sort(a,a+t,compare);

Viewing all articles
Browse latest Browse all 22113

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>