9.1华为笔试上机考试啊,赶紧复习下字符串。
网上参考了下,自己写了个实现:
#include<iostream>
#include "stdio.h"
using namespace std;
char temp[100];
void my_swap(char &a,char &b)
{
char temp1 = a;
a = b;
b = temp1;
}
void res_num(int num)
{
int i = 0;
while (num)
{
temp[i++] = num%10 + '0';
num /= 10;
}
cout << temp << endl;
int j = 0;
--i;
while (j < i)
{
my_swap(temp[i],temp[j]);
++j;
--i;
}
}
int main()
{
res_num(10011828);
cout << temp;
}