Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cmath>
- #include <iostream>
- #include <iomanip>
- #include <cstdlib>
- #include <time.h>
- //bąbelkowe
- using namespace std;
- int main()
- {
- int N;
- cout <<"Ile losowych liczb chcesz posortowac?";
- cin >> N;
- int tab[N],i,j;
- srand((unsigned)time(NULL));
- for(i = 0; i < N; i++)
- tab[i] = rand() % 100;
- for(i = 0; i < N; i++)
- cout << " " << tab[i];
- cout << endl;
- for(j = 0; j < N - 1; j++)
- for(i = 0; i < N - 1; i++)
- if(tab[i] > tab[i + 1])
- swap(tab[i], tab[i + 1]);
- cout << "Po sortowaniu:";
- for(i = 0; i < N; i++)
- cout <<" " << tab[i];
- cout << endl;
- return 0;
- }
- //dodawanie systemy:
- #include <iostream>
- using namespace std;
- int main()
- {
- cout << "Podstawa systemu w ktorym chcesz dodawac?"<< endl;
- int p;
- cin >> p;
- if (p>=2&&p<=9)
- {
- long long a,b;
- cout << "Jakie dwie liczby chcesz dodac?" << endl;
- cin >> a >> b;
- long long wynik=0;
- int mnoznik=1;
- int dalej=0;
- while (a>0||b>0||dalej>0)
- {
- int temp=(a%10)+(b%10)+dalej;
- if (temp>=p)
- {
- wynik=wynik+(temp%p)*mnoznik;
- dalej=temp/p;
- }
- else
- {
- wynik=wynik+temp*mnoznik;
- dalej=0;
- }
- mnoznik=mnoznik*10;
- a=a/10;
- b=b/10;
- }
- cout << wynik <<endl;
- }
- else
- cout << "Daj inna podstawe pls"<< endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement