Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<vector>
- #include<stdlib.h>
- using namespace std;
- int main(void)
- {
- int k, n, c;
- c = 1;
- while(n != 0)
- {
- cout << "n: ";
- cin >> n;
- cout << "k: ";
- cin >> k;
- vector<string> nome(n);
- pair<string, int> ind[n];
- pair<string, int> aux;
- for(int i = 0; i < n; i++)
- {
- cin >> nome[i];
- ind[i].first = nome[i];
- ind[i].second = i;
- }
- for(int i=0; i<=k; i++)
- {
- for (int j = (i+1); j <= k; j++)
- {
- if (ind[j] < ind[i])
- {
- aux = ind[i];
- ind[i] = ind[j];
- ind[j] = aux;
- }
- }
- }
- cout << "Instancia " << c++ << '\n';
- for(int i = 0; i < n; ++i)
- cout << ind[i].first << ' ';
- cout << "\n\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement