Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int silnia (int x)
- {
- if (x == 0) return 1;
- else return x*silnia(x-1);
- }
- int main()
- {
- int a;
- cout << "Obliczanie silni z ";
- cout << "Podaj liczbe: ";
- cin >> a;
- cout << a << "! = " << silnia(a) << endl;
- return 0;
- }
- //P.C. IIIA
- #include <iostream>
- #include <cstdlib>
- using namespace std;
- void Dane (int &x,float tab[])
- {
- cout << "Sortowanie liczb rosnaco dowolnych liczb 'bombelkowo' P.C."<<endl;;
- cout << "Ile ma byc zbiorow :";
- cin >> x;
- cout << "Podaj wartosci : "<<endl;
- for (int i=0; i<x; i++)
- {
- cout <<" liczba(" <<i+1<<") =";
- cin >>tab[i];
- cout << endl;
- }
- }
- void Wypisz (int x, float tab[])
- {
- for (int i=0; i<x; i++)
- cout << tab[i]<< " ";
- cout << endl;
- }
- void Zamiana (float &a, float &b)
- {
- float temp;
- temp=a;
- a=b;
- b=temp;
- }
- void Bubble_sort (int x, float tab[])
- {
- for(int j=0;j<x-1; j++)
- for(int i=0; i<x-1;i++)
- if (tab[i]> tab[i+1]) Zamiana(tab[i], tab[i+1]);
- }
- float liczby[20];
- int y;
- int main()
- {
- Dane(y,liczby);
- Wypisz(y,liczby);
- Bubble_sort(y,liczby);
- cout << "Liczby uporzadkowane: "<< endl;
- Wypisz(y,liczby);
- return 0;
- }
- //P.C IIIa
- #include<iostream>
- #include<string.h>
- using namespace std;
- void zamiana(string &c, string &v)
- {
- string temp;
- temp = c;
- c = v;
- v = temp;
- }
- void sortowanie(int x, string tab[])
- {
- int j, k;
- for (int i = 0; i < x; i++)
- {
- k = i;
- for (int j = i; j < x; j++) if (tab[j] < tab[k]) k = j;
- zamiana(tab[k], tab[i]);
- }
- }
- void dane(int &x, string tab[])
- {
- cout << "Podaj ile ma byc imion:";
- cin >> x;
- cout << endl;
- for (int i = 0; i < x; i++)
- {
- cout << "Podaj Imie " << i + 1 << ":";
- cin >> tab[i];
- cout << endl;
- }
- }
- void wypisz(int x, string tab[])
- {
- for (int i = 0; i < x; i++)
- {
- cout << tab[i] << " ";
- }
- }
- void kobiety(int n, string lel[])
- {
- cout << endl;
- cout << "kobiety:";
- int index;
- string imie;
- for (int i = 0; i < n; i++)
- {
- imie = lel[i];
- index = lel[i].length() - 1;
- if (imie[index] == 'a')
- cout << lel[i] << " ";
- }
- }
- void mezczyzni(int n, string lel[])
- {
- cout << endl;
- cout << "mezczyzni: ";
- int index;
- string imie;
- for (int i = 0; i < n; i++)
- {
- imie = lel[i];
- index = lel[i].length() - 1;
- if (imie[index] != 'a')
- cout << lel[i] << " ";
- }
- }
- string slowa[20];
- int n;
- int main()
- {
- dane(n, slowa);
- wypisz(n, slowa);
- sortowanie(n, slowa);
- cout << endl << endl;
- cout << "Imiona ulozone alfabetycznie :" << " ";
- wypisz(n, slowa);
- kobiety(n, slowa);
- mezczyzni(n, slowa);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement