From 84d3676f2bb8e7b71fca8802caec79f7e3f13ee0 Mon Sep 17 00:00:00 2001 From: hao14293 Date: Wed, 27 Mar 2019 10:37:39 +0800 Subject: [PATCH] =?UTF-8?q?Create=20=E6=97=A5=E6=9C=9F=E8=BD=AC=E6=8D=A2?= =?UTF-8?q?=E5=87=BD=E6=95=B0.cpp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DailySummary/日期转换函数.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 DailySummary/日期转换函数.cpp diff --git a/DailySummary/日期转换函数.cpp b/DailySummary/日期转换函数.cpp new file mode 100644 index 0000000..d1a8ce3 --- /dev/null +++ b/DailySummary/日期转换函数.cpp @@ -0,0 +1,22 @@ +#include +#include +using namespace std; + +int converse(int n, int d){ + int arr[100], index = 0; + while(n != 0){ + arr[index++] = n % d; + n = n / d; + } + int result = 0; + for(int i = index - 1; i >= 0; i--){ + result = result + arr[i] * pow(10, i); + } + return result; +} +int main(){ + int a, b; + cin >> a >> b; + cout << converse(a, b); + return 0; +}