#include <iostream>
using namespace std;
class Integer{
private:
int _num;
//getLength()函数获取_num长度
int getLength(){
int size=0;
while(_num>0){
size++;
_num/=10;
}
return size;
}
public:
//Integer类构造函数
Integer(int num){
_num=num;
}
//反转_num
int inversed(){
int innum=0;
while(_num>0){
innum= innum * 10 + _num % 10;
_num /= 10;
}
return innum;
}
};
int main() {
int n;
cin >> n;
Integer integer(n);
cout << integer.inversed() << endl;
system("pause");
return 0;
}
对于输入的一个正整数,输出其反转形式 使用c++ class编写
最新推荐文章于 2022-08-29 11:05:17 发布