Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int N = 0;
- do {
- cout << "Upisite N: ";
- cin >> N;
- }while(N <= 0);
- int poljeV[N];
- string poljeK[N];
- for(int i = 0; i < N ; ++i) {
- cout << "Upisite " << i+1 << ". element: znak: ";
- cin >>poljeK[i];
- cout << "Upisite " << i+1 << ". element: broj: ";
- cin >>poljeV[i];
- }
- for(int i = 1; i < N; ++i) {
- int j = i;
- while( j > 0 && poljeV[j] < poljeV[j-1]) {
- swap(poljeV[j], poljeV[j-1]);
- swap(poljeK[j], poljeK[j-1]);
- --j;
- }
- }
- for(int i = 0; i < N; ++i) {
- for(int j = 0; j < poljeV[i]; ++j)
- cout << poljeK[i];
- cout << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment