(乙)1001 害死人不偿命的(3n+1)猜想

#include <iostream>
#include <cmath>
#include <cstring>
using namespace std;
int main()
{
	int a,b,c,m[10]= {0},x=0;
	cin>>a>>b;
	c=a+b;
	int ok=0;
	if(c>=0) ok=1;
	else c=fabs(c);
	if(c==0) cout<<c;
	else
		{
			while(c)
				{
					int p=c%10;
					c/=10;
					m[x++]=p;
				}
			if(ok==0) cout<<"-";
			for(int i=x-1; i>=0; i--)
				{
					if(i!=0&&i%3==0)
						{
							cout<<m[i]<<",";
						}
					else cout<<m[i];
				}
		}
	return 0;
}

猜你喜欢

转载自blog.csdn.net/Reticent_Man/article/details/80726566