Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- using namespace std;
- bool cmp(int a,int b)
- {
- if(a<b)
- return false;
- return true;
- }
- int main()
- {
- int n,m;
- char c;
- cin>>n>>m;
- cin>>c;
- int a[n*m+1];
- for(int i=1;i<=n*m;++i)
- cin>>a[i];
- if(c=='+')
- sort(a+1,a+n*m+1);
- else
- sort(a+1,a+n*m+1,cmp);
- for(int i=1;i<=n*m;++i)
- {
- cout<<a[i]<<' ';
- if(i%m==0)
- cout<<'\n';
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment