xiangshancuizhu

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;
}

  

分类:

技术点:

相关文章:

  • 2021-12-25
  • 2021-12-20
  • 2022-02-08
  • 2022-02-08
  • 2021-12-23
  • 2022-03-07
  • 2021-12-31
猜你喜欢
  • 2021-12-06
  • 2021-11-07
  • 2022-02-08
  • 2022-12-23
  • 2021-09-28
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案