Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <cstring>
- #include <algorithm>
- bool igeretesZ(int *pInt, int k, int n, char **pString);
- void kiirZ(int *pInt, int n, int k, char **pString);
- int countFives(int number, int count = 0) {
- if (number == 0)
- return count;
- if (number % 10 == 5)
- countFives(number / 10, count + 1);
- else countFives(number / 10, count);
- }
- long hatvanyozas(int alap, int kitevo) {
- if (kitevo == 0)
- return 1;
- if (kitevo % 2 == 0)
- return hatvanyozas(alap * alap, kitevo / 2);
- return alap * hatvanyozas(alap, kitevo - 1);
- }
- int kiirTomb(int n, int t[]) {
- if (n == 0) {
- return 0;
- }
- if (n > 0) {
- // kiirTomb(n - 1,t);
- // printf("%d ", t[n - 1]);
- return t[n - 1] + kiirTomb(n - 1, t);
- }
- }
- using namespace std;
- void kiirZ(int *x, int k, char **szinek) {
- for (int i = 0; i <= k; ++i) {
- cout<<szinek[x[i]]<<' ';
- }
- cout<<'\n';
- }
- bool igeretesZ(int *x, int k, char **szinek) {
- if (k >= 1)
- if (strstr("feher sarga narancs", szinek[x[1]])==NULL)
- return false;
- if(k>0 and strcmp(szinek[x[0]],szinek[x[1]])==0)
- return false;
- if(k>1 and strcmp(szinek[x[2]],szinek[x[1]])==0)
- return false;
- return true;
- }
- void BTz(int *x, int n, int k, int p, char **szinek) {
- int i;
- for (i = 0; i < n; ++i) {
- x[k]=i;
- if (igeretesZ(x, k, szinek)) {
- if (k < p-1) {
- BTz(x, n, k + 1, p, szinek);
- } else kiirZ(x, k, szinek);
- }
- }
- }
- int main() {
- ifstream fin("be.txt");
- int n;
- fin >> n;
- char **szinek = new char *[n];
- for (int i = 0; i < n; ++i) {
- szinek[i] = new char[25];
- fin >> szinek[i];
- }
- for (int i = 0; i < n; ++i) {
- cout << szinek[i] << '\t';
- }
- cout<<'\n';
- int tomb[] = {5, 4, 3, 2, 1};
- sort(tomb,tomb+5);
- for (int i = 0; i < 5; ++i) {
- cout << tomb[i] << '\t';
- }
- int *x = new int[3];
- // BTz(x, n, 0, 3, szinek);
- for (int i = 0; i < n; ++i) {
- delete[] szinek[i];
- }
- delete[] szinek;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement