Advertisement
tankian202

Untitled

Sep 1st, 2023 (edited)
635
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.20 KB | Source Code | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <cstring>
  4. #include <algorithm>
  5.  
  6. bool igeretesZ(int *pInt, int k, int n, char **pString);
  7.  
  8. void kiirZ(int *pInt, int n, int k, char **pString);
  9.  
  10. int countFives(int number, int count = 0) {
  11.     if (number == 0)
  12.         return count;
  13.     if (number % 10 == 5)
  14.         countFives(number / 10, count + 1);
  15.     else countFives(number / 10, count);
  16.  
  17. }
  18.  
  19.  
  20. long hatvanyozas(int alap, int kitevo) {
  21.     if (kitevo == 0)
  22.         return 1;
  23.     if (kitevo % 2 == 0)
  24.         return hatvanyozas(alap * alap, kitevo / 2);
  25.     return alap * hatvanyozas(alap, kitevo - 1);
  26. }
  27.  
  28. int kiirTomb(int n, int t[]) {
  29.     if (n == 0) {
  30.         return 0;
  31.     }
  32.     if (n > 0) {
  33. //        kiirTomb(n - 1,t);
  34. //        printf("%d ", t[n - 1]);
  35.         return t[n - 1] + kiirTomb(n - 1, t);
  36.     }
  37.  
  38. }
  39.  
  40.  
  41. using namespace std;
  42. void kiirZ(int *x, int k, char **szinek) {
  43.     for (int i = 0; i <= k; ++i) {
  44.         cout<<szinek[x[i]]<<' ';
  45.     }
  46.     cout<<'\n';
  47. }
  48.  
  49. bool igeretesZ(int *x, int k, char **szinek) {
  50.     if (k >= 1)
  51.         if (strstr("feher sarga narancs", szinek[x[1]])==NULL)
  52.             return false;
  53.     if(k>0 and strcmp(szinek[x[0]],szinek[x[1]])==0)
  54.         return false;
  55.     if(k>1 and strcmp(szinek[x[2]],szinek[x[1]])==0)
  56.         return false;
  57.  
  58.     return true;
  59. }
  60. void BTz(int *x, int n, int k, int p, char **szinek) {
  61.     int i;
  62.     for (i = 0; i < n; ++i) {
  63.         x[k]=i;
  64.         if (igeretesZ(x, k, szinek)) {
  65.             if (k < p-1) {
  66.                 BTz(x, n, k + 1, p, szinek);
  67.             } else kiirZ(x, k, szinek);
  68.         }
  69.     }
  70. }
  71.  
  72.  
  73.  
  74. int main() {
  75.     ifstream fin("be.txt");
  76.     int n;
  77.     fin >> n;
  78.     char **szinek = new char *[n];
  79.     for (int i = 0; i < n; ++i) {
  80.         szinek[i] = new char[25];
  81.         fin >> szinek[i];
  82.     }
  83.  
  84.  
  85.  
  86.     for (int i = 0; i < n; ++i) {
  87.         cout << szinek[i] << '\t';
  88.     }
  89.     cout<<'\n';
  90.     int tomb[] = {5, 4, 3, 2, 1};
  91.     sort(tomb,tomb+5);
  92.     for (int i = 0; i < 5; ++i) {
  93.         cout << tomb[i] << '\t';
  94.     }
  95.     int *x = new int[3];
  96. //    BTz(x, n, 0, 3, szinek);
  97.     for (int i = 0; i < n; ++i) {
  98.         delete[] szinek[i];
  99.     }
  100.     delete[] szinek;
  101. }
  102.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement