Code sinh số may mắn

#include <iostream> #include <bits/stdc++.h> using namespace std; string decimal_to_binary (int n,int m) { string res = ""; while (n > 0) { int digit = n % 2; res += digit + '0'; n /= 2; } while (res.size() < m) { res+="0"; } reverse(res.begin(), res.end()); return res; } int main() { int m; cin>>m; for (int i = 0; i<(1<<m); i++) { for (int j = 0; j<m; j++) { if ( (i& (1<<j)) > 0) { cout<<7; } else { cout<<4; } } cout<< endl; } return 0; }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.