Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <stdio.h>
- #include <cstdlib>
- #include <time.h>
- #include <string>
- #include <math.h>
- using namespace std;
- void poteg(int a, int b) {
- cout << "Poteg : " << pow(a,b) << endl;
- }
- void hey(string d) {
- cout << " YOUR NAME IS : " << endl;
- cout <<d<< endl;
- }
- void silnia(int f1) {
- int s;
- s = f1;
- long long silnia = 1;
- for (int i = 1; i <= s; i++)
- silnia *= i;
- cout << silnia << endl;
- }
- void quick_sort(int *tab, int lewy, int prawy)
- {
- if (prawy <= lewy) return;
- int i = lewy - 1, j = prawy + 1,
- pivot = tab[(lewy + prawy) / 2];
- while (1)
- {
- while (pivot>tab[++i]);
- while (pivot<tab[--j]);
- if (i <= j)
- swap(tab[i], tab[j]);
- else
- break;
- }
- if (j > lewy)
- quick_sort(tab, lewy, j);
- if (i < prawy)
- quick_sort(tab, i, prawy);
- }
- int main()
- {
- int a;
- do {
- cout << " Ello ! " << endl;
- cout << " 1. Poteg , 2. Przywitaj, 3. Silnia, 4. Sortuj, 5. Zakoncz" << endl;
- cin >> a;
- switch (a)
- {
- case 1:
- {
- int first = 0;
- int second = 0;
- cout << " Podaj liczby " << endl;
- cin >> first;
- cin >> second;
- poteg(first, second);
- break;
- }
- case 2:
- {
- string d;
- cout << " Your Name ! " << endl;
- cin >> d;
- hey(d);
- break;
- }
- case 3:
- {
- int f1;
- cout << " Podaj liczby" << endl;
- cin >> f1;
- silnia(f1);
- break;
- }
- case 4:
- {
- int *tab, n;
- cin >> n;
- tab = new int[n];
- for (int i = 0; i < n; i++)
- cin >> tab[i];
- quick_sort(tab, 0, n - 1);
- for (int i = 0; i < n; i++)
- cout << tab[i] << " ";
- cin.ignore();
- cin.get();
- break;
- }
- case 5:
- {
- cout << " KONIEC " << endl;
- return 0;
- }
- }
- } while (a != 5);
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement