Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include<iostream>
- #include<cstdio>
- #include<cstdlib>
- #include<algorithm>
- #include<cmath>
- #include<string>
- #include<cstring>
- #include<vector>
- using namespace std;
- void swap(int a, int b) {
- }
- int main() {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- int a[5] = {2, 0, 1, 2, 0};
- int b[5] = {-1, 7, 2, 3, 2};
- int n = 5;
- for(int i=0; i<(n-1); i++)
- {
- for(int j=0; j<(n-i-1); j++)
- {
- int temp = 0;
- if(a[j]>a[j+1])
- {
- temp=a[j];
- a[j]=a[j+1];
- a[j+1]=temp;
- temp=b[j];
- b[j]=b[j+1];
- b[j+1]=temp;
- }
- if(a[j]==a[j+1]) {
- if (b[j] > b[j+1]) {
- temp=a[j];
- a[j]=a[j+1];
- a[j+1]=temp;
- temp=b[j];
- b[j]=b[j+1];
- b[j+1]=temp;
- }
- }
- }
- }
- for (int i=0;i<n;i++) {
- cout << a[i] << ' ' << b[i] << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement