#include <iostream>
using namespace std;
int fun(unsigned n, int &zero) //统计无符号整数
{
int max = 0, t;
zero = 0;
do
{
t = n % 10;
if (t == 0)
zero++;
if (max < t)
max = t;
n = n / 10;
} while (n);
return max;
}
int fun(int n, int &zero) //统计有符号整数
{
int max = 0, t;
zero = 0;
do
{
t = n % 10;
if (t == 0)
zero++;
if (max < -t)
max = -t;
n = n / 10;
} while (n < -1);
return max;
}
int fun(double d, int &zero) //统计实数,要求四舍五入
{
int nd = 0;
nd = d * 10;
if (nd % 10 >= 5)
nd = nd / 10 + 1;
else if (nd % 10 > 0 || nd % 10 > -5)
nd = nd / 10;
else if (nd % 10 <= -5)
nd = nd / 10 - 1;
int max = 0, t;
zero = 0;
if (nd < 0)
{
do
{
t = nd % 10;
if (t == 0)
zero++;
if (max < -t)
max = -t;
nd = nd / 10;
} while (nd < -1);
}
else
{
do
{
t = nd % 10;
if (t == 0)
zero++;
if (max < t)
max = t;
nd = nd / 10;
} while (nd > 1);
}
return max;
}
#ifndef __COMPLEX__
#define __COMPLEX__
class complex;
class complex
{
public:
double real, image;
private:
};
#endif
int fun(complex c, int &zero)
{
int nd = 0;
nd = c.real * 10;
if (nd % 10 >= 5)
nd = nd / 10 + 1;
else if (nd % 10 > 0 || nd % 10 > -5)
nd = nd / 10;
else if (nd % 10 <= -5)
nd = nd / 10 - 1;
int max = 0, t;
zero = 0;
if (nd < 0)
{
do
{
t = nd % 10;
if (t == 0)
zero++;
if (max < -t)
max = -t;
nd = nd / 10;
} while (nd < -1);
}
else
{
do
{
t = nd % 10;
if (t == 0)
zero++;
if (max < t)
max = t;
nd = nd / 10;
} while (nd > 1);
}
return max;
}
//统计复数的实部
int main()
{
unsigned uNum;
int iNum;
int zero,max;
double dNum;
complex c;
cin>>uNum>>iNum>>dNum>>c.real>>c.image;
max=fun(uNum,zero);
cout<<"\nThe result of unsigned: max="<<max<<" zero="<<zero<<endl;
max=fun(iNum,zero);
cout<<"\nThe result of int: max="<<max<<" zero="<<zero<<endl;
max=fun(dNum,zero);
cout<<"\nThe result of double: max="<<max<<" zero="<<zero<<endl;
max=fun(c,zero);
cout<<"\nThe result of complex: max="<<max<<" zero="<<zero<<endl;
return 0;
}