#include <iostream> using namespace std; void decimalToBinary(int number) { if (number == 1 || number == 0) cout << number; else { decimalToBinary(number / 2); cout << number % 2; } } int main() { for (int i = 10; i <= 50; i++) { decimalToBinary(i); cout << endl; } cin.get(); return 0; }
时间: 2024-10-05 15:39:33