第一期练习题test5

#include “pch.h”
#include
#include
using namespace std;

int main()
{
int a,n=0; //n记录a的位数
cin >> a;
int f = a;
int p[5];
int k = 1;
for (;f != 0; )
{
f = f / 10;
n++;
}
int i;
for ( i= 1; i<=n; ++i) //例 45411054
{
int t = pow(10, i);
int x = (a %t-a%(t/10))/(t/10);
if (x == 5)
{
p[k-1] = a % (t / 10);
a = a / t;
cout << “i=” << i << endl;
n = n - i;
cout << “n=” << n<<endl;
i = 1;
++k;//k表示被分成的组数
}
cout << “x=” << x << endl;
}
for ( i = 0; i < k; ++i)
{
cout << p[i] << ’ ';
}

}

猜你喜欢

转载自blog.csdn.net/weixin_44002829/article/details/84887883