Advertisement
STANAANDREY

pb2 2/11/2020

Nov 2nd, 2020 (edited)
2,108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4. int n, st[30];
  5. ofstream fout("morse.out");
  6.  
  7. void tipar() {
  8.     fout << '.';
  9.     for (int i = 1; i <= n; i++)
  10.         if (st[i] == 1)
  11.             fout << '.';
  12.         else
  13.             fout << '-';
  14.     fout << '.' << endl;
  15. }
  16.  
  17. void bktr(int k) {
  18.     if (n == k - 1) {
  19.         tipar();
  20.         return;
  21.     }
  22.     for (int i = 1; i <= 2; i++) {
  23.         st[k] = i;
  24.         bktr(k + 1);
  25.     }
  26. }
  27.  
  28. int main() {
  29.     cin >> n;
  30.     n -= 2;
  31.     bktr(1);
  32.     return 0;
  33. }
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement