Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Zad18-18c-s13810
- #include <iostream>
- using namespace std;
- void mix(int* a, int a_size, int* b, int b_size);
- void swap_t(int* a, int a_ind, int* b, int b_ind);
- void show_tab(int *tab, int tab_size);
- void mix(int* a, int a_size, int* b, int b_size){
- for(int i=0; i<b_size; i++){
- for(int j=0; j<a_size; j++){
- if(*(a+j) > *(b+i))
- swap_t(a, j, b, i);
- }
- }
- for(int i=0; i<b_size; i++){
- for(int j=0; j<b_size; j++){
- if(*(b+j) > *(b+i))
- swap_t(b, j, b, i);
- }
- }
- }
- void swap_t(int* a, int a_ind, int* b, int b_ind){
- int temp = *(a+a_ind);
- *(a+a_ind) = *(b+b_ind);
- *(b+b_ind) = temp;
- }
- void show_tab(int *tab, int tab_size){
- cout << "{";
- for(int i=0; i<tab_size; i++){
- cout << *(tab++);
- if(i != tab_size -1)
- cout << " , ";
- }
- cout << "}";
- }
- int main()
- {
- int a[] = {1, 2, 2, 3, 5, 6};
- int b[] = {2, 4, 5, 8};
- int a_size = 6;
- int b_size = 4;
- cout << "Przed miksowaniem" << endl;
- cout << "a = ";
- show_tab(a, a_size);
- cout << "\nb = ";
- show_tab(b, b_size);
- cout << endl;
- mix(a, a_size, b, b_size);
- cout << "\nPo miksowaniu" << endl;
- cout << "a = ";
- show_tab(a, a_size);
- cout << "\nb = ";
- show_tab(b, b_size);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement