Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- string print_first(int k) {
- int j;
- string s;
- unsigned long long mask = 0;
- unsigned long long max_mask = pow(2, k);
- while(mask < max_mask) {
- unsigned long long ind = 1;
- ind <<= k - 1;
- for (j = 0; j < k; j++) {
- if (mask & ind) {
- cout << "4";
- } else {
- cout << "3";
- }
- ind >>= 1;
- }
- mask++;
- }
- }
- void print_second(int k, string s) {
- int j;
- unsigned long long mask = 0;
- unsigned long long max_mask = pow(2, k);
- while(mask < max_mask) {
- cout << s;
- unsigned long long ind = 1;
- ind <<= k - 1;
- for (j = 0; j < k; j++) {
- if (mask & ind) {
- cout << "2";
- } else {
- cout << "1";
- }
- ind >>= 1;
- }
- cout << endl
- mask++;
- }
- }
- int main()
- {
- int k;
- cin >> k;
- int i;
- for (i = 0; i <= k; i++) {
- print_first(i);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement