#16854: Not "char" solution


szedicky770@gmail.com (Sze dicky)

學校 : 不指定學校
編號 : 70669
來源 : []
最後登入時間 :
2017-10-12 22:55:24
a038. 數字翻轉 | From: [112.120.200.81] | 發表日期 : 2019-02-14 03:07

#include <iostream>
#include <stack>
#include <cmath>

using namespace std;

int main()
{

int n;
int d = 0;
int temp = 0;

stack<int> s;

while(cin >> n)
{

if(n == 0)
{
cout << "0";
}

temp = log10(n);
while(n > 0)
{
d = n / pow(10, temp);
s.push(d);
n -= d * pow(10, temp);
temp--;
}

while(!s.empty())
{
cout << s.top();
s.pop();
}

cout << endl;
}

return 0;
}

 
ZeroJudge Forum